3
** Copyright (C) 2000-2005 SIA Zabbix
5
** This program is free software; you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation; either version 2 of the License, or
8
** (at your option) any later version.
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
15
** You should have received a copy of the GNU General Public License
16
** along with this program; if not, write to the Free Software
17
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
int VFS_FS_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
32
ULARGE_INTEGER freeBytes,totalBytes;
34
if(num_param(param) > 2)
36
return SYSINFO_RET_FAIL;
39
if(get_param(param, 1, path, MAX_PATH) != 0)
41
return SYSINFO_RET_FAIL;
44
if(get_param(param, 2, mode, sizeof(mode)) != 0)
50
/* default parameter */
51
zbx_snprintf(mode, sizeof(mode), "total");
54
if (!GetDiskFreeSpaceEx(path, &freeBytes, &totalBytes, NULL))
56
return SYSINFO_RET_FAIL;
59
if (strcmp(mode,"free") == 0)
61
SET_UI64_RESULT(result, freeBytes.QuadPart);
63
else if (strcmp(mode,"used") == 0)
65
SET_UI64_RESULT(result, totalBytes.QuadPart - freeBytes.QuadPart);
67
else if (strcmp(mode,"total") == 0)
69
SET_UI64_RESULT(result, totalBytes.QuadPart);
71
else if (strcmp(mode,"pfree") == 0)
73
SET_UI64_RESULT(result, (double)(__int64)freeBytes.QuadPart * 100. / (double)(__int64)totalBytes.QuadPart);
75
else if (strcmp(mode,"pused") == 0)
77
SET_UI64_RESULT(result, (double)((__int64)totalBytes.QuadPart-(__int64)freeBytes.QuadPart) * 100. / (double)(__int64)totalBytes.QuadPart);
81
return SYSINFO_RET_FAIL;
84
return SYSINFO_RET_OK;