summaryrefslogtreecommitdiffstats
path: root/src/libs/zbxsysinfo/win32
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/zbxsysinfo/win32')
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/cpu.c4
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/diskio.c14
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/diskspace.c53
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/inodes.c2
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/kernel.c4
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/memory.c83
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/net.c10
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/proc.c2
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/sensors.c2
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/swap.c8
-rwxr-xr-xsrc/libs/zbxsysinfo/win32/win32.c36
11 files changed, 187 insertions, 31 deletions
diff --git a/src/libs/zbxsysinfo/win32/cpu.c b/src/libs/zbxsysinfo/win32/cpu.c
index 6d720071..d9aebfc9 100755
--- a/src/libs/zbxsysinfo/win32/cpu.c
+++ b/src/libs/zbxsysinfo/win32/cpu.c
@@ -190,7 +190,7 @@ int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RE
int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function SYSTEM_CPU_SWITCHES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -200,7 +200,7 @@ int SYSTEM_CPU_SWITCHES(const char *cmd, const char *param, unsigned flags,
int SYSTEM_CPU_INTR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function SYSTEM_CPU_INTR!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/diskio.c b/src/libs/zbxsysinfo/win32/diskio.c
index e15e7028..9253cecc 100755
--- a/src/libs/zbxsysinfo/win32/diskio.c
+++ b/src/libs/zbxsysinfo/win32/diskio.c
@@ -26,7 +26,7 @@
int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function VFS_DEV_WRITE!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -35,7 +35,7 @@ int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESU
int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function VFS_DEV_READ!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -44,7 +44,7 @@ int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function DISK_IO!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -53,7 +53,7 @@ static int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RES
static int DISK_RIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function DISK_RIO!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -62,7 +62,7 @@ static int DISK_RIO(const char *cmd, const char *param, unsigned flags, AGENT_RE
static int DISK_WIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function DISK_WIO!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -71,7 +71,7 @@ static int DISK_WIO(const char *cmd, const char *param, unsigned flags, AGENT_RE
static int DISK_RBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function DISK_RBLK!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -80,7 +80,7 @@ static int DISK_RBLK(const char *cmd, const char *param, unsigned flags, AGENT_R
static int DISK_WBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function DISK_WBLK!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/diskspace.c b/src/libs/zbxsysinfo/win32/diskspace.c
index a9946c18..ad839383 100755
--- a/src/libs/zbxsysinfo/win32/diskspace.c
+++ b/src/libs/zbxsysinfo/win32/diskspace.c
@@ -25,10 +25,55 @@
int VFS_FS_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef TODO
-#error Realize function!!!
-#endif /* todo */
+
+ char
+ path[MAX_PATH],
+ mode[20];
- return SYSINFO_RET_FAIL;
+ ULARGE_INTEGER freeBytes,totalBytes;
+
+ if(num_param(param) > 2)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, path, MAX_PATH) != 0)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 2, mode, 20) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "total");
+ }
+
+ if (!GetDiskFreeSpaceEx(path, &freeBytes, &totalBytes, NULL))
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if (strcmp(mode,"free") == 0)
+ {
+ SET_UI64_RESULT(result, freeBytes.QuadPart);
+ }
+ else if (strcmp(mode,"used") == 0)
+ {
+ SET_UI64_RESULT(result, totalBytes.QuadPart - freeBytes.QuadPart);
+ }
+ else if (strcmp(mode,"total") == 0)
+ {
+ SET_UI64_RESULT(result, totalBytes.QuadPart);
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ return SYSINFO_RET_OK;
}
diff --git a/src/libs/zbxsysinfo/win32/inodes.c b/src/libs/zbxsysinfo/win32/inodes.c
index 074b28b3..47e31b40 100755
--- a/src/libs/zbxsysinfo/win32/inodes.c
+++ b/src/libs/zbxsysinfo/win32/inodes.c
@@ -27,7 +27,7 @@ int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function VFS_FS_INODE!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/kernel.c b/src/libs/zbxsysinfo/win32/kernel.c
index f4c1974b..23c7a7e4 100755
--- a/src/libs/zbxsysinfo/win32/kernel.c
+++ b/src/libs/zbxsysinfo/win32/kernel.c
@@ -25,7 +25,7 @@
int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -34,7 +34,7 @@ int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RE
int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/memory.c b/src/libs/zbxsysinfo/win32/memory.c
index 4a778c65..1d106156 100755
--- a/src/libs/zbxsysinfo/win32/memory.c
+++ b/src/libs/zbxsysinfo/win32/memory.c
@@ -22,13 +22,88 @@
#include "common.h"
#include "sysinfo.h"
-
int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
-#ifdef TODO
-#error Realize function!!!
-#endif /* todo */
+
+#if defined(HAVE_GETPERFORMANCEINFO)
+ PERFORMANCE_INFORMATION pfi;
+#endif /* HAVE_GETPERFORMANCEINFO */
+
+#if defined(HAVE_GLOBALMEMORYSTATUSEX)
+ MEMORYSTATUSEX ms;
+#else /* HAVE_GLOBALMEMORYSTATUSEX */
+ MEMORYSTATUS ms;
+#endif
+ char mode[10];
+
+ if(num_param(param) > 1)
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+ if(get_param(param, 1, mode, sizeof(mode)) != 0)
+ {
+ mode[0] = '\0';
+ }
+ if(mode[0] == '\0')
+ {
+ /* default parameter */
+ sprintf(mode, "total");
+ }
+
+#if defined(HAVE_GETPERFORMANCEINFO)
+
+ if (strcmp(mode,"cached") == 0)
+ {
+
+ GetPerformanceInfo(&pfi,sizeof(PERFORMANCE_INFORMATION));
+
+ SET_UI64_RESULT(result, (zbx_uint64_t)pfi.SystemCache * (zbx_uint64_t)pfi.PageSize);
+
+ return SYSINFO_RET_OK;
+ }
+
+#endif /* HAVE_GETPERFORMANCEINFO */
+
+#if defined(HAVE_GLOBALMEMORYSTATUSEX)
+
+ ms.dwLength = sizeof(MEMORYSTATUSEX);
+
+ GlobalMemoryStatusEx(&ms);
+
+ if (strcmp(mode, "total") == 0)
+ {
+ SET_UI64_RESULT(result, ms.ullTotalPhys);
+ return SYSINFO_RET_OK;
+ }
+ else if (strcmp(mode, "free") == 0)
+ {
+ SET_UI64_RESULT(result, ms.ullAvailPhys);
+ return SYSINFO_RET_OK;
+ }
+ else
+ {
+ return SYSINFO_RET_FAIL;
+ }
+
+#else /* not HAVE_GLOBALMEMORYSTATUSEX */
+
+ GlobalMemoryStatus(&ms);
+
+ if (strcmp(mode,"total") == 0)
+ {
+ SET_UI64_RESULT(result, ms.dwTotalPhys);
+ return SYSINFO_RET_OK;
+ }
+ else if (strcmp(mode,"free") == 0)
+ {
+ SET_UI64_RESULT(result, ms.dwAvailPhys);
+ return SYSINFO_RET_OK;
+ }
+
+#endif /* HAVE_GLOBALMEMORYSTATUSEX */
return SYSINFO_RET_FAIL;
+
}
diff --git a/src/libs/zbxsysinfo/win32/net.c b/src/libs/zbxsysinfo/win32/net.c
index f2c44b77..0b2d9ddd 100755
--- a/src/libs/zbxsysinfo/win32/net.c
+++ b/src/libs/zbxsysinfo/win32/net.c
@@ -26,7 +26,7 @@
int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -35,7 +35,7 @@ int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *
int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function NET_IF_OUT!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -44,7 +44,7 @@ int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT
int NET_IF_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function NET_IF_TOTAL!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -53,7 +53,7 @@ int NET_IF_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function NET_TCP_LISTEN!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -62,7 +62,7 @@ int NET_TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT
int NET_IF_COLLISIONS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function NET_IF_COLLISIONS!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/proc.c b/src/libs/zbxsysinfo/win32/proc.c
index db66a889..ff36794c 100755
--- a/src/libs/zbxsysinfo/win32/proc.c
+++ b/src/libs/zbxsysinfo/win32/proc.c
@@ -71,7 +71,7 @@ lbl_err:
int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{ /* usage: <function name>[ <process name>, <user name>, <mode>, <command> ] */
#ifdef TODO
- # error Realize function!!!
+ # error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/sensors.c b/src/libs/zbxsysinfo/win32/sensors.c
index 8c724913..453bf30f 100755
--- a/src/libs/zbxsysinfo/win32/sensors.c
+++ b/src/libs/zbxsysinfo/win32/sensors.c
@@ -28,7 +28,7 @@
int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/swap.c b/src/libs/zbxsysinfo/win32/swap.c
index b78fe622..5a1f13bc 100755
--- a/src/libs/zbxsysinfo/win32/swap.c
+++ b/src/libs/zbxsysinfo/win32/swap.c
@@ -29,7 +29,7 @@ int SYSTEM_SWAP_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_R
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function KERNEL_MAXFILES!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -38,7 +38,7 @@ int SYSTEM_SWAP_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_R
int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function OLD_SWAP!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -47,7 +47,7 @@ int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESUL
int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function SYSTEM_SWAP_IN!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
@@ -56,7 +56,7 @@ int SYSTEM_SWAP_IN(const char *cmd, const char *param, unsigned flags, AGENT_RES
int SYSTEM_SWAP_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef TODO
-#error Realize function!!!
+#error Realize function SYSTEM_SWAP_OUT!!!
#endif /* todo */
return SYSINFO_RET_FAIL;
diff --git a/src/libs/zbxsysinfo/win32/win32.c b/src/libs/zbxsysinfo/win32/win32.c
index 558754fe..779c6bc6 100755
--- a/src/libs/zbxsysinfo/win32/win32.c
+++ b/src/libs/zbxsysinfo/win32/win32.c
@@ -20,6 +20,42 @@
#include "common.h"
#include "sysinfo.h"
+#ifdef TODO
+#error Check supported functionality!!!
+/*
+SKIP { "__exec{*}", NULL, H_Execute, NULL },
+SKIP { "__usercnt{*}", H_UserCounter, NULL, NULL },
+OK { "system.run[*]", NULL, H_RunCommand, NULL },
+ { "agent.stat[avg_collector_time]", H_NumericPtr, NULL, (char *)&statAvgCollectorTime },
+ { "agent.stat[max_collector_time]", H_NumericPtr, NULL, (char *)&statMaxCollectorTime },
+ { "agent.stat[accepted_requests]", H_NumericPtr, NULL, (char *)&statAcceptedRequests },
+ { "agent.stat[rejected_requests]", H_NumericPtr, NULL, (char *)&statRejectedRequests },
+ { "agent.stat[timed_out_requests]", H_NumericPtr, NULL, (char *)&statTimedOutRequests },
+ { "agent.stat[accept_errors]", H_NumericPtr, NULL, (char *)&statAcceptErrors },
+ { "agent.stat[processed_requests]", H_NumericPtr, NULL, (char *)&statProcessedRequests },
+ { "agent.stat[failed_requests]", H_NumericPtr, NULL, (char *)&statFailedRequests },
+ { "agent.stat[unsupported_requests]", H_NumericPtr, NULL, (char *)&statUnsupportedRequests },
+ { "proc_info[*]", H_ProcInfo, NULL, NULL }, // TODO 'new realization and naming'
+OK { "perf_counter[*]", H_PerfCounter, NULL, NULL }, // TODO 'new naming'
+ { "service_state[*]", H_ServiceState, NULL, NULL }, // TODO 'new naming'
+
+OK { "net.tcp.port[*]", H_CheckTcpPort, NULL, NULL },
+OK { "system.cpu.util[*]", H_CpuUtil, NULL, NULL},
+OK { "system.cpu.load[*]", H_CpuLoad, NULL, NULL},
+OK { "vfs.fs.size[*]", H_DiskInfo, NULL, NULL },
+OK { "vfs.file.size[*]", H_FileSize, NULL, NULL },
+OK { "vfs.file.cksum[*]", H_CRC32, NULL, NULL },
+ { "vfs.file.md5sum[*]", NULL, H_MD5Hash, NULL },
+ { "system.swap.size[*]", H_SwapSize, NULL, NULL },
+OK { "vm.memory.size[*]", H_MemorySize, NULL, NULL },
+OK { "agent.ping", H_NumericConstant, NULL, (char *)1 },
+OK { "proc.num[*]", H_ProcNum, NULL, NULL },
+OK { "system.uname", NULL, H_SystemUname, NULL },
+OK { "system.hostname", NULL, H_HostName, NULL },
+OK { "agent.version", NULL, H_StringConstant, AGENT_VERSION },
+*/
+#endif /* TODO */
+
ZBX_METRIC parameters_specific[]=
/* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */
{