source: nscp/trunk/modules/CheckExternalScripts/CheckExternalScripts.h @ 34f5502

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

+ Added propper output handling to process subsystem (now you can execute programs tat return "much" data.

+ Added select support for SSL_write (now you can send "any amount of data" to the (SSL) socket.

Since check_nrpe doesn't do this it wont work in that end, but still...

  • 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
42public:
43        CheckExternalScripts();
44        virtual ~CheckExternalScripts();
45        // Module calls
46        bool loadModule();
47        bool unloadModule();
48
49
50        std::wstring getModuleName() {
51                return _T("Check External Scripts");
52        }
53        NSCModuleWrapper::module_version getModuleVersion() {
54                NSCModuleWrapper::module_version version = {0, 0, 1 };
55                return version;
56        }
57        std::wstring getModuleDescription() {
58                return _T("A simple wrapper to run external scripts and batch files.");
59        }
60
61        bool hasCommandHandler();
62        bool hasMessageHandler();
63        NSCAPI::nagiosReturn handleCommand(const strEx::blindstr command, const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf);
64        std::wstring getConfigurationMeta();
65
66private:
67        class NRPEException {
68                std::wstring error_;
69        public:
70                NRPEException(std::wstring s) {
71                        error_ = s;
72                }
73                std::wstring getMessage() {
74                        return error_;
75                }
76        };
77
78
79private:
80        void addAllScriptsFrom(std::wstring path);
81        void addCommand(strEx::blindstr key, std::wstring cmd = _T(""), std::wstring args = _T("")) {
82                commands[key] = command_data(cmd, args);
83        }
84        void addAlias(strEx::blindstr key, std::wstring cmd = _T(""), std::wstring args = _T("")) {
85                alias[key] = command_data(cmd, args);
86        }
87};
88
Note: See TracBrowser for help on using the repository browser.