From 1b9e77ce99c6a790d62ba6a04ef905a566d2d838 Mon Sep 17 00:00:00 2001 From: osmiy Date: Fri, 28 Oct 2005 13:51:13 +0000 Subject: - grouped commands in to the new command with parameters. [only in linux] (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2231 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- src/libs/zbxsysinfo/linux/Makefile.am | 2 +- src/libs/zbxsysinfo/linux/cpu.c | 156 +++++++++++++++ src/libs/zbxsysinfo/linux/diskio.c | 152 +++++++++++++++ src/libs/zbxsysinfo/linux/diskspace.c | 59 ++++++ src/libs/zbxsysinfo/linux/inodes.c | 194 +++++++++++++------ src/libs/zbxsysinfo/linux/linux.c | 344 ++++++++++++++-------------------- src/libs/zbxsysinfo/linux/memory.c | 100 +++++----- src/libs/zbxsysinfo/linux/net.c | 44 +++++ src/libs/zbxsysinfo/linux/proc.c | 24 ++- src/libs/zbxsysinfo/linux/swap.c | 139 ++++++++++---- 10 files changed, 859 insertions(+), 355 deletions(-) create mode 100644 src/libs/zbxsysinfo/linux/net.c (limited to 'src/libs/zbxsysinfo/linux') diff --git a/src/libs/zbxsysinfo/linux/Makefile.am b/src/libs/zbxsysinfo/linux/Makefile.am index 4e57c84f..899b3101 100644 --- a/src/libs/zbxsysinfo/linux/Makefile.am +++ b/src/libs/zbxsysinfo/linux/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS= -libzbxsysinfo2_a_SOURCES=cpu.c diskio.c diskspace.c inodes.c memory.c proc.c sensors.c swap.c uptime.c +libzbxsysinfo2_a_SOURCES=cpu.c diskio.c diskspace.c inodes.c memory.c net.c proc.c sensors.c swap.c uptime.c lib_LIBRARIES=libzbxsysinfo2.a libzbxsysinfo2_a_LIBADD = ../../zbxcommon/libzbxcommon.a ../../zbxcrypto/libzbxcrypto.a diff --git a/src/libs/zbxsysinfo/linux/cpu.c b/src/libs/zbxsysinfo/linux/cpu.c index b914fdb6..ca161e58 100644 --- a/src/libs/zbxsysinfo/linux/cpu.c +++ b/src/libs/zbxsysinfo/linux/cpu.c @@ -22,6 +22,162 @@ #include "common.h" #include "sysinfo.h" +int SYSTEM_CPU_LOAD(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define CPU_FNCLIST struct cpu_fnclist_s +CPU_FNCLIST +{ + char *mode; + int (*function)(); +}; + + CPU_FNCLIST fl[] = + { + {"avg1" , SYSTEM_CPU_LOAD1}, + {"avg5" , SYSTEM_CPU_LOAD5}, + {"avg15", SYSTEM_CPU_LOAD15}, + {0, 0} + }; + + char cpuname[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 2) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + if(cpuname[0] == '\0') + { + /* default parameter */ + sprintf(cpuname, "all"); + } + if(strncmp(cpuname, "all", MAX_STRING_LEN)) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "avg1"); + } + for(i=0; fl[i].mode!=0; i++) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, param, flags, result); + } + } + + return SYSINFO_RET_FAIL; +} + +int SYSTEM_CPU_UTIL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define CPU_FNCLIST struct cpu_fnclist_s +CPU_FNCLIST +{ + char *type; + char *mode; + int (*function)(); +}; + + CPU_FNCLIST fl[] = + { + {"idle", "avg1" , SYSTEM_CPU_IDLE1}, + {"idle", "avg5" , SYSTEM_CPU_IDLE5}, + {"idle", "avg15", SYSTEM_CPU_IDLE15}, + {"nice", "avg1" , SYSTEM_CPU_NICE1}, + {"nice", "avg5" , SYSTEM_CPU_NICE5}, + {"nice", "avg15", SYSTEM_CPU_NICE15}, + {"user", "avg1" , SYSTEM_CPU_USER1}, + {"user", "avg5" , SYSTEM_CPU_USER5}, + {"user", "avg15", SYSTEM_CPU_USER15}, + {"system", "avg1" , SYSTEM_CPU_SYS1}, + {"system", "avg5" , SYSTEM_CPU_SYS5}, + {"system", "avg15", SYSTEM_CPU_SYS15}, + {0, 0, 0} + }; + + char cpuname[MAX_STRING_LEN]; + char type[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 3) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, cpuname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + if(cpuname[0] == '\0') + { + /* default parameter */ + sprintf(cpuname, "all"); + } + if(strncmp(cpuname, "all", MAX_STRING_LEN)) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, type, MAX_STRING_LEN) != 0) + { + type[0] = '\0'; + } + if(type[0] == '\0') + { + /* default parameter */ + sprintf(type, "user"); + } + + if(get_param(param, 3, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "avg1"); + } + + for(i=0; fl[i].type!=0; i++) + { + if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, param, flags, result); + } + } + } + + return SYSINFO_RET_FAIL; +} + int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { return get_stat(cmd, flags, result); diff --git a/src/libs/zbxsysinfo/linux/diskio.c b/src/libs/zbxsysinfo/linux/diskio.c index 2ff6590c..328dceb3 100644 --- a/src/libs/zbxsysinfo/linux/diskio.c +++ b/src/libs/zbxsysinfo/linux/diskio.c @@ -22,6 +22,158 @@ #include "common.h" #include "sysinfo.h" +int VFS_DEV_WRITE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define DEV_FNCLIST struct dev_fnclist_s +DEV_FNCLIST +{ + char *type; + char *mode; + int (*function)(); +}; + + DEV_FNCLIST fl[] = + { + {"ops", "avg1" , DISKWRITEOPS1}, + {"ops", "avg5" , DISKWRITEOPS5}, + {"ops", "avg15", DISKWRITEOPS15}, + {"bps", "avg1" , DISKWRITEBLKS1}, + {"bps", "avg5" , DISKWRITEBLKS5}, + {"bps", "avg15", DISKWRITEBLKS15}, + {0, 0, 0} + }; + + char devname[MAX_STRING_LEN]; + char type[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 3) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, devname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, type, MAX_STRING_LEN) != 0) + { + type[0] = '\0'; + } + if(type[0] == '\0') + { + /* default parameter */ + sprintf(type, "bps"); + } + + if(get_param(param, 3, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "avg1"); + } + + for(i=0; fl[i].type!=0; i++) + { + if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, devname, flags, result); + } + } + } + + return SYSINFO_RET_FAIL; +} + +int VFS_DEV_READ(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define DEV_FNCLIST struct dev_fnclist_s +DEV_FNCLIST +{ + char *type; + char *mode; + int (*function)(); +}; + + DEV_FNCLIST fl[] = + { + {"ops", "avg1" , DISKREADOPS1}, + {"ops", "avg5" , DISKREADOPS5}, + {"ops", "avg15", DISKREADOPS15}, + {"bps", "avg1" , DISKREADBLKS1}, + {"bps", "avg5" , DISKREADBLKS5}, + {"bps", "avg15", DISKREADBLKS15}, + {0, 0, 0} + }; + + char devname[MAX_STRING_LEN]; + char type[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 3) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, devname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, type, MAX_STRING_LEN) != 0) + { + type[0] = '\0'; + } + if(type[0] == '\0') + { + /* default parameter */ + sprintf(type, "bps"); + } + + if(get_param(param, 3, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "avg1"); + } + + for(i=0; fl[i].type!=0; i++) + { + if(strncmp(type, fl[i].type, MAX_STRING_LEN)==0) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, devname, flags, result); + } + } + } + + return SYSINFO_RET_FAIL; +} + int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { char key[MAX_STRING_LEN]; diff --git a/src/libs/zbxsysinfo/linux/diskspace.c b/src/libs/zbxsysinfo/linux/diskspace.c index 09846515..9db5895a 100644 --- a/src/libs/zbxsysinfo/linux/diskspace.c +++ b/src/libs/zbxsysinfo/linux/diskspace.c @@ -22,6 +22,65 @@ #include "common.h" #include "sysinfo.h" +int VFS_FS_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define FS_FNCLIST struct fs_fnclist_s +FS_FNCLIST +{ + char *mode; + int (*function)(); +}; + + FS_FNCLIST fl[] = + { + {"free" , VFS_FS_FREE}, + {"total" , VFS_FS_TOTAL}, + {"used", VFS_FS_USED}, + {"pfree" , VFS_FS_PFREE}, + {"pused" , VFS_FS_PUSED}, + {0, 0} + }; + + char fsname[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 2) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "total"); + } + + for(i=0; fl[i].mode!=0; i++) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, fsname, flags, result); + } + } + + return SYSINFO_RET_FAIL; +} + int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { #ifdef HAVE_SYS_STATVFS_H diff --git a/src/libs/zbxsysinfo/linux/inodes.c b/src/libs/zbxsysinfo/linux/inodes.c index ba72e78e..2def25a0 100644 --- a/src/libs/zbxsysinfo/linux/inodes.c +++ b/src/libs/zbxsysinfo/linux/inodes.c @@ -24,39 +24,73 @@ #include "md5.h" -int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +int VFS_FS_INODE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { -#ifdef HAVE_SYS_STATVFS_H - struct statvfs s; - char mountPoint[MAX_STRING_LEN]; - - assert(result); - memset(result, 0, sizeof(AGENT_RESULT)); +#define FS_FNCLIST struct fs_fnclist_s +FS_FNCLIST +{ + char *mode; + int (*function)(); +}; - if(num_param(param) > 1) + FS_FNCLIST fl[] = + { + {"free" , VFS_FS_INODE_FREE}, + {"total" , VFS_FS_INODE_TOTAL}, + {"used", VFS_FS_INODE_USED}, + {"pfree" , VFS_FS_INODE_PFREE}, + {"pused" , VFS_FS_INODE_PUSED}, + {0, 0} + }; + + char fsname[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 2) { return SYSINFO_RET_FAIL; } - if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0) + if(get_param(param, 1, fsname, MAX_STRING_LEN) != 0) { return SYSINFO_RET_FAIL; - } - - if ( statvfs( (char *)mountPoint, &s) != 0 ) + } + + if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "total"); + } + + for(i=0; fl[i].mode!=0; i++) { - return SYSINFO_RET_FAIL; + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, fsname, flags, result); + } } + + return SYSINFO_RET_FAIL; +} - result->type |= AR_DOUBLE; - result->dbl = (double)s.f_favail; - return SYSINFO_RET_OK; +int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + char mountPoint[MAX_STRING_LEN]; +#ifdef HAVE_SYS_STATVFS_H + struct statvfs s; #else struct statfs s; - long blocks_used; - long blocks_percent_used; - char mountPoint[MAX_STRING_LEN]; +#endif assert(result); @@ -72,38 +106,35 @@ int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_ return SYSINFO_RET_FAIL; } +#ifdef HAVE_SYS_STATVFS_H + if ( statvfs( (char *)mountPoint, &s) != 0 ) +#else if ( statfs( (char *)mountPoint, &s) != 0 ) +#endif { return SYSINFO_RET_FAIL; } if ( s.f_blocks > 0 ) { - blocks_used = s.f_blocks - s.f_bfree; - blocks_percent_used = (long) - (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); - -/* printf( - "%7.0f %7.0f %7.0f %5ld%% %s\n" - ,s.f_blocks * (s.f_bsize / 1024.0) - ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0) - ,s.f_bavail * (s.f_bsize / 1024.0) - ,blocks_percent_used - ,mountPoint); -*/ result->type |= AR_DOUBLE; +#ifdef HAVE_SYS_STATVFS_H + result->dbl = (double)(s.f_favail); +#else result->dbl = (double)(s.f_ffree); +#endif return SYSINFO_RET_OK; - } return SYSINFO_RET_FAIL; -#endif } -int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +int VFS_FS_INODE_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { + char mountPoint[MAX_STRING_LEN]; #ifdef HAVE_SYS_STATVFS_H struct statvfs s; - char mountPoint[MAX_STRING_LEN]; +#else + struct statfs s; +#endif assert(result); @@ -119,19 +150,36 @@ int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_FAIL; } - if ( statvfs( (char *)mountPoint, &s) != 0 ) +#ifdef HAVE_SYS_STATVFS_H + if ( statvfs( (char *)mountPoint, &s) != 0 ) +#else + if ( statfs( (char *)mountPoint, &s) != 0 ) +#endif { - return SYSINFO_RET_FAIL; + return SYSINFO_RET_FAIL; } + + if ( s.f_blocks > 0 ) { + result->type |= AR_DOUBLE; +#ifdef HAVE_SYS_STATVFS_H + struct statvfs s; + result->dbl = (double)(s.f_files - s.f_favail); +#else + result->dbl = (double)(s.f_files - s.f_ffree); +#endif + return SYSINFO_RET_OK; + } + return SYSINFO_RET_FAIL; +} - result->type |= AR_DOUBLE; - result->dbl = (double)(s.f_files); - return SYSINFO_RET_OK; +int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + char mountPoint[MAX_STRING_LEN]; +#ifdef HAVE_SYS_STATVFS_H + struct statvfs s; #else struct statfs s; - long blocks_used; - long blocks_percent_used; - char mountPoint[MAX_STRING_LEN]; +#endif assert(result); @@ -147,31 +195,21 @@ int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_FAIL; } +#ifdef HAVE_SYS_STATVFS_H + if ( statvfs( (char *)mountPoint, &s) != 0 ) +#else if ( statfs( (char *)mountPoint, &s) != 0 ) +#endif { return SYSINFO_RET_FAIL; } if ( s.f_blocks > 0 ) { - blocks_used = s.f_blocks - s.f_bfree; - blocks_percent_used = (long) - (blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); - -/* printf( - "%7.0f %7.0f %7.0f %5ld%% %s\n" - ,s.f_blocks * (s.f_bsize / 1024.0) - ,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0) - ,s.f_bavail * (s.f_bsize / 1024.0) - ,blocks_percent_used - ,mountPoint); -*/ result->type |= AR_DOUBLE; result->dbl = (double)(s.f_files); return SYSINFO_RET_OK; - } return SYSINFO_RET_FAIL; -#endif } int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) @@ -216,3 +254,45 @@ int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT return SYSINFO_RET_OK; } +int VFS_FS_INODE_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + AGENT_RESULT total_result; + AGENT_RESULT used_result; + char mountPoint[MAX_STRING_LEN]; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 1) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, mountPoint, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(SYSINFO_RET_OK != VFS_FS_INODE_TOTAL(cmd, mountPoint, flags, &total_result)) + { + memcpy(result, &total_result, sizeof(AGENT_RESULT)); + return SYSINFO_RET_FAIL; + } + + if(SYSINFO_RET_OK != VFS_FS_INODE_USED(cmd, mountPoint, flags, &used_result)) + { + memcpy(result, &used_result, sizeof(AGENT_RESULT)); + return SYSINFO_RET_FAIL; + } + + if(total_result.dbl == 0) + { + return SYSINFO_RET_FAIL; + } + + result->type |= AR_DOUBLE; + result->dbl = 100.0 * used_result.dbl / total_result.dbl; + return SYSINFO_RET_OK; +} + diff --git a/src/libs/zbxsysinfo/linux/linux.c b/src/libs/zbxsysinfo/linux/linux.c index 96ff647a..e7618d0e 100644 --- a/src/libs/zbxsysinfo/linux/linux.c +++ b/src/libs/zbxsysinfo/linux/linux.c @@ -21,117 +21,6 @@ #include "common.h" #include "sysinfo.h" -int VM_MEMORY_BUFFERS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SYSTEM_CPU_IDLE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_IDLE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_IDLE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_USER1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_USER5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_USER15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_NICE1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_NICE5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_NICE15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_SYS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_SYS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_SYS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int VFS_FS_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_USED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_PUSED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int DISK_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISK_RIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISK_WIO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISK_RBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISK_WBLK(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int VFS_FILE_ATIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_CKSUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_CTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_MD5SUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_MTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_REGEXP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_REGMATCH(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FILE_EXISTS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int VFS_FS_INODE_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_INODE_PFREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VFS_FS_INODE_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - - -int KERNEL_MAXFILES(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int KERNEL_MAXPROC(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int NET_IF_IBYTES1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int NET_IF_IBYTES5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int NET_IF_IBYTES15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int NET_IF_OBYTES1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int NET_IF_OBYTES5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int NET_IF_OBYTES15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int DISKREADOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKREADOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKREADOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKREADBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKREADBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKREADBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEOPS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEOPS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEOPS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEBLKS1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEBLKS5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int DISKWRITEBLKS15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int AGENT_PING(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VM_MEMORY_SHARED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int VM_MEMORY_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int PROC_MEMORY(const char *cmd, const char *param, double *value, const char *msg, int mlen_max); - -int PROCCOUNT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SYSTEM_CPU_LOAD1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_LOAD5(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_CPU_LOAD15(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SENSOR_TEMP1(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SENSOR_TEMP2(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SENSOR_TEMP3(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SYSTEM_UPTIME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SYSTEM_HOSTNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_UNAME(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_UNUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int SYSTEM_SWAP_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int TCP_LISTEN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int AGENT_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int CHECK_SERVICE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int CHECK_SERVICE_PERF(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int CHECK_PORT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int CHECK_DNS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - -int OLD_CPU(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_IO(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_KERNEL(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_SYSTEM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_SENSOR(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); -int OLD_VERSION(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result); - ZBX_METRIC parameters_specific[]= /* KEY FLAG FUNCTION ADD_PARAM TEST_PARAM */ { @@ -140,154 +29,147 @@ ZBX_METRIC parameters_specific[]= /* incorrect OLD naming */ {"cpu", CF_USEUPARAM, OLD_CPU, 0, "idle1"}, /* - {"cpu[idle1]", 0, OLD_CPU, 0, 0}, - {"cpu[idle5]", 0, OLD_CPU, 0, 0}, - {"cpu[idle15]", 0, OLD_CPU, 0, 0}, - {"cpu[nice1]", 0, OLD_CPU, 0, 0}, - {"cpu[nice5]", 0, OLD_CPU, 0, 0}, - {"cpu[nice15]", 0, OLD_CPU, 0, 0}, - {"cpu[system1]", 0, OLD_CPU, 0, 0}, - {"cpu[system5]", 0, OLD_CPU, 0, 0}, - {"cpu[system15]", 0, OLD_CPU, 0, 0}, - {"cpu[user1]", 0, OLD_CPU, 0, 0}, - {"cpu[user5]", 0, OLD_CPU, 0, 0}, - {"cpu[user15]", 0, OLD_CPU, 0, 0}, + {"cpu[idle1]", 0, 0, 0, 0}, + {"cpu[idle5]", 0, 0, 0, 0}, + {"cpu[idle15]", 0, 0, 0, 0}, + {"cpu[nice1]", 0, 0, 0, 0}, + {"cpu[nice5]", 0, 0, 0, 0}, + {"cpu[nice15]", 0, 0, 0, 0}, + {"cpu[system1]", 0, 0, 0, 0}, + {"cpu[system5]", 0, 0, 0, 0}, + {"cpu[system15]", 0, 0, 0, 0}, + {"cpu[user1]", 0, 0, 0, 0}, + {"cpu[user5]", 0, 0, 0, 0}, + {"cpu[user15]", 0, 0, 0, 0}, */ {"io", CF_USEUPARAM, OLD_IO, 0, "disk_io"}, /* - {"io[disk_io]", 0, OLD_IO, 0, 0}, - {"io[disk_rio]", 0, OLD_IO, 0, 0}, - {"io[disk_wio]", 0, OLD_IO, 0, 0}, - {"io[disk_rblk]", 0, OLD_IO, 0, 0}, - {"io[disk_wblk]", 0, OLD_IO, 0, 0}, + {"io[disk_io]", 0, 0, 0, 0}, + {"io[disk_rio]", 0, 0, 0, 0}, + {"io[disk_wio]", 0, 0, 0, 0}, + {"io[disk_rblk]", 0, 0, 0, 0}, + {"io[disk_wblk]", 0, 0, 0, 0}, */ {"kern", CF_USEUPARAM, OLD_KERNEL, 0, "maxfiles"}, /* - {"kern[maxfiles]", 0, OLD_KERNEL, 0, 0}, - {"kern[maxproc]", 0, OLD_KERNEL, 0, 0}, + {"kern[maxfiles]", 0, 0, 0, 0}, + {"kern[maxproc]", 0, 0, 0, 0}, */ {"memory", CF_USEUPARAM, OLD_MEMORY, 0, "buffers"}, /* - {"memory[buffers]", 0, OLD_MEMORY, 0, 0}, - {"memory[cached]", 0, OLD_MEMORY, 0, 0}, - {"memory[free]", 0, OLD_MEMORY, 0, 0}, - {"memory[shared]", 0, OLD_MEMORY, 0, 0}, - {"memory[total]", 0, OLD_MEMORY, 0, 0}, + {"memory[buffers]", 0, 0, 0, 0}, + {"memory[cached]", 0, 0, 0, 0}, + {"memory[free]", 0, 0, 0, 0}, + {"memory[shared]", 0, 0, 0, 0}, + {"memory[total]", 0, 0, 0, 0}, */ {"system", CF_USEUPARAM, OLD_SYSTEM, 0, "uname"}, /* - {"system[proccount]", 0, OLD_SYSTEM, 0, 0}, + {"system[proccount]", 0, 0, 0, 0}, - {"system[procload]", 0, OLD_SYSTEM, 0, 0}, - {"system[procload5]", 0, OLD_SYSTEM, 0, 0}, - {"system[procload15]", 0, OLD_SYSTEM, 0, 0}, - {"system[hostname]", 0, OLD_SYSTEM, 0, 0}, - {"system[uname]", 0, OLD_SYSTEM, 0, 0}, - {"system[uptime]", 0, OLD_SYSTEM, 0, 0}, - {"system[users]", 0, OLD_SYSTEM, 0, 0}, + {"system[procload]", 0, 0, 0, 0}, + {"system[procload5]", 0, 0, 0, 0}, + {"system[procload15]", 0, 0, 0, 0}, + {"system[hostname]", 0, 0, 0, 0}, + {"system[uname]", 0, 0, 0, 0}, + {"system[uptime]", 0, 0, 0, 0}, + {"system[users]", 0, 0, 0, 0}, - {"system[procrunning]", 0, OLD_SYSTEM, 0, 0}, + {"system[procrunning]", 0, 0, 0, 0}, */ {"sensor", CF_USEUPARAM, OLD_SENSOR, 0, "temp1"}, /* - {"sensor[temp1]", 0, OLD_SENSOR, 0, 0}, - {"sensor[temp2]", 0, OLD_SENSOR, 0, 0}, - {"sensor[temp3]", 0, OLD_SENSOR, 0, 0}, + {"sensor[temp1]", 0, 0, 0, 0}, + {"sensor[temp2]", 0, 0, 0, 0}, + {"sensor[temp3]", 0, 0, 0, 0}, */ {"swap", CF_USEUPARAM, OLD_SWAP, 0, "total"}, /* - {"swap[free]", 0, OLD_SWAP, 0, 0}, - {"swap[total]", 0, OLD_SWAP, 0, 0}, + {"swap[free]", 0, 0, 0, 0}, + {"swap[total]", 0, 0, 0, 0}, */ - {"version", CF_USEUPARAM, OLD_VERSION, 0, "zabbix_agent"}, + {"version", CF_USEUPARAM, OLD_VERSION, 0, "zabbix_agent"}, /* {"version[zabbix_agent]", 0, OLD_VERSION, 0, 0}, */ /* correct OLD naming */ +/* {"cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"}, - - {"diskfree", CF_USEUPARAM, VFS_FS_FREE, 0, "/"}, +*/ +/* + {"diskfree", CF_USEUPARAM, VFS_FS_FREE, 0, "/"}, {"disktotal", CF_USEUPARAM, VFS_FS_TOTAL, 0, "/"}, {"diskused", CF_USEUPARAM, VFS_FS_USED, 0, "/"}, {"diskfree_perc", CF_USEUPARAM, VFS_FS_PFREE, 0, "/"}, {"diskused_perc", CF_USEUPARAM, VFS_FS_PUSED, 0, "/"}, - +*/ +/* {"file", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"}, {"filesize", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"}, - +*/ +/* {"inodefree", CF_USEUPARAM, VFS_FS_INODE_FREE, 0, "/"}, {"inodetotal", CF_USEUPARAM, VFS_FS_INODE_TOTAL, 0, "/"}, {"inodefree_perc", CF_USEUPARAM, VFS_FS_INODE_PFREE, 0, "/"}, - +*/ +/* {"md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"}, - +*/ +/* {"netloadin1", CF_USEUPARAM, NET_IF_IBYTES1, 0, "lo"}, {"netloadin5", CF_USEUPARAM, NET_IF_IBYTES5, 0, "lo"}, {"netloadin15", CF_USEUPARAM, NET_IF_IBYTES15, 0, "lo"}, {"netloadout1", CF_USEUPARAM, NET_IF_OBYTES1, 0, "lo"}, {"netloadout5", CF_USEUPARAM, NET_IF_OBYTES5, 0, "lo"}, {"netloadout15", CF_USEUPARAM, NET_IF_OBYTES15, 0, "lo"}, - +*/ +/* {"ping", 0, AGENT_PING, 0, 0}, - - {"proc_cnt", CF_USEUPARAM, PROC_NUM, 0, "inetd"}, +*/ /* New naming */ - - {"agent.ping", 0, AGENT_PING, 0, 0}, - {"agent.version", 0, AGENT_VERSION, 0, 0}, - - {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0}, - {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0}, - - {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd"}, - {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd"}, - +/* + {"system.cpu.idle1", 0, SYSTEM_CPU_IDLE1, 0, 0}, + {"system.cpu.idle5", 0, SYSTEM_CPU_IDLE5, 0, 0}, + {"system.cpu.idle15", 0, SYSTEM_CPU_IDLE15, 0, 0}, + {"system.cpu.nice1", 0, SYSTEM_CPU_NICE1, 0, 0}, + {"system.cpu.nice5", 0, SYSTEM_CPU_NICE5, 0, 0}, + {"system.cpu.nice15", 0, SYSTEM_CPU_NICE15, 0, 0}, + {"system.cpu.sys1", 0, SYSTEM_CPU_SYS1, 0, 0}, + {"system.cpu.sys5", 0, SYSTEM_CPU_SYS5, 0, 0}, + {"system.cpu.sys15", 0, SYSTEM_CPU_SYS15, 0, 0}, + {"system.cpu.user1", 0, SYSTEM_CPU_USER1, 0, 0}, + {"system.cpu.user5", 0, SYSTEM_CPU_USER5, 0, 0}, + {"system.cpu.user15", 0, SYSTEM_CPU_USER15, 0, 0}, +*/ +/* {"vm.memory.total", 0, VM_MEMORY_TOTAL, 0, 0}, {"vm.memory.shared", 0, VM_MEMORY_SHARED, 0, 0}, {"vm.memory.buffers", 0, VM_MEMORY_BUFFERS, 0, 0}, {"vm.memory.cached", 0, VM_MEMORY_CACHED, 0, 0}, {"vm.memory.free", 0, VM_MEMORY_FREE, 0, 0}, - +*/ +/* {"vfs.fs.free", CF_USEUPARAM, VFS_FS_FREE, 0, "/"}, {"vfs.fs.total", CF_USEUPARAM, VFS_FS_TOTAL, 0, "/"}, {"vfs.fs.used", CF_USEUPARAM, VFS_FS_USED, 0, "/"}, {"vfs.fs.pfree", CF_USEUPARAM, VFS_FS_PFREE, 0, "/"}, {"vfs.fs.pused", CF_USEUPARAM, VFS_FS_PUSED, 0, "/"}, - +*/ +/* {"vfs.fs.inode.free", CF_USEUPARAM, VFS_FS_INODE_FREE, 0, "/"}, {"vfs.fs.inode.total", CF_USEUPARAM, VFS_FS_INODE_TOTAL, 0, "/"}, {"vfs.fs.inode.pfree", CF_USEUPARAM, VFS_FS_INODE_PFREE, 0, "/"}, - - {"vfs.file.atime", CF_USEUPARAM, VFS_FILE_ATIME, 0, "/etc/passwd"}, - {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"}, - {"vfs.file.ctime", CF_USEUPARAM, VFS_FILE_CTIME, 0, "/etc/passwd"}, - {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"}, - {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"}, - {"vfs.file.mtime", CF_USEUPARAM, VFS_FILE_MTIME, 0, "/etc/passwd"}, - {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"}, - {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"}, - {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"}, - - {"system.cpu.idle1", 0, SYSTEM_CPU_IDLE1, 0, 0}, - {"system.cpu.idle5", 0, SYSTEM_CPU_IDLE5, 0, 0}, - {"system.cpu.idle15", 0, SYSTEM_CPU_IDLE15, 0, 0}, - {"system.cpu.nice1", 0, SYSTEM_CPU_NICE1, 0, 0}, - {"system.cpu.nice5", 0, SYSTEM_CPU_NICE5, 0, 0}, - {"system.cpu.nice15", 0, SYSTEM_CPU_NICE15, 0, 0}, - {"system.cpu.sys1", 0, SYSTEM_CPU_SYS1, 0, 0}, - {"system.cpu.sys5", 0, SYSTEM_CPU_SYS5, 0, 0}, - {"system.cpu.sys15", 0, SYSTEM_CPU_SYS15, 0, 0}, - {"system.cpu.user1", 0, SYSTEM_CPU_USER1, 0, 0}, - {"system.cpu.user5", 0, SYSTEM_CPU_USER5, 0, 0}, - {"system.cpu.user15", 0, SYSTEM_CPU_USER15, 0, 0}, - +*/ +/* {"net.if.ibytes1", CF_USEUPARAM, NET_IF_IBYTES1, 0, "lo"}, {"net.if.ibytes5", CF_USEUPARAM, NET_IF_IBYTES5, 0, "lo"}, {"net.if.ibytes15", CF_USEUPARAM, NET_IF_IBYTES15,0, "lo"}, + {"net.if.obytes1", CF_USEUPARAM, NET_IF_OBYTES1, 0, "lo"}, {"net.if.obytes5", CF_USEUPARAM, NET_IF_OBYTES5, 0, "lo"}, {"net.if.obytes15", CF_USEUPARAM, NET_IF_OBYTES15,0, "lo"}, - +*/ +/* {"disk_read_ops1", CF_USEUPARAM, DISKREADOPS1, 0, "hda"}, {"disk_read_ops5", CF_USEUPARAM, DISKREADOPS5, 0, "hda"}, {"disk_read_ops15", CF_USEUPARAM, DISKREADOPS15, 0, "hda"}, @@ -303,20 +185,12 @@ ZBX_METRIC parameters_specific[]= {"disk_write_blks1", CF_USEUPARAM, DISKWRITEBLKS1, 0, "hda"}, {"disk_write_blks5", CF_USEUPARAM, DISKWRITEBLKS5, 0, "hda"}, {"disk_write_blks15", CF_USEUPARAM, DISKWRITEBLKS15,0, "hda"}, - +*/ +/* {"system.cpu.load1", 0, SYSTEM_CPU_LOAD1, 0, 0}, {"system.cpu.load5", 0, SYSTEM_CPU_LOAD5, 0, 0}, {"system.cpu.load15", 0, SYSTEM_CPU_LOAD15, 0, 0}, - - {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0}, - - {"system.swap.free", 0, SYSTEM_SWAP_FREE, 0, 0}, - {"system.swap.total", 0, SYSTEM_SWAP_TOTAL, 0, 0}, - - - {"system.uname", 0, SYSTEM_UNAME, 0, 0}, - {"system.uptime", 0, SYSTEM_UPTIME, 0, 0}, - {"system.users.num", 0, SYSTEM_UNUM, 0, 0}, +*/ /**************************************** All these perameters require more than 1 second to retrieve. @@ -329,11 +203,65 @@ ZBX_METRIC parameters_specific[]= ***************************************/ /* {"tcp_count" ,EXECUTE, 0, "netstat -tn|grep EST|wc -l"}, */ - +/* {"check_port", CF_USEUPARAM, CHECK_PORT, 0, "80"}, {"check_service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"}, {"check_service_perf", CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"}, +*/ +/* {"dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"}, +*/ + {"agent.ping", 0, AGENT_PING, 0, 0}, + {"agent.version", 0, AGENT_VERSION, 0, 0}, + + {"kernel.maxfiles", 0, KERNEL_MAXFILES, 0, 0}, + {"kernel.maxproc", 0, KERNEL_MAXPROC, 0, 0}, + + {"vfs.file.atime", CF_USEUPARAM, VFS_FILE_ATIME, 0, "/etc/passwd"}, + {"vfs.file.cksum", CF_USEUPARAM, VFS_FILE_CKSUM, 0, "/etc/services"}, + {"vfs.file.ctime", CF_USEUPARAM, VFS_FILE_CTIME, 0, "/etc/passwd"}, + {"vfs.file.exists", CF_USEUPARAM, VFS_FILE_EXISTS, 0, "/etc/passwd"}, + {"vfs.file.md5sum", CF_USEUPARAM, VFS_FILE_MD5SUM, 0, "/etc/services"}, + {"vfs.file.mtime", CF_USEUPARAM, VFS_FILE_MTIME, 0, "/etc/passwd"}, + {"vfs.file.regexp", CF_USEUPARAM, VFS_FILE_REGEXP, 0, "/etc/passwd,root"}, + {"vfs.file.regmatch", CF_USEUPARAM, VFS_FILE_REGMATCH, 0, "/etc/passwd,root"}, + {"vfs.file.size", CF_USEUPARAM, VFS_FILE_SIZE, 0, "/etc/passwd"}, + +/************************************ + * NEW FUNCTIONS * + ************************************/ + + {"net.tcp.dns", CF_USEUPARAM, CHECK_DNS, 0, "127.0.0.1,localhost"}, + + {"net.tcp.port", CF_USEUPARAM, CHECK_PORT, 0, "80"}, + {"net.tcp.service", CF_USEUPARAM, CHECK_SERVICE, 0, "ssh,127.0.0.1,22"}, + {"net.tcp.service.perf",CF_USEUPARAM, CHECK_SERVICE_PERF, 0, "ssh,127.0.0.1,22"}, + + {"net.if.in", CF_USEUPARAM, NET_IF_IN, 0, "lo,bytes,avg1"}, + {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo,bytes,avg1"}, + + {"vfs.fs.size", CF_USEUPARAM, VFS_FS_SIZE, 0, "/,free"}, + {"vfs.fs.inode", CF_USEUPARAM, VFS_FS_INODE, 0, "/,free"}, + + {"vfs.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"}, + + {"vfs.dev.read", CF_USEUPARAM, VFS_DEV_READ, 0, "hda,ops,avg1"}, + {"vfs.dev.write", CF_USEUPARAM, VFS_DEV_WRITE, 0, "hda,ops,avg1"}, + + {"proc.num", CF_USEUPARAM, PROC_NUM, 0, "inetd,,"}, + {"proc.mem", CF_USEUPARAM, PROC_MEMORY, 0, "inetd,,"}, + + {"system.cpu.util", CF_USEUPARAM, SYSTEM_CPU_UTIL, 0, "all,user,avg1"}, + + {"system.cpu.load", CF_USEUPARAM, SYSTEM_CPU_LOAD, 0, "all,avg1"}, + + {"system.swap.size", CF_USEUPARAM, SYSTEM_SWAP_SIZE, 0, "all,free"}, + + {"system.hostname", 0, SYSTEM_HOSTNAME, 0, 0}, + + {"system.uname", 0, SYSTEM_UNAME, 0, 0}, + {"system.uptime", 0, SYSTEM_UPTIME, 0, 0}, + {"system.users.num", 0, SYSTEM_UNUM, 0, 0}, {0} }; diff --git a/src/libs/zbxsysinfo/linux/memory.c b/src/libs/zbxsysinfo/linux/memory.c index d48d3eec..92db6809 100644 --- a/src/libs/zbxsysinfo/linux/memory.c +++ b/src/libs/zbxsysinfo/linux/memory.c @@ -22,6 +22,59 @@ #include "common.h" #include "sysinfo.h" +int VM_MEMORY_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ +#define MEM_FNCLIST struct mem_fnclist_s +MEM_FNCLIST +{ + char *mode; + int (*function)(); +}; + + MEM_FNCLIST fl[] = + { + {"free", DISKWRITEOPS1}, + {"shared", DISKWRITEOPS5}, + {"total", DISKWRITEOPS15}, + {"buffers", DISKWRITEBLKS1}, + {"cached", DISKWRITEBLKS5}, + {"free", DISKWRITEBLKS15}, + {0, 0} + }; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 1) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "total"); + } + + for(i=0; fl[i].mode!=0; i++) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, param, flags, result); + } + } + + return SYSINFO_RET_FAIL; +} + int VM_MEMORY_CACHED(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { #ifdef HAVE_PROC @@ -402,50 +455,3 @@ int VM_MEMORY_FREE(const char *cmd, const char *param, unsigned flags, AGENT_RES #endif } -int OLD_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - char key[MAX_STRING_LEN]; - int ret; - - assert(result); - - memset(result, 0, sizeof(AGENT_RESULT)); - - if(num_param(param) > 1) - { - return SYSINFO_RET_FAIL; - } - - if(get_param(param, 1, key, MAX_STRING_LEN) != 0) - { - return SYSINFO_RET_FAIL; - } - - if(strcmp(key,"buffers") == 0) - { - ret = VM_MEMORY_BUFFERS(cmd, param, flags, result); - } - else if(strcmp(key,"cached") == 0) - { - ret = VM_MEMORY_CACHED(cmd, param, flags, result); - } - else if(strcmp(key,"free") == 0) - { - ret = VM_MEMORY_FREE(cmd, param, flags, result); - } - else if(strcmp(key,"shared") == 0) - { - ret = VM_MEMORY_SHARED(cmd, param, flags, result); - } - else if(strcmp(key,"total") == 0) - { - ret = VM_MEMORY_TOTAL(cmd, param, flags, result); - } - else - { - ret = SYSINFO_RET_FAIL; - } - - return ret; -} - diff --git a/src/libs/zbxsysinfo/linux/net.c b/src/libs/zbxsysinfo/linux/net.c new file mode 100644 index 00000000..accddb18 --- /dev/null +++ b/src/libs/zbxsysinfo/linux/net.c @@ -0,0 +1,44 @@ +/* +** ZABBIX +** Copyright (C) 2000-2005 SIA Zabbix +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ + +#include "config.h" + +#include "common.h" +#include "sysinfo.h" + +int NET_IF_IN(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + return SYSINFO_RET_FAIL; +} + +int NET_IF_OUT(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + return SYSINFO_RET_FAIL; +} + diff --git a/src/libs/zbxsysinfo/linux/proc.c b/src/libs/zbxsysinfo/linux/proc.c index 30fafd7c..57be6272 100644 --- a/src/libs/zbxsysinfo/linux/proc.c +++ b/src/libs/zbxsysinfo/linux/proc.c @@ -82,17 +82,22 @@ int PROC_MEMORY(const char *cmd, const char *param, unsigned flags, AGENT_RE usrinfo = getpwnam(usrname); if(usrinfo == NULL) { - /* incorrect user name */ + /* incorrect user name */ return SYSINFO_RET_FAIL; - } + } } } if(get_param(param, 3, mode, MAX_STRING_LEN) != 0) { - strscpy(mode, "sum"); + mode[0] = '\0'; } + if(mode[0] == '\0') + { + strscpy(mode, "sum"); + } + if(strcmp(mode,"avg") == 0) { do_task = DO_AVG; @@ -338,10 +343,15 @@ int PROC_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESUL } } - if(get_param(param, 3, procstat, MAX_STRING_LEN) != 0) - { - strscpy(procstat,"all"); - } + if(get_param(param, 3, procstat, MAX_STRING_LEN) != 0) + { + procstat[0] = '\0'; + } + + if(procstat[0] == '\0') + { + strscpy(procstat, "all"); + } if(strcmp(procstat,"run") == 0) { diff --git a/src/libs/zbxsysinfo/linux/swap.c b/src/libs/zbxsysinfo/linux/swap.c index 067ab90d..c86a2e46 100644 --- a/src/libs/zbxsysinfo/linux/swap.c +++ b/src/libs/zbxsysinfo/linux/swap.c @@ -24,6 +24,110 @@ #include "md5.h" + +int SYSTEM_SWAP_SIZE(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + +#define SWP_FNCLIST struct swp_fnclist_s +SWP_FNCLIST +{ + char *mode; + int (*function)(); +}; + + SWP_FNCLIST fl[] = + { + {"total", SYSTEM_SWAP_FREE}, + {"free", SYSTEM_SWAP_TOTAL}, + {0, 0} + }; + + char swapdev[MAX_STRING_LEN]; + char mode[MAX_STRING_LEN]; + int i; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 2) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, swapdev, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(swapdev[0] == '\0') + { + /* default parameter */ + sprintf(swapdev, "all"); + } + + if(strncmp(swapdev, "all", MAX_STRING_LEN)) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 2, mode, MAX_STRING_LEN) != 0) + { + mode[0] = '\0'; + } + + if(mode[0] == '\0') + { + /* default parameter */ + sprintf(mode, "free"); + } + + for(i=0; fl[i].mode!=0; i++) + { + if(strncmp(mode, fl[i].mode, MAX_STRING_LEN)==0) + { + return (fl[i].function)(cmd, param, flags, result); + } + } + + return SYSINFO_RET_FAIL; +} + +int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + char key[MAX_STRING_LEN]; + int ret; + + assert(result); + + memset(result, 0, sizeof(AGENT_RESULT)); + + if(num_param(param) > 1) + { + return SYSINFO_RET_FAIL; + } + + if(get_param(param, 1, key, MAX_STRING_LEN) != 0) + { + return SYSINFO_RET_FAIL; + } + + if(strcmp(key,"free") == 0) + { + ret = SYSTEM_SWAP_FREE(cmd, param, flags, result); + } + else if(strcmp(key,"total") == 0) + { + ret = SYSTEM_SWAP_TOTAL(cmd, param, flags, result); + } + else + { + ret = SYSINFO_RET_FAIL; + } + + return ret; +} + /* Solaris. */ #ifndef HAVE_SYSINFO_FREESWAP #ifdef HAVE_SYS_SWAP_SWAPTABLE @@ -184,38 +288,3 @@ int SYSTEM_SWAP_TOTAL(const char *cmd, const char *param, unsigned flags, AGENT_ #endif } -int OLD_SWAP(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) -{ - char key[MAX_STRING_LEN]; - int ret; - - assert(result); - - memset(result, 0, sizeof(AGENT_RESULT)); - - if(num_param(param) > 1) - { - return SYSINFO_RET_FAIL; - } - - if(get_param(param, 1, key, MAX_STRING_LEN) != 0) - { - return SYSINFO_RET_FAIL; - } - - if(strcmp(key,"free") == 0) - { - ret = SYSTEM_SWAP_FREE(cmd, param, flags, result); - } - else if(strcmp(key,"total") == 0) - { - ret = SYSTEM_SWAP_TOTAL(cmd, param, flags, result); - } - else - { - ret = SYSINFO_RET_FAIL; - } - - return ret; -} - -- cgit