| 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 | NSC_WRAPPERS_MAIN();
|
|---|
| 24 | NSC_WRAPPERS_CHANNELS();
|
|---|
| 25 |
|
|---|
| 26 | class NSCAAgent : public nscapi::impl::SimpleNotificationHandler {
|
|---|
| 27 | private:
|
|---|
| 28 |
|
|---|
| 29 | std::string hostname_;
|
|---|
| 30 | std::wstring nscahost_;
|
|---|
| 31 | unsigned int nscaport_;
|
|---|
| 32 | unsigned int payload_length_;
|
|---|
| 33 | bool cacheNscaHost_;
|
|---|
| 34 | std::string password_;
|
|---|
| 35 | int encryption_method_;
|
|---|
| 36 | unsigned int timeout_;
|
|---|
| 37 | int time_delta_;
|
|---|
| 38 |
|
|---|
| 39 | public:
|
|---|
| 40 | NSCAAgent();
|
|---|
| 41 | virtual ~NSCAAgent();
|
|---|
| 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 | * Return the module name.
|
|---|
| 50 | * @return The module name
|
|---|
| 51 | */
|
|---|
| 52 | std::wstring getModuleName() {
|
|---|
| 53 | #ifdef HAVE_LIBCRYPTOPP
|
|---|
| 54 | return _T("NSCAAgent (w/ encryption)");
|
|---|
| 55 | #else
|
|---|
| 56 | return _T("NSCAAgent");
|
|---|
| 57 | #endif
|
|---|
| 58 | }
|
|---|
| 59 | /**
|
|---|
| 60 | * Module version
|
|---|
| 61 | * @return module version
|
|---|
| 62 | */
|
|---|
| 63 | nscapi::plugin_wrapper::module_version getModuleVersion() {
|
|---|
| 64 | nscapi::plugin_wrapper::module_version version = {0, 3, 0 };
|
|---|
| 65 | return version;
|
|---|
| 66 | }
|
|---|
| 67 | std::wstring getModuleDescription() {
|
|---|
| 68 | return std::wstring(_T("Passive check support (needs NSCA on nagios server).\nAvalible crypto are: ")) + getCryptos();
|
|---|
| 69 | }
|
|---|
| 70 | bool hasNotificationHandler() { return true; }
|
|---|
| 71 |
|
|---|
| 72 | std::wstring getCryptos();
|
|---|
| 73 |
|
|---|
| 74 | NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf);
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | void set_delay(std::wstring key) {
|
|---|
| 78 | time_delta_ = strEx::stol_as_time_sec(key, 1);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | };
|
|---|