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
|
|
|
|
|
|
|
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-05-27 15:09:26 +02:00
|
|
|
std::shared_ptr<AsioTcpStream> m_Stream;
|
2015-02-07 22:36:17 +01:00
|
|
|
|
2015-01-28 10:57:34 +01:00
|
|
|
Timer::Ptr m_ReconnectTimer;
|
|
|
|
|
|
|
|
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();
|
2015-01-28 10:57:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OPENTSDBWRITER_H */
|