| 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 <config.h>
|
|---|
| 24 |
|
|---|
| 25 | #include <string>
|
|---|
| 26 |
|
|---|
| 27 | //#include <NSCAPI.h>
|
|---|
| 28 | #include <nscapi/plugin.hpp>
|
|---|
| 29 |
|
|---|
| 30 | #include <boost/thread/thread.hpp>
|
|---|
| 31 | #include <boost/thread/locks.hpp>
|
|---|
| 32 |
|
|---|
| 33 | NSC_WRAPPERS_MAIN();
|
|---|
| 34 |
|
|---|
| 35 | class CheckNSCP : public nscapi::impl::SimpleCommand, public nscapi::impl::simple_plugin, public nscapi::impl::simple_log_handler {
|
|---|
| 36 | private:
|
|---|
| 37 | boost::timed_mutex mutex_;
|
|---|
| 38 | std::wstring crashFolder;
|
|---|
| 39 | typedef std::list<std::string> error_list;
|
|---|
| 40 | error_list errors_;
|
|---|
| 41 | public:
|
|---|
| 42 | // Module calls
|
|---|
| 43 | bool loadModule();
|
|---|
| 44 | bool loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode);
|
|---|
| 45 | bool unloadModule();
|
|---|
| 46 | std::wstring getConfigurationMeta();
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | std::wstring getModuleName() {
|
|---|
| 50 | return _T("Check NSCP");
|
|---|
| 51 | }
|
|---|
| 52 | nscapi::plugin_wrapper::module_version getModuleVersion() {
|
|---|
| 53 | nscapi::plugin_wrapper::module_version version = {0, 0, 1 };
|
|---|
| 54 | return version;
|
|---|
| 55 | }
|
|---|
| 56 | std::wstring getModuleDescription() {
|
|---|
| 57 | return _T("Checkes the state of the agent");
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | bool hasCommandHandler();
|
|---|
| 61 | bool hasMessageHandler();
|
|---|
| 62 | void handleMessage(int msgType, const std::string file, int line, std::string message);
|
|---|
| 63 | NSCAPI::nagiosReturn handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf);
|
|---|
| 64 | std::string render(int msgType, const std::string file, int line, std::string message);
|
|---|
| 65 | NSCAPI::nagiosReturn check_nscp( std::list<std::wstring> arguments, std::wstring & msg, std::wstring & perf );
|
|---|
| 66 | int get_crashes(std::wstring &last_crash);
|
|---|
| 67 | int get_errors(std::wstring &last_error);
|
|---|
| 68 | }; |
|---|