本文整理汇总了C++中plugin::queryrequestmessage::Request::clear_arguments方法的典型用法代码示例。如果您正苦于以下问题:C++ Request::clear_arguments方法的具体用法?C++ Request::clear_arguments怎么用?C++ Request::clear_arguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plugin::queryrequestmessage::Request
的用法示例。
在下文中一共展示了Request::clear_arguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDriveSize
void CheckDisk::checkDriveSize(Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response) {
boost::program_options::options_description desc;
std::vector<std::string> times;
std::vector<std::string> types;
std::string perf_unit;
nscapi::program_options::add_help(desc);
desc.add_options()
("CheckAll", po::value<std::string>()->implicit_value("true"), "Checks all drives.")
("CheckAllOthers", po::value<std::string>()->implicit_value("true"), "Checks all drives turns the drive option into an exclude option.")
("Drive", po::value<std::vector<std::string>>(×), "The drives to check")
("FilterType", po::value<std::vector<std::string>>(&types), "The type of drives to check fixed, remote, cdrom, ramdisk, removable")
("perf-unit", po::value<std::string>(&perf_unit), "Force performance data to use a given unit prevents scaling which can cause problems over time in some graphing solutions.")
;
compat::addShowAll(desc);
compat::addAllNumeric(desc);
compat::addAllNumeric(desc, "Free");
compat::addAllNumeric(desc, "Used");
boost::program_options::variables_map vm;
std::vector<std::string> extra;
if (!nscapi::program_options::process_arguments_from_request(vm, desc, request, *response, true, extra))
return;
std::string warn, crit;
request.clear_arguments();
compat::matchFirstNumeric(vm, "used", "free", warn, crit);
compat::matchFirstNumeric(vm, "used", "used", warn, crit, "Used");
compat::matchFirstNumeric(vm, "free", "free", warn, crit, "Free");
compat::inline_addarg(request, warn);
compat::inline_addarg(request, crit);
if (vm.count("CheckAll"))
request.add_arguments("drive=*");
bool exclude = false;
if (vm.count("CheckAllOthers")) {
request.add_arguments("drive=*");
exclude = true;
}
if (!perf_unit.empty())
request.add_arguments("perf-config=free(unit:" + perf_unit + ")used(unit:" + perf_unit + ")");
request.add_arguments("detail-syntax=%(drive): Total: %(size) - Used: %(used) (%(used_pct)%) - Free: %(free) (%(free_pct)%)");
compat::matchShowAll(vm, request);
std::string keyword = exclude ? "exclude=" : "drive=";
BOOST_FOREACH(const std::string &t, times) {
request.add_arguments(keyword + t);
}
示例2: CheckTaskSched_
void CheckTaskSched::CheckTaskSched_(Plugin::QueryRequestMessage::Request &request, Plugin::QueryResponseMessage::Response *response) {
boost::program_options::options_description desc;
std::vector<std::string> counters;
std::string syntax, topSyntax, filter, arg_warn, arg_crit;
bool debug = false;
nscapi::program_options::add_help(desc);
desc.add_options()
("warn", po::value<std::string>(&arg_warn), "Warning bounds.")
("crit", po::value<std::string>(&arg_crit), "Critical bounds.")
("MaxWarn", po::value<std::string>(), "Maximum value before a warning is returned.")
("MaxCrit", po::value<std::string>(), "Maximum value before a critical is returned.")
("MinWarn", po::value<std::string>(), "Minimum value before a warning is returned.")
("MinCrit", po::value<std::string>(), "Minimum value before a critical is returned.")
("Counter", po::value<std::vector<std::string>>(&counters), "The time to check")
("truncate", po::value<std::string>(), "Deprecated option")
("syntax", po::value<std::string>(&syntax), "Syntax (same as detail-syntax in the check_tasksched check)")
("master-syntax", po::value<std::string>(&topSyntax), "Master Syntax (same as top-syntax in the check_tasksched check)")
("filter", po::value<std::string>(&filter), "Filter (same as filter in the check_tasksched check)")
("debug", po::bool_switch(&debug), "Filter (same as filter in the check_tasksched check)")
;
boost::program_options::variables_map vm;
std::vector<std::string> extra;
if (!nscapi::program_options::process_arguments_from_request(vm, desc, request, *response, true, extra))
return;
std::string warn, crit;
request.clear_arguments();
if (vm.count("MaxWarn"))
warn = "warn=count > " + vm["MaxWarn"].as<std::string>();
if (vm.count("MaxCrit"))
crit = "crit=count > " + vm["MaxCrit"].as<std::string>();
if (vm.count("MinWarn"))
warn = "warn=count < " + vm["MinWarn"].as<std::string>();
if (vm.count("MinCrit"))
crit = "crit=count > " + vm["MinCrit"].as<std::string>();
if (!arg_warn.empty())
warn = "warn=count " + arg_warn;
if (!arg_crit.empty())
crit = "crit=count " + arg_crit;
if (!warn.empty())
request.add_arguments(warn);
if (!crit.empty())
request.add_arguments(crit);
if (debug)
request.add_arguments("debug");
if (!filter.empty())
request.add_arguments("filter=" + filter);
if (!topSyntax.empty()) {
boost::replace_all(topSyntax, "%status%", "${task_status}");
request.add_arguments("top-syntax=" + topSyntax);
}
if (!syntax.empty()) {
boost::replace_all(syntax, "%title%", "${title}");
boost::replace_all(syntax, "%status%", "${task_status}");
boost::replace_all(syntax, "%exit_code%", "${exit_code}");
boost::replace_all(syntax, "%most_recent_run_time%", "${most_recent_run_time}");
request.add_arguments("detail-syntax=" + syntax);
}
log_args(request);
check_tasksched(request, response);
}