| 102 | } |
| 103 | |
| 104 | static int printOutput(const printInfoStruct& printInfo) |
| 105 | { |
| 106 | if (l_Debug) |
| 107 | std::wcout << L"Constructing output string" << '\n'; |
| 108 | |
| 109 | std::wstring perf; |
| 110 | state state = OK; |
| 111 | |
| 112 | if (!printInfo.ServiceState) { |
| 113 | std::wcout << L"SERVICE CRITICAL NOT FOUND | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n'; |
| 114 | return 3; |
| 115 | } |
| 116 | |
| 117 | if (printInfo.ServiceState != 0x04) |
| 118 | printInfo.warn ? state = WARNING : state = CRITICAL; |
| 119 | |
| 120 | switch (state) { |
| 121 | case OK: |
| 122 | std::wcout << L"SERVICE \"" << printInfo.service << "\" OK RUNNING | 'service'=4;;;1;7" << '\n'; |
| 123 | break; |
| 124 | case WARNING: |
| 125 | std::wcout << L"SERVICE \"" << printInfo.service << "\" WARNING NOT RUNNING | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n'; |
| 126 | break; |
| 127 | case CRITICAL: |
| 128 | std::wcout << L"SERVICE \"" << printInfo.service << "\" CRITICAL NOT RUNNING | 'service'=" << printInfo.ServiceState << ";;;1;7" << '\n'; |
| 129 | break; |
| 130 | } |
| 131 | |
| 132 | return state; |
| 133 | } |
| 134 | |
| 135 | static std::wstring getServiceByDescription(const std::wstring& description) |
| 136 | { |