1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #ifndef INFLUXDBWRITER_H
4 #define INFLUXDBWRITER_H
6 #include "perfdata/influxdbwriter-ti.hpp"
7 #include "icinga/service.hpp"
8 #include "base/configobject.hpp"
9 #include "base/tcpsocket.hpp"
10 #include "base/timer.hpp"
11 #include "base/tlsstream.hpp"
12 #include "base/workqueue.hpp"
19 * An Icinga InfluxDB writer.
23 class InfluxdbWriter final : public ObjectImpl<InfluxdbWriter>
26 DECLARE_OBJECT(InfluxdbWriter);
27 DECLARE_OBJECTNAME(InfluxdbWriter);
29 static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
31 void ValidateHostTemplate(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
32 void ValidateServiceTemplate(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
35 void OnConfigLoaded() override;
36 void Resume() override;
37 void Pause() override;
40 WorkQueue m_WorkQueue{10000000, 1};
41 Timer::Ptr m_FlushTimer;
42 std::vector<String> m_DataBuffer;
44 void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
45 void CheckResultHandlerWQ(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
46 void SendMetric(const Checkable::Ptr& checkable, const Dictionary::Ptr& tmpl,
47 const String& label, const Dictionary::Ptr& fields, double ts);
49 void FlushTimeoutWQ();
52 static String EscapeKeyOrTagValue(const String& str);
53 static String EscapeValue(const Value& value);
55 OptionalTlsStream Connect();
57 void AssertOnWorkQueue();
59 void ExceptionHandler(boost::exception_ptr exp);
64 #endif /* INFLUXDBWRITER_H */