"Fossies" - the Fresh Open Source Software Archive

Member "icinga2-2.10.5/lib/compat/statusdatawriter.hpp" (23 May 2019, 3555 Bytes) of package /linux/misc/icinga2-2.10.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "statusdatawriter.hpp": 2.10.0_vs_2.10.1.

    1 /******************************************************************************
    2  * Icinga 2                                                                   *
    3  * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)      *
    4  *                                                                            *
    5  * This program is free software; you can redistribute it and/or              *
    6  * modify it under the terms of the GNU General Public License                *
    7  * as published by the Free Software Foundation; either version 2             *
    8  * of the License, or (at your option) any later version.                     *
    9  *                                                                            *
   10  * This program is distributed in the hope that it will be useful,            *
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
   13  * GNU General Public License for more details.                               *
   14  *                                                                            *
   15  * You should have received a copy of the GNU General Public License          *
   16  * along with this program; if not, write to the Free Software Foundation     *
   17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
   18  ******************************************************************************/
   19 
   20 #ifndef STATUSDATAWRITER_H
   21 #define STATUSDATAWRITER_H
   22 
   23 #include "compat/statusdatawriter-ti.hpp"
   24 #include "icinga/customvarobject.hpp"
   25 #include "icinga/host.hpp"
   26 #include "icinga/service.hpp"
   27 #include "icinga/command.hpp"
   28 #include "icinga/compatutility.hpp"
   29 #include "base/timer.hpp"
   30 #include "base/utility.hpp"
   31 #include <iostream>
   32 
   33 namespace icinga
   34 {
   35 
   36 /**
   37  * @ingroup compat
   38  */
   39 class StatusDataWriter final : public ObjectImpl<StatusDataWriter>
   40 {
   41 public:
   42     DECLARE_OBJECT(StatusDataWriter);
   43     DECLARE_OBJECTNAME(StatusDataWriter);
   44 
   45     static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
   46 
   47 protected:
   48     void Start(bool runtimeCreated) override;
   49     void Stop(bool runtimeRemoved) override;
   50 
   51 private:
   52     Timer::Ptr m_StatusTimer;
   53     bool m_ObjectsCacheOutdated;
   54 
   55     void DumpCommand(std::ostream& fp, const Command::Ptr& command);
   56     void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp);
   57     void DumpDowntimes(std::ostream& fp, const Checkable::Ptr& owner);
   58     void DumpComments(std::ostream& fp, const Checkable::Ptr& owner);
   59     void DumpHostStatus(std::ostream& fp, const Host::Ptr& host);
   60     void DumpHostObject(std::ostream& fp, const Host::Ptr& host);
   61 
   62     void DumpCheckableStatusAttrs(std::ostream& fp, const Checkable::Ptr& checkable);
   63 
   64     template<typename T>
   65     void DumpNameList(std::ostream& fp, const T& list)
   66     {
   67         bool first = true;
   68         for (const auto& obj : list) {
   69             if (!first)
   70                 fp << ",";
   71             else
   72                 first = false;
   73 
   74             fp << obj->GetName();
   75         }
   76     }
   77 
   78     template<typename T>
   79     void DumpStringList(std::ostream& fp, const T& list)
   80     {
   81         bool first = true;
   82         for (const auto& str : list) {
   83             if (!first)
   84                 fp << ",";
   85             else
   86                 first = false;
   87 
   88             fp << str;
   89         }
   90     }
   91 
   92     void DumpServiceStatus(std::ostream& fp, const Service::Ptr& service);
   93     void DumpServiceObject(std::ostream& fp, const Service::Ptr& service);
   94 
   95     void DumpCustomAttributes(std::ostream& fp, const CustomVarObject::Ptr& object);
   96 
   97     void UpdateObjectsCache();
   98     void StatusTimerHandler();
   99     void ObjectHandler();
  100 
  101     static String GetNotificationOptions(const Checkable::Ptr& checkable);
  102 };
  103 
  104 }
  105 
  106 #endif /* STATUSDATAWRITER_H */