From 8c35c821c6ddb99e501102c0689d8896fa747e86 Mon Sep 17 00:00:00 2001 From: Matthias Schales Date: Tue, 27 Sep 2016 20:29:23 +0200 Subject: [PATCH] Update perfdata; Add skipping of isatap interfaces with parameter Also updates interface names to fix perfdata output refs #12155 --- plugins/check_network.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/check_network.cpp b/plugins/check_network.cpp index 65d11d890..26eb34ff6 100644 --- a/plugins/check_network.cpp +++ b/plugins/check_network.cpp @@ -32,11 +32,12 @@ #include "check_network.h" #include "boost/algorithm/string/replace.hpp" -#define VERSION 1.1 +#define VERSION 1.2 namespace po = boost::program_options; static BOOL debug = FALSE; +static BOOL noisatap = FALSE; INT wmain(INT argc, WCHAR **argv) { @@ -72,6 +73,7 @@ INT parseArguments(INT ac, WCHAR **av, po::variables_map& vm, printInfoStruct& p ("help,h", "print usage and exit") ("version,V", "print version and exit") ("debug,d", "Verbose/Debug output") + ("noisatap,n", "Don't show isatap interfaces in output") ("warning,w", po::wvalue(), "warning value") ("critical,c", po::wvalue(), "critical value") ; @@ -159,6 +161,9 @@ INT parseArguments(INT ac, WCHAR **av, po::variables_map& vm, printInfoStruct& p if (vm.count("debug")) debug = TRUE; + if (vm.count("noisatap")) + noisatap = TRUE; + return -1; } @@ -189,8 +194,16 @@ INT printOutput(printInfoStruct& printInfo, CONST std::vector& vInte std::wcout << "\tNo friendly name found, using adapter name\n"; wsFriendlyName = it->name; } - boost::algorithm::replace_all(wsFriendlyName, "'", "''"); - tss << L"netI='" << wsFriendlyName << L"';in=" << it->BytesInSec << "B;out=" << it->BytesOutSec << L"B "; + if(wsFriendlyName.find(L"isatap") != std::wstring::npos && noisatap) { + if (debug) + std::wcout << "\tSkipping isatap interface " << wsFriendlyName << "\n"; + continue; + } + else + { + boost::algorithm::replace_all(wsFriendlyName, "'", "''"); + tss << L"\'" << wsFriendlyName << L"_in\'=" << it->BytesInSec << L"B \'" << wsFriendlyName << L"_out\'=" << it->BytesOutSec << L"B "; + } } if (printInfo.warn.rend(tIn + tOut))