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

Function getDriveSpaceValues

plugins/check_disk.cpp:165–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165static bool getDriveSpaceValues(drive& drive, const Bunit& unit)
166{
167 if (l_Debug)
168 std::wcout << "Getting free and used disk space for drive " << drive.name << '\n';
169
170 ULARGE_INTEGER tempFree, tempTotal;
171 if (!GetDiskFreeSpaceEx(drive.name.c_str(), NULL, &tempTotal, &tempFree))
172 return false;
173
174 ULARGE_INTEGER tempUsed;
175 tempUsed.QuadPart = tempTotal.QuadPart - tempFree.QuadPart;
176
177 if (l_Debug)
178 std::wcout << "\tcap: " << tempFree.QuadPart << '\n';
179
180 drive.cap = round((tempTotal.QuadPart / pow(1024.0, unit)));
181
182 if (l_Debug)
183 std::wcout << "\tAfter conversion: " << drive.cap << '\n'
184 << "\tfree: " << tempFree.QuadPart << '\n';
185
186 drive.free = round((tempFree.QuadPart / pow(1024.0, unit)));
187
188 if (l_Debug)
189 std::wcout << "\tAfter conversion: " << drive.free << '\n'
190 << "\tused: " << tempUsed.QuadPart << '\n';
191
192 drive.used = round((tempUsed.QuadPart / pow(1024.0, unit)));
193
194 if (l_Debug)
195 std::wcout << "\tAfter conversion: " << drive.used << '\n' << '\n';
196
197 return true;
198}
199
200static int parseArguments(int ac, WCHAR **av, po::variables_map& vm, printInfoStruct& printInfo)
201{

Callers 1

wmainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected