89 lines
2.1 KiB
C++
Executable File
89 lines
2.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Handler for CheckmkHandlerScheduleCheck
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Norbert Thoden, SLSE, 2022-11-03
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "dds_handler.h"
|
|
#include "logger.h"
|
|
#include <ComponentMonitor/cmo_fts.h>
|
|
#include <ComponentMonitor/cmo.hpp>
|
|
#include <QTimer>
|
|
#include <QTcpSocket>
|
|
#include <QDataStream>
|
|
|
|
namespace DDSConnector
|
|
{
|
|
class DdsConnector;
|
|
}
|
|
|
|
namespace ComponentMonitor
|
|
{
|
|
class DdsHandler;
|
|
|
|
// Maybe helpful:
|
|
// https://docs.checkmk.com/latest/de/livestatus.html
|
|
// https://docs.checkmk.com/latest/de/livestatus_references.html
|
|
// https://github.com/sileht/check_mk/blob/master/livestatus/api/python/livestatus.py
|
|
|
|
class CheckmkHandlerScheduleCheck : public QObject
|
|
, protected Interface::Fts::TriggerUpdateRequestHandler
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CheckmkHandlerScheduleCheck(const std::shared_ptr<DdsHandler> &ddsHandler);
|
|
~CheckmkHandlerScheduleCheck();
|
|
|
|
bool initialize(const QString &checkMkServerHostname, int checkMkServerPort);
|
|
|
|
void run(int timoutMsec = 100);
|
|
void stop();
|
|
bool doConnect();
|
|
void addScheduleCheckHostnames(const QStringList &hostnames);
|
|
|
|
private:
|
|
bool writeScheduleUpdateRequest();
|
|
|
|
Q_SIGNALS:
|
|
void newCheckScheduled();
|
|
void updateLastCheckTimeDirect(QStringList hostnamesForLastCheckTime, qint64 lastCheckSec);
|
|
|
|
private Q_SLOTS:
|
|
void onTimeout();
|
|
void onConnected();
|
|
void onStateChanged(const QAbstractSocket::SocketState &newState);
|
|
void onSocketError(const QAbstractSocket::SocketError &socketError);
|
|
|
|
private:
|
|
void onTriggerUpdateRequest(const rti::core::SampleIdentity &cookie,
|
|
const TriggerUpdate &request) override;
|
|
|
|
|
|
protected:
|
|
bool processLine(const QByteArray &line);
|
|
|
|
private:
|
|
// checkMkServer
|
|
QString m_checkMkHost;
|
|
quint16 m_checkMkPort{0};
|
|
QTimer *m_timer{nullptr};
|
|
|
|
QStringList m_scheduleCheckHostnames;
|
|
|
|
QTcpSocket *m_socket{nullptr};
|
|
|
|
std::shared_ptr<DdsHandler> m_ddsHandler;
|
|
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
};
|
|
|
|
|
|
} // namespace ComponentMonitor
|