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

Function countProcs

plugins/check_procs.cpp:167–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167static int countProcs()
168{
169 if (l_Debug)
170 std::wcout << L"Counting all processes" << '\n';
171
172 if (l_Debug)
173 std::wcout << L"Creating snapshot" << '\n';
174
175 HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
176 if (hProcessSnap == INVALID_HANDLE_VALUE)
177 return -1;
178
179 PROCESSENTRY32 pe32;
180 pe32.dwSize = sizeof(PROCESSENTRY32);
181
182 if (l_Debug)
183 std::wcout << L"Grabbing first proccess" << '\n';
184
185 if (!Process32First(hProcessSnap, &pe32)) {
186 CloseHandle(hProcessSnap);
187 return -1;
188 }
189
190 if (l_Debug)
191 std::wcout << L"Counting processes..." << '\n';
192
193 int numProcs = 0;
194
195 do {
196 ++numProcs;
197 } while (Process32Next(hProcessSnap, &pe32));
198
199 if (l_Debug)
200 std::wcout << L"Found " << numProcs << L" processes. Cleaning up udn returning" << '\n';
201
202 CloseHandle(hProcessSnap);
203
204 return numProcs;
205}
206
207static int countProcs(const std::wstring& user)
208{

Callers 1

wmainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected