| 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 <boost/optional.hpp>
|
|---|
| 24 | #include <boost/scoped_ptr.hpp>
|
|---|
| 25 |
|
|---|
| 26 | #include <protobuf/plugin.pb.h>
|
|---|
| 27 |
|
|---|
| 28 | #include <strEx.h>
|
|---|
| 29 | #include <utils.h>
|
|---|
| 30 | #include <scripts/functions.hpp>
|
|---|
| 31 | #include <scripts/script_interface.hpp>
|
|---|
| 32 | #include <scripts/script_nscp.hpp>
|
|---|
| 33 |
|
|---|
| 34 | #include <lua/lua_script.hpp>
|
|---|
| 35 | #include <lua/lua_core.hpp>
|
|---|
| 36 |
|
|---|
| 37 | class LUAScript : public nscapi::impl::simple_plugin {
|
|---|
| 38 | private:
|
|---|
| 39 | boost::scoped_ptr<scripts::script_manager<lua::lua_traits> > scripts_;
|
|---|
| 40 | boost::shared_ptr<lua::lua_runtime> lua_runtime_;
|
|---|
| 41 | boost::shared_ptr<scripts::nscp::nscp_runtime_impl> nscp_runtime_;
|
|---|
| 42 | boost::filesystem::path root_;
|
|---|
| 43 |
|
|---|
| 44 | public:
|
|---|
| 45 | LUAScript() {}
|
|---|
| 46 | virtual ~LUAScript() {}
|
|---|
| 47 | // Module calls
|
|---|
| 48 | bool loadModuleEx(std::string alias, NSCAPI::moduleLoadMode mode);
|
|---|
| 49 |
|
|---|
| 50 | bool unloadModule();
|
|---|
| 51 | void query_fallback(const Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response, const Plugin::QueryRequestMessage &request_message);
|
|---|
| 52 | bool commandLineExec(const Plugin::ExecuteRequestMessage::Request &request, Plugin::ExecuteResponseMessage::Response *response, const Plugin::ExecuteRequestMessage &request_message);
|
|---|
| 53 | void handleNotification(const std::string &channel, const Plugin::QueryResponseMessage::Response &request, Plugin::SubmitResponseMessage::Response *response, const Plugin::SubmitRequestMessage &request_message);
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | bool reload(std::wstring &msg);
|
|---|
| 57 |
|
|---|
| 58 | bool loadScript(std::string alias, std::string file);
|
|---|
| 59 | // NSCAPI::nagiosReturn execute_and_load(std::list<std::wstring> args, std::wstring &message);
|
|---|
| 60 | // NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf);
|
|---|
| 61 | // NSCAPI::nagiosReturn handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response);
|
|---|
| 62 | // NSCAPI::nagiosReturn commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result);
|
|---|
| 63 | };
|
|---|