source: nscp/modules/CheckExternalScripts/CheckExternalScripts.h @ 9567d4b

0.4.00.4.10.4.2
Last change on this file since 9567d4b was 9567d4b, checked in by Michael Medin <michael@…>, 5 years ago

2008-05-?? MickeM

  • BREAKING CHANGE! -- THe API function NSCLoadPlugin has been changed to take an integer to define the load-status

2008-06-?? MickeM

  • BREAKING CHANGE! -- New settings API as well as new WEBConfiguration UI (nothing is finnished yet but I wanted to check things into the SVN since it is a lot of changes now :)

2008-05-14 MickeM

  • Fixed memoryleak in the service checker.

I am really sorry I usualy write better code then this.

2008-05-11 MickeM

  • BREAKING CHANGE! -- Changed PDH options to a more uniform design:

auto_detect_pdh and dont_use_pdh_index has been removed and instead there is a new method option that takes various values.

  • Property mode set to 100644
File size: 3.3 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
22NSC_WRAPPERS_MAIN();
23#include <map>
24#include <error.hpp>
25#include <execute_process.hpp>
26
27class CheckExternalScripts {
28private:
29        struct command_data {
30                command_data() {}
31                command_data(std::wstring command_, std::wstring arguments_) : command(command_), arguments(arguments_) {}
32                std::wstring command;
33                std::wstring arguments;
34        };
35        typedef std::map<strEx::blindstr, command_data> command_list;
36        command_list commands;
37        command_list alias;
38        unsigned int timeout;
39        std::wstring scriptDirectory_;
40        std::wstring root_;
41        bool allowArgs_;
42        bool allowNasty_;
43
44public:
45        CheckExternalScripts();
46        virtual ~CheckExternalScripts();
47        // Module calls
48        bool loadModule(NSCAPI::moduleLoadMode mode);
49        bool unloadModule();
50
51
52        std::wstring getModuleName() {
53                return _T("Check External Scripts");
54        }
55        NSCModuleWrapper::module_version getModuleVersion() {
56                NSCModuleWrapper::module_version version = {0, 0, 1 };
57                return version;
58        }
59        std::wstring getModuleDescription() {
60                return _T("A simple wrapper to run external scripts and batch files.");
61        }
62
63        bool hasCommandHandler();
64        bool hasMessageHandler();
65        NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf);
66        std::wstring getConfigurationMeta();
67
68private:
69        class NRPEException {
70                std::wstring error_;
71        public:
72                NRPEException(std::wstring s) {
73                        error_ = s;
74                }
75                std::wstring getMessage() {
76                        return error_;
77                }
78        };
79
80
81private:
82        void addAllScriptsFrom(std::wstring path);
83        void addCommand(strEx::blindstr key, std::wstring cmd = _T(""), std::wstring args = _T("")) {
84                commands[key] = command_data(cmd, args);
85        }
86        void addAlias(strEx::blindstr key, std::wstring cmd = _T(""), std::wstring args = _T("")) {
87                alias[key] = command_data(cmd, args);
88        }
89};
90
Note: See TracBrowser for help on using the repository browser.