Add --perf-syntax option to check_perfmon

fixes #4896
This commit is contained in:
Jean Flach 2017-01-12 15:55:26 +01:00
parent e4f48a85dd
commit c3b0051360
3 changed files with 15 additions and 4 deletions

View File

@ -1509,6 +1509,7 @@ perfmon\_win\_crit | **Optional**. The critical threshold.
perfmon\_win\_counter | **Required**. The Performance Counter to use. Ex. `\Processor(_Total)\% Idle Time`.
perfmon\_win\_wait | **Optional**. Time in milliseconds to wait between data collection (default: 1000).
perfmon\_win\_type | **Optional**. Format in which to expect perfomance values. Possible are: long, int64 and double (default).
perfmon\_win\_syntax | **Optional**. Use this in the performance output instead of `perfmon\_win\_counter`. Exists for graphice compatibility reasons.
### <a id="windows-plugins-ping-windows"></a> ping-windows
@ -4792,5 +4793,3 @@ rbl_server | **Required** List of RBL servers as an array.
rbl_warning | **Optional** Number of blacklisting servers for a warning.
rbl_critical | **Optional** Number of blacklisting servers for a critical.
tbl_timeout | **Optional** Seconds before plugin times out (default: 15).

View File

@ -129,6 +129,11 @@ object CheckCommand "perfmon-windows" {
value = "$perfmon_win_type$"
description = "Performance counter type"
}
"--perf-syntax" = {
value = "$perfmon_win_syntax$"
description = "Use this instead of the counter name in the perfomance data"
}
}
vars.performance_win_wait = 1000

View File

@ -67,6 +67,7 @@ BOOL ParseArguments(CONST INT ac, WCHAR **av, po::variables_map& vm, printInfoSt
("fmt-countertype", po::wvalue<std::wstring>(), "Value type of counter: 'double'(default), 'long', 'int64'")
("print-objects", "Prints all available objects to console")
("print-object-info", "Prints all available instances and counters of --performance-counter, do not use a full perfomance counter string here")
("perf-syntax", po::wvalue<std::wstring>(), "Use this string as name for the performance counter (graphite compatibility)")
;
po::basic_command_line_parser<wchar_t> parser(ac, av);
@ -361,8 +362,14 @@ die:
INT PrintOutput(CONST po::variables_map& vm, printInfoStruct& pi)
{
std::wstringstream wssPerfData;
wssPerfData << "\"" << pi.wsFullPath << "\"=" << pi.dValue << ';'
<< pi.tWarn.pString() << ';' << pi.tCrit.pString() << ";;";
if (vm.count("perf-syntax")) {
wssPerfData << "\"" << vm["perf-syntax"].as<std::wstring>() << "\"=";
} else {
wssPerfData << "\"" << pi.wsFullPath << "\"=";
}
wssPerfData << pi.dValue << ';' << pi.tWarn.pString() << ';' << pi.tCrit.pString() << ";;";
if (pi.tCrit.rend(pi.dValue)) {
std::wcout << "PERFMON CRITICAL \"" << pi.wsFullPath << "\" = "