本文整理汇总了C++中plugin::queryrequestmessage::Request::arguments方法的典型用法代码示例。如果您正苦于以下问题:C++ Request::arguments方法的具体用法?C++ Request::arguments怎么用?C++ Request::arguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin::queryrequestmessage::Request
的用法示例。
在下文中一共展示了Request::arguments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log_args
void log_args(const Plugin::QueryRequestMessage::Request &request) {
std::stringstream ss;
for (int i=0;i<request.arguments_size();i++) {
if (i>0)
ss << " ";
if (request.arguments(i).find(" ") != std::string::npos)
ss << '\"' << request.arguments(i) << '\"';
else
ss << request.arguments(i);
}
NSC_DEBUG_MSG("Created command: " + ss.str());
}
示例2: lua
void lua::lua_runtime::on_query(std::string command, script_information *information, lua::lua_traits::function_type function, bool simple, const Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response, const Plugin::QueryRequestMessage &request_message)
{
lua_wrapper lua(prep_function(information, function));
int args = 2;
if (function.object_ref != 0)
args = 3;
if (simple) {
std::list<std::string> argslist;
for (int i=0;i<request.arguments_size();i++)
argslist.push_back(request.arguments(i));
lua.push_string(command);
lua.push_array(argslist);
if (lua.pcall(args, 3, 0) != 0)
return nscapi::protobuf::functions::set_response_bad(*response, "Failed to handle command: " + command + ": " + lua.pop_string());
NSCAPI::nagiosReturn ret = NSCAPI::returnUNKNOWN;
if (lua.size() < 3) {
NSC_LOG_ERROR_STD("Invalid return: " + lua.dump_stack());
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, NSCAPI::returnUNKNOWN, "Invalid return", "");
return;
}
std::string msg, perf;
perf = lua.pop_string();
msg = lua.pop_string();
ret = lua.pop_code();
lua.gc(LUA_GCCOLLECT, 0);
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, ret, msg, perf);
} else {
lua.push_string(command);
lua.push_raw_string(request.SerializeAsString());
lua.push_raw_string(request_message.SerializeAsString());
args++;
if (lua.pcall(args, 1, 0) != 0)
return nscapi::protobuf::functions::set_response_bad(*response, "Failed to handle command: " + command + ": " + lua.pop_string());
if (lua.size() < 1) {
NSC_LOG_ERROR_STD("Invalid return: " + lua.dump_stack());
nscapi::protobuf::functions::append_simple_query_response_payload(response, command, NSCAPI::returnUNKNOWN, "Invalid return data", "");
return;
}
Plugin::QueryResponseMessage local_response;
std::string data = lua.pop_raw_string();
response->ParseFromString(data);
lua.gc(LUA_GCCOLLECT, 0);
}
}
示例3: query_fallback
void CheckExternalScripts::query_fallback(const Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response, const Plugin::QueryRequestMessage &) {
//nscapi::functions::decoded_simple_command_data data = nscapi::functions::parse_simple_query_request(char_command, request);
commands::optional_command_object command_def = commands_.find_object(request.command());
std::list<std::string> args;
for (int i=0;i<request.arguments_size();++i) {
args.push_back(request.arguments(i));
}
if (command_def) {
handle_command(*command_def, args, response);
return;
}
alias::optional_command_object alias_def = aliases_.find_object(request.command());
if (alias_def) {
handle_alias(*alias_def, args, response);
return;
}
NSC_LOG_ERROR_STD("No command or alias found matching: " + request.command());
nscapi::protobuf::functions::set_response_bad(*response, "No command or alias found matching: " + request.command());
}
示例4: query_fallback
void CheckExternalScripts::query_fallback(const Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response, const Plugin::QueryRequestMessage &) {
if (!provider_) {
NSC_LOG_ERROR_STD("No provider found: " + request.command());
nscapi::protobuf::functions::set_response_bad(*response, "No command or alias found matching: " + request.command());
return;
}
commands::command_object_instance command_def = provider_->find_command(request.command());
std::list<std::string> args;
for (int i = 0; i < request.arguments_size(); ++i) {
args.push_back(request.arguments(i));
}
if (command_def) {
handle_command(*command_def, args, response);
return;
}
alias::command_object_instance alias_def = aliases_.find_object(request.command());
if (alias_def) {
handle_alias(*alias_def, args, response);
return;
}
NSC_LOG_ERROR_STD("No command or alias found matching: " + request.command());
nscapi::protobuf::functions::set_response_bad(*response, "No command or alias found matching: " + request.command());
}