2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2015-01-28 10:57:34 +01:00
|
|
|
|
|
|
|
#ifndef OPENTSDBWRITER_H
|
|
|
|
#define OPENTSDBWRITER_H
|
|
|
|
|
2018-01-18 13:50:38 +01:00
|
|
|
#include "perfdata/opentsdbwriter-ti.hpp"
|
2015-01-28 10:57:34 +01:00
|
|
|
#include "icinga/service.hpp"
|
2015-08-15 20:28:05 +02:00
|
|
|
#include "base/configobject.hpp"
|
2015-01-28 10:57:34 +01:00
|
|
|
#include "base/tcpsocket.hpp"
|
|
|
|
#include "base/timer.hpp"
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Icinga opentsdb writer.
|
|
|
|
*
|
|
|
|
* @ingroup perfdata
|
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class OpenTsdbWriter final : public ObjectImpl<OpenTsdbWriter>
|
2015-01-28 10:57:34 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_OBJECT(OpenTsdbWriter);
|
|
|
|
DECLARE_OBJECTNAME(OpenTsdbWriter);
|
|
|
|
|
2015-02-07 22:36:17 +01:00
|
|
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
2015-01-28 10:57:34 +01:00
|
|
|
|
2019-07-23 15:28:42 +02:00
|
|
|
void ValidateHostTemplate(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
|
|
|
|
void ValidateServiceTemplate(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
|
|
|
|
|
2015-01-28 10:57:34 +01:00
|
|
|
protected:
|
2018-10-24 13:55:19 +02:00
|
|
|
void OnConfigLoaded() override;
|
|
|
|
void Resume() override;
|
|
|
|
void Pause() override;
|
2015-01-28 10:57:34 +01:00
|
|
|
|
|
|
|
private:
|
2019-07-25 14:55:22 +02:00
|
|
|
Shared<AsioTcpStream>::Ptr m_Stream;
|
2015-02-07 22:36:17 +01:00
|
|
|
|
2015-01-28 10:57:34 +01:00
|
|
|
Timer::Ptr m_ReconnectTimer;
|
|
|
|
|
2019-07-26 17:31:16 +02:00
|
|
|
Dictionary::Ptr m_ServiceConfigTemplate;
|
|
|
|
Dictionary::Ptr m_HostConfigTemplate;
|
|
|
|
|
2015-01-28 10:57:34 +01:00
|
|
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
2019-03-19 09:38:32 +01:00
|
|
|
void SendMetric(const Checkable::Ptr& checkable, const String& metric,
|
|
|
|
const std::map<String, String>& tags, double value, double ts);
|
|
|
|
void SendPerfdata(const Checkable::Ptr& checkable, const String& metric,
|
|
|
|
const std::map<String, String>& tags, const CheckResult::Ptr& cr, double ts);
|
2015-01-28 10:57:34 +01:00
|
|
|
static String EscapeTag(const String& str);
|
|
|
|
static String EscapeMetric(const String& str);
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
void ReconnectTimerHandler();
|
2019-07-26 17:31:16 +02:00
|
|
|
|
|
|
|
void ReadConfigTemplate(const Dictionary::Ptr& stemplate,
|
|
|
|
const Dictionary::Ptr& htemplate);
|
2015-01-28 10:57:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OPENTSDBWRITER_H */
|