MCPcopy Create free account
hub / github.com/Icinga/icinga2 / getUptime

Function getUptime

plugins/check_uptime.cpp:173–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173static void getUptime(printInfoStruct& printInfo)
174{
175 if (l_Debug)
176 std::wcout << L"Getting uptime in milliseconds" << '\n';
177
178 boost::chrono::milliseconds uptime = boost::chrono::milliseconds(GetTickCount64());
179
180 if (l_Debug)
181 std::wcout << L"Converting requested unit (default: seconds)" << '\n';
182
183 switch (printInfo.unit) {
184 case TunitH:
185 printInfo.time = boost::chrono::duration_cast<boost::chrono::hours>(uptime).count();
186 break;
187 case TunitM:
188 printInfo.time = boost::chrono::duration_cast<boost::chrono::minutes>(uptime).count();
189 break;
190 case TunitS:
191 printInfo.time = boost::chrono::duration_cast<boost::chrono::seconds>(uptime).count();
192 break;
193 case TunitMS:
194 printInfo.time = uptime.count();
195 break;
196 }
197
198 // For the Performance Data we need the time in seconds
199 printInfo.timeInSeconds = boost::chrono::duration_cast<boost::chrono::seconds>(uptime).count();
200}
201
202int wmain(int argc, WCHAR **argv)
203{

Callers 1

wmainFunction · 0.85

Calls 1

countMethod · 0.80

Tested by

no test coverage detected