source: nscp/modules/CheckSystem/CheckSystem.h @ 3bdaf18

0.4.00.4.10.4.2
Last change on this file since 3bdaf18 was 3bdaf18, checked in by Michael Medin <michael@…>, 2 years ago

Tweaks to building on linux, stil need to fix the utf8 issue and some modules...

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/**************************************************************************
2*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
3*                                                                         *
4*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
5*                                                                         *
6*   This program is free software; you can redistribute it and/or modify  *
7*   it under the terms of the GNU General Public License as published by  *
8*   the Free Software Foundation; either version 2 of the License, or     *
9*   (at your option) any later version.                                   *
10*                                                                         *
11*   This program is distributed in the hope that it will be useful,       *
12*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14*   GNU General Public License for more details.                          *
15*                                                                         *
16*   You should have received a copy of the GNU General Public License     *
17*   along with this program; if not, write to the                         *
18*   Free Software Foundation, Inc.,                                       *
19*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20***************************************************************************/
21#pragma once
22
23#include <pdh.hpp>
24#include "PDHCollector.h"
25#include <CheckMemory.h>
26
27NSC_WRAPPERS_MAIN();
28NSC_WRAPPERS_CLI();
29
30class CheckSystem : public nscapi::impl::SimpleCommand, public nscapi::impl::simple_plugin {
31private:
32        CheckMemory memoryChecker;
33        PDHCollectorThread pdhThread;
34
35public:
36        typedef enum { started, stopped } states;
37        typedef struct rB {
38                NSCAPI::nagiosReturn code_;
39                std::wstring msg_;
40                std::wstring perf_;
41                rB(NSCAPI::nagiosReturn code, std::wstring msg) : code_(code), msg_(msg) {}
42                rB() : code_(NSCAPI::returnUNKNOWN) {}
43        } returnBundle;
44
45        std::map<DWORD,std::wstring> lookups_;
46
47
48public:
49        CheckSystem();
50        virtual ~CheckSystem();
51        // Module calls
52        bool loadModule();
53        bool loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode);
54        bool unloadModule();
55        std::wstring getConfigurationMeta();
56
57        /**
58        * Return the module name.
59        * @return The module name
60        */
61        std::wstring getModuleName() {
62                return _T("CheckSystem");
63        }
64        /**
65        * Module version
66        * @return module version
67        */
68        nscapi::plugin_wrapper::module_version getModuleVersion() {
69                nscapi::plugin_wrapper::module_version version = {0, 3, 0 };
70                return version;
71        }
72        std::wstring getModuleDescription() {
73                return _T("Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.");
74        }
75
76        bool hasCommandHandler();
77        bool hasMessageHandler();
78        NSCAPI::nagiosReturn handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf);
79        int commandLineExec(const wchar_t* command,const unsigned int argLen,wchar_t** args);
80
81        NSCAPI::nagiosReturn checkCPU(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
82        NSCAPI::nagiosReturn checkUpTime(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
83        NSCAPI::nagiosReturn checkServiceState(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
84        NSCAPI::nagiosReturn checkMem(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
85        NSCAPI::nagiosReturn checkProcState(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
86        NSCAPI::nagiosReturn checkCounter(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
87        NSCAPI::nagiosReturn listCounterInstances(std::list<std::wstring> arguments, std::wstring &msg, std::wstring &perf);
88        NSCAPI::nagiosReturn checkSingleRegEntry(std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf);
89
90
91};
Note: See TracBrowser for help on using the repository browser.