| 110 | } |
| 111 | |
| 112 | static int printOutput(const printInfoStruct& printInfo) |
| 113 | { |
| 114 | if (l_Debug) |
| 115 | std::wcout << L"Constructing output string" << '\n'; |
| 116 | |
| 117 | state state = OK; |
| 118 | std::wstring output = L"UPDATE "; |
| 119 | |
| 120 | if (printInfo.numUpdates >= printInfo.warn && printInfo.warn) |
| 121 | state = WARNING; |
| 122 | |
| 123 | if ((printInfo.reboot && !printInfo.ignoreReboot) || (printInfo.numUpdates >= printInfo.crit && printInfo.crit)) |
| 124 | state = CRITICAL; |
| 125 | |
| 126 | switch (state) { |
| 127 | case OK: |
| 128 | output.append(L"OK "); |
| 129 | break; |
| 130 | case WARNING: |
| 131 | output.append(L"WARNING "); |
| 132 | break; |
| 133 | case CRITICAL: |
| 134 | output.append(L"CRITICAL "); |
| 135 | break; |
| 136 | } |
| 137 | output.append(std::to_wstring(printInfo.numUpdates)); |
| 138 | if (printInfo.reboot) { |
| 139 | output.append(L"; "); |
| 140 | output.append(std::to_wstring(printInfo.reboot)); |
| 141 | output.append(L" NEED REBOOT "); |
| 142 | } |
| 143 | std::wcout << output << L" | 'update'=" << printInfo.numUpdates << L";" |
| 144 | << printInfo.warn << L";" << printInfo.crit << L";0;" << '\n'; |
| 145 | |
| 146 | return state; |
| 147 | } |
| 148 | |
| 149 | static int check_update(printInfoStruct& printInfo) |
| 150 | { |