source: nscp/modules/CheckSystem/CheckSystem.h @ d1029bd

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

2010-04-21 MickeM - 0.3.8 RC1

+ Added support for strings and int (values) to CheckSingleRegEntry?

Use like so (int):

CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSize? "syntax=%path%: %int%" warn==20971520 crit==20971520 check=int ShowAll=long
CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSize? "syntax=%path%: %int%" warn==30971520 crit==30971520 check=int ShowAll=long

Use like so (string):

CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSize? "syntax=%path%: %string%" warn==20971520 crit==20971520 check=string ShowAll=long
CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSize? "syntax=%path%: %string%" warn==30971520 crit==30971520 check=string ShowAll=long

This can ofcourse be combined and all valid operators (like regexp, substr, lt, gt, ne etc etc are supported.


2010-04-16 MickeM

+ Added new Check to CheckSystem: CheckSingleRegEntry?

Similar to the previous CheckSIngleFile but can be used to check aspects of registry entries.

CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSize? "syntax=%path%: %exists%" warn==true crit==true check=exists ShowAll=long

CheckSingleRegEntry? path=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet?\services\eventlog\Application\MaxSizeYY "syntax=%path%: %exists%" warn==true crit==true check=exists ShowAll=long

Currently only supports checking existanse of keys but more checks will be added soon.

  • Property mode set to 100644
File size: 3.8 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 {
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
45public:
46        CheckSystem();
47        virtual ~CheckSystem();
48        // Module calls
49        bool loadModule();
50        bool unloadModule();
51        std::wstring getConfigurationMeta();
52
53        /**
54        * Return the module name.
55        * @return The module name
56        */
57        std::wstring getModuleName() {
58                return _T("CheckSystem");
59        }
60        /**
61        * Module version
62        * @return module version
63        */
64        NSCModuleWrapper::module_version getModuleVersion() {
65                NSCModuleWrapper::module_version version = {0, 3, 0 };
66                return version;
67        }
68        std::wstring getModuleDescription() {
69                return _T("Various system related checks, such as CPU load, process state, service state memory usage and PDH counters.");
70        }
71
72        bool hasCommandHandler();
73        bool hasMessageHandler();
74        NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
75        int commandLineExec(const TCHAR* command,const unsigned int argLen,TCHAR** args);
76
77        NSCAPI::nagiosReturn checkCPU(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
78        NSCAPI::nagiosReturn checkUpTime(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
79        NSCAPI::nagiosReturn checkServiceState(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
80        NSCAPI::nagiosReturn checkMem(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
81        NSCAPI::nagiosReturn checkProcState(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
82        NSCAPI::nagiosReturn checkCounter(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
83        NSCAPI::nagiosReturn listCounterInstances(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf);
84        NSCAPI::nagiosReturn checkSingleRegEntry(const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf);
85
86
87};
Note: See TracBrowser for help on using the repository browser.