| 138 | } |
| 139 | |
| 140 | static int printOutput(printInfoStruct& printInfo) |
| 141 | { |
| 142 | if (l_Debug) |
| 143 | std::wcout << L"Constructing output string" << '\n'; |
| 144 | |
| 145 | state state = OK; |
| 146 | |
| 147 | if (printInfo.warn.rend((double) printInfo.time)) |
| 148 | state = WARNING; |
| 149 | if (printInfo.crit.rend((double) printInfo.time)) |
| 150 | state = CRITICAL; |
| 151 | |
| 152 | switch (state) { |
| 153 | case OK: |
| 154 | std::wcout << L"UPTIME OK " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.timeInSeconds |
| 155 | << "s" << L";" << printInfo.warn.toSeconds(printInfo.unit).pString() << L";" |
| 156 | << printInfo.crit.toSeconds(printInfo.unit).pString() << L";0;" << '\n'; |
| 157 | break; |
| 158 | case WARNING: |
| 159 | std::wcout << L"UPTIME WARNING " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.timeInSeconds |
| 160 | << "s" << L";" << printInfo.warn.toSeconds(printInfo.unit).pString() << L";" |
| 161 | << printInfo.crit.toSeconds(printInfo.unit).pString() << L";0;" << '\n'; |
| 162 | break; |
| 163 | case CRITICAL: |
| 164 | std::wcout << L"UPTIME CRITICAL " << printInfo.time << TunitStr(printInfo.unit) << L" | 'uptime'=" << printInfo.timeInSeconds |
| 165 | << "s" << L";" << printInfo.warn.toSeconds(printInfo.unit).pString() << L";" |
| 166 | << printInfo.crit.toSeconds(printInfo.unit).pString() << L";0;" << '\n'; |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | return state; |
| 171 | } |
| 172 | |
| 173 | static void getUptime(printInfoStruct& printInfo) |
| 174 | { |