]> granicus.if.org Git - icinga2/commitdiff
Conform to the Plugin API spec for performance label quoting 6411/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 22 Jun 2018 09:12:57 +0000 (11:12 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 22 Jun 2018 09:12:57 +0000 (11:12 +0200)
Single quotes are allowed, double quotes are not.

plugins/check_disk.cpp
plugins/check_load.cpp
plugins/check_memory.cpp
plugins/check_network.cpp
plugins/check_perfmon.cpp
plugins/check_service.cpp
plugins/check_swap.cpp
plugins/check_update.cpp
plugins/check_uptime.cpp
plugins/check_users.cpp

index b0e898f5408a3ebeb24b66fdb53d3ff47e9ea2d5..c6bd9cdd3aca282853521a57ec44df1d0b712539 100644 (file)
@@ -382,7 +382,7 @@ static int printOutput(printInfoStruct& printInfo, std::vector<drive>& vDrives)
                        wsDrives.push_back(it->name + L" " + removeZero(it->free) + L" " + unit + L" (" +
                                removeZero(std::round(it->free / it->cap * 100.0)) + L"%); ");
 
-                       wsPerf.push_back(L" " + it->name + L"=" + removeZero(it->free) + unit + L";" +
+                       wsPerf.push_back(L" '" + it->name + L"'=" + removeZero(it->free) + unit + L";" +
                                printInfo.warn.pString(it->cap) + L";" + printInfo.crit.pString(it->cap) + L";0;"
                                + removeZero(it->cap));
 
index 81f2ecfdf59fa0b3c41a8518f653bd74614d0268..44a99a4560129be172ac318972a3ef0bf99cb34d 100644 (file)
@@ -171,7 +171,7 @@ static int printOutput(printInfoStruct& printInfo)
                break;
        }
 
-       std::wcout << " " << printInfo.load << L"% | load=" << printInfo.load << L"%;"
+       std::wcout << " " << printInfo.load << L"% | 'load'=" << printInfo.load << L"%;"
                << printInfo.warn.pString() << L";"
                << printInfo.crit.pString() << L";0;100" << '\n';
 
index 46c65649ec808d15fdbabe0e75a0ecc74573e18f..8c274c1fe0a35c417cd3a17374019b383c0c8b64 100644 (file)
@@ -187,7 +187,7 @@ static int printOutput(printInfoStruct& printInfo)
        else
                std::wcout << " - " << 100 - printInfo.percentFree << L"% used";
 
-       std::wcout << "| memory=" << currentValue << BunitStr(printInfo.unit) << L";"
+       std::wcout << "| 'memory'=" << currentValue << BunitStr(printInfo.unit) << L";"
                << printInfo.warn.pString(printInfo.tRam) << L";" << printInfo.crit.pString(printInfo.tRam)
                << L";0;" << printInfo.tRam;
 
index e17d7b50371905f20d44ea72a3a96e3d9f408d1f..e0c464139f666f6b66c01907ca59ac50c4b76d92 100644 (file)
@@ -190,7 +190,7 @@ static int printOutput(printInfoStruct& printInfo, const std::vector<nInterface>
                        continue;
                } else {
                        boost::algorithm::replace_all(wsFriendlyName, "'", "''");
-                       tss << L"\'" << wsFriendlyName << L"_in\'=" << it->BytesInSec << L"B \'" << wsFriendlyName << L"_out\'=" << it->BytesOutSec << L"B ";
+                       tss << L"'" << wsFriendlyName << L"_in'=" << it->BytesInSec << L"B '" << wsFriendlyName << L"_out'=" << it->BytesOutSec << L"B ";
                }
        }
 
@@ -214,7 +214,7 @@ static int printOutput(printInfoStruct& printInfo, const std::vector<nInterface>
        }
 
        std::wcout << " " << tIn + tOut << L"B/s | "
-               << L"network=" << tIn + tOut << L"B;" << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";" << L"0; "
+               << L"'network'=" << tIn + tOut << L"B;" << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";" << L"0; "
                << tss.str() << '\n';
 
        return state;
index 7e415f1cdb0e6972f46afbe3c4e495fd9a7bdc3d..ad3c8bcc5bdaa56ca13d99a8188ba727997585ed 100644 (file)
@@ -352,26 +352,27 @@ static int printOutput(const po::variables_map& vm, printInfoStruct& pi)
        std::wstringstream wssPerfData;
 
        if (vm.count("perf-syntax"))
-               wssPerfData << "\"" << vm["perf-syntax"].as<std::wstring>() << "\"=";
+               wssPerfData << "'" << vm["perf-syntax"].as<std::wstring>() << "'=";
        else
-               wssPerfData << "\"" << pi.wsFullPath << "\"=";
+               wssPerfData << "'" << pi.wsFullPath << "'=";
 
        wssPerfData << pi.dValue << ';' << pi.tWarn.pString() << ';' << pi.tCrit.pString() << ";;";
 
        if (pi.tCrit.rend(pi.dValue)) {
-               std::wcout << "PERFMON CRITICAL \"" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
-                       << "\" = " << pi.dValue << " | " << wssPerfData.str() << '\n';
+               std::wcout << "PERFMON CRITICAL for '" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
+                       << "' = " << pi.dValue << " | " << wssPerfData.str() << "\n";
                return 2;
        }
 
        if (pi.tWarn.rend(pi.dValue)) {
-               std::wcout << "PERFMON WARNING \"" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
-                       << "\" = " << pi.dValue << " | " << wssPerfData.str() << '\n';
+               std::wcout << "PERFMON WARNING for '" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
+                       << "' = " << pi.dValue << " | " << wssPerfData.str() << "\n";
                return 1;
        }
 
-       std::wcout << "PERFMON OK \"" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
-               << "\" = " << pi.dValue << " | " << wssPerfData.str() << '\n';
+       std::wcout << "PERFMON OK for '" << (vm.count("perf-syntax") ? vm["perf-syntax"].as<std::wstring>() : pi.wsFullPath)
+               << "' = " << pi.dValue << " | " << wssPerfData.str() << "\n";
+
        return 0;
 }
 
index e6e12d74e930ab3cdb5379602f12f1ca7a3a4580..93e0a58a2e2ebe48bb1999780542dc3df88f86b7 100644 (file)
@@ -124,7 +124,7 @@ static int printOutput(const printInfoStruct& printInfo)
        state state = OK;
 
        if (!printInfo.ServiceState) {
-               std::wcout << L"SERVICE CRITICAL NOTFOUND | service=" << printInfo.ServiceState << ";;;1;7" << '\n';
+               std::wcout << L"SERVICE CRITICAL NOT FOUND | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n';
                return 3;
        }
 
@@ -133,13 +133,13 @@ static int printOutput(const printInfoStruct& printInfo)
 
        switch (state) {
        case OK:
-               std::wcout << L"SERVICE \"" << printInfo.service << "\" OK RUNNING | service=4;;;1;7" << '\n';
+               std::wcout << L"SERVICE \"" << printInfo.service << "\" OK RUNNING | 'service'=4;;;1;7" << '\n';
                break;
        case WARNING:
-               std::wcout << L"SERVICE \"" << printInfo.service << "\" WARNING NOT RUNNING | service=" << printInfo.ServiceState << ";;;1;7" << '\n';
+               std::wcout << L"SERVICE \"" << printInfo.service << "\" WARNING NOT RUNNING | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n';
                break;
        case CRITICAL:
-               std::wcout << L"SERVICE \"" << printInfo.service << "\" CRITICAL NOT RUNNING | service=" << printInfo.ServiceState << ";;;1;7" << '\n';
+               std::wcout << L"SERVICE \"" << printInfo.service << "\" CRITICAL NOT RUNNING | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n';
                break;
        }
 
index d405a094f8c525a9cea6d6c8609b4b0c1f64d412..b06a38c7b251aaed657484537fca56f3f0e39bb3 100644 (file)
@@ -166,17 +166,17 @@ static int printOutput(printInfoStruct& printInfo)
 
        switch (state) {
        case OK:
-               std::wcout << L"SWAP OK - " << printInfo.percentFree << L"% free | swap=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
+               std::wcout << L"SWAP OK - " << printInfo.percentFree << L"% free | 'swap'=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
                        << printInfo.warn.pString(printInfo.tSwap) << L";" << printInfo.crit.pString(printInfo.tSwap)
                        << L";0;" << printInfo.tSwap << '\n';
                break;
        case WARNING:
-               std::wcout << L"SWAP WARNING - " << printInfo.percentFree << L"% free | swap=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
+               std::wcout << L"SWAP WARNING - " << printInfo.percentFree << L"% free | 'swap'=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
                        << printInfo.warn.pString(printInfo.tSwap) << L";" << printInfo.crit.pString(printInfo.tSwap)
                        << L";0;" << printInfo.tSwap << '\n';
                break;
        case CRITICAL:
-               std::wcout << L"SWAP CRITICAL - " << printInfo.percentFree << L"% free | swap=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
+               std::wcout << L"SWAP CRITICAL - " << printInfo.percentFree << L"% free | 'swap'=" << printInfo.aSwap << BunitStr(printInfo.unit) << L";"
                        << printInfo.warn.pString(printInfo.tSwap) << L";" << printInfo.crit.pString(printInfo.tSwap)
                        << L";0;" << printInfo.tSwap << '\n';
                break;
index 31d98e44b681e023e17535fd1832d54f3ff30572..3543400c00e910c3e1f4a632eb9c0b61d7aefcd4 100644 (file)
@@ -149,7 +149,7 @@ static int printOutput(const printInfoStruct& printInfo)
                break;
        }
 
-       std::wcout << output << printInfo.numUpdates << L" | update=" << printInfo.numUpdates << L";"
+       std::wcout << output << printInfo.numUpdates << L" | 'update'=" << printInfo.numUpdates << L";"
                << printInfo.warn << L";" << printInfo.crit << L";0;" << '\n';
 
        return state;
index 038625ade2368235a0c5bb2d78915c65a0809b53..27a656ef2068d5016092b4c46b38adee02a0e48d 100644 (file)
@@ -166,17 +166,17 @@ static int printOutput(printInfoStruct& printInfo)
 
        switch (state) {
        case OK:
-               std::wcout << L"UPTIME OK " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
+               std::wcout << L"UPTIME OK " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.time
                        << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
                        << printInfo.crit.pString() << L";0;" << '\n';
                break;
        case WARNING:
-               std::wcout << L"UPTIME WARNING " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
+               std::wcout << L"UPTIME WARNING " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.time
                        << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
                        << printInfo.crit.pString() << L";0;" << '\n';
                break;
        case CRITICAL:
-               std::wcout << L"UPTIME CRITICAL " << printInfo.time << TunitStr(printInfo.unit) << L" | uptime=" << printInfo.time
+               std::wcout << L"UPTIME CRITICAL " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.time
                        << TunitStr(printInfo.unit) << L";" << printInfo.warn.pString() << L";"
                        << printInfo.crit.pString() << L";0;" << '\n';
                break;
index 993a4002756f911d3bba7a842386a557c477673c..83ab5d05de5df930dddc8c1869f93cca2c54d7c8 100644 (file)
@@ -151,15 +151,15 @@ static int printOutput(printInfoStruct& printInfo)
 
        switch (state) {
        case OK:
-               std::wcout << L"USERS OK " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
+               std::wcout << L"USERS OK " << printInfo.users << L" User(s) logged in | 'users'=" << printInfo.users << L";"
                        << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << '\n';
                break;
        case WARNING:
-               std::wcout << L"USERS WARNING " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
+               std::wcout << L"USERS WARNING " << printInfo.users << L" User(s) logged in | 'users'=" << printInfo.users << L";"
                        << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << '\n';
                break;
        case CRITICAL:
-               std::wcout << L"USERS CRITICAL " << printInfo.users << L" User(s) logged in | users=" << printInfo.users << L";"
+               std::wcout << L"USERS CRITICAL " << printInfo.users << L" User(s) logged in | 'users'=" << printInfo.users << L";"
                        << printInfo.warn.pString() << L";" << printInfo.crit.pString() << L";0;" << '\n';
                break;
        }