aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/messagebus/mon_messagebus.h
blob: e1fa73c69fb1a7f603a38f7f1e045357480f76fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include <library/cpp/messagebus/ybus.h>
#include <library/cpp/messagebus/www/www.h>

#include <library/cpp/monlib/service/pages/mon_page.h>

namespace NMonitoring {
    template <class TBusSmth>
    class TBusSmthMonPage: public NMonitoring::IMonPage {
    private:
        TBusSmth* Smth;

    public:
        explicit TBusSmthMonPage(const TString& name, const TString& title, TBusSmth* smth)
            : IMonPage("msgbus/" + name, title)
            , Smth(smth)
        {
        }
        void Output(NMonitoring::IMonHttpRequest& request) override {
            Y_UNUSED(request);
            request.Output() << NMonitoring::HTTPOKHTML;
            request.Output() << "<h2>" << Title << "</h2>";
            request.Output() << "<pre>";
            request.Output() << Smth->GetStatus();
            request.Output() << "</pre>";
        }
    };

    using TBusQueueMonPage = TBusSmthMonPage<NBus::TBusMessageQueue>;
    using TBusModuleMonPage = TBusSmthMonPage<NBus::TBusModule>;

    class TBusNgMonPage: public NMonitoring::IMonPage {
    public:
        TIntrusivePtr<NBus::TBusWww> BusWww;

    public:
        TBusNgMonPage()
            : IMonPage("messagebus", "MessageBus")
            , BusWww(new NBus::TBusWww)
        {
        }
        void Output(NMonitoring::IMonHttpRequest& request) override;
    };

}