1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #ifndef PERFDATAWRITER_H
4 #define PERFDATAWRITER_H
6 #include "perfdata/perfdatawriter-ti.hpp"
7 #include "icinga/service.hpp"
8 #include "base/configobject.hpp"
9 #include "base/timer.hpp"
16 * An Icinga perfdata writer.
20 class PerfdataWriter final : public ObjectImpl<PerfdataWriter>
23 DECLARE_OBJECT(PerfdataWriter);
24 DECLARE_OBJECTNAME(PerfdataWriter);
26 static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
28 void ValidateHostFormatTemplate(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
29 void ValidateServiceFormatTemplate(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
32 void OnConfigLoaded() override;
33 void Resume() override;
34 void Pause() override;
37 Timer::Ptr m_RotationTimer;
38 std::ofstream m_ServiceOutputFile;
39 std::ofstream m_HostOutputFile;
40 boost::mutex m_StreamMutex;
42 void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
43 static Value EscapeMacroMetric(const Value& value);
45 void RotationTimerHandler();
46 void RotateAllFiles();
47 void RotateFile(std::ofstream& output, const String& temp_path, const String& perfdata_path);
52 #endif /* PERFDATAWRITER_H */