mirror of
https://github.com/Icinga/icinga2.git
synced 2026-04-09 10:56:28 -04:00
I've used the following command to replace the original copyright header
lines in a C-style comment block:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
And for SQL files:
```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#ifndef PERFDATAWRITER_H
|
|
#define PERFDATAWRITER_H
|
|
|
|
#include "perfdata/perfdatawriter-ti.hpp"
|
|
#include "icinga/service.hpp"
|
|
#include "base/configobject.hpp"
|
|
#include "base/timer.hpp"
|
|
#include <fstream>
|
|
|
|
namespace icinga
|
|
{
|
|
|
|
/**
|
|
* An Icinga perfdata writer.
|
|
*
|
|
* @ingroup icinga
|
|
*/
|
|
class PerfdataWriter final : public ObjectImpl<PerfdataWriter>
|
|
{
|
|
public:
|
|
DECLARE_OBJECT(PerfdataWriter);
|
|
DECLARE_OBJECTNAME(PerfdataWriter);
|
|
|
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
|
|
|
void ValidateHostFormatTemplate(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
|
|
void ValidateServiceFormatTemplate(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
|
|
|
|
protected:
|
|
void OnConfigLoaded() override;
|
|
void Resume() override;
|
|
void Pause() override;
|
|
|
|
private:
|
|
boost::signals2::connection m_HandleCheckResults;
|
|
Timer::Ptr m_RotationTimer;
|
|
std::ofstream m_ServiceOutputFile;
|
|
std::ofstream m_HostOutputFile;
|
|
std::mutex m_StreamMutex;
|
|
|
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
|
static Value EscapeMacroMetric(const Value& value);
|
|
|
|
void RotationTimerHandler();
|
|
void RotateAllFiles();
|
|
void RotateFile(std::ofstream& output, const String& temp_path, const String& perfdata_path);
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* PERFDATAWRITER_H */
|