diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-22 07:47:42 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-09-22 07:47:42 +0000 |
commit | 84ef2d972ab484757d91fe78f1fe6c1fdda34f9a (patch) | |
tree | c11288cb85bf7907eebd90ae2c858817f5eb8172 | |
parent | 3f10c5e24cdbf46f432067f0ec1695141704aff4 (diff) | |
download | zabbix-84ef2d972ab484757d91fe78f1fe6c1fdda34f9a.tar.gz zabbix-84ef2d972ab484757d91fe78f1fe6c1fdda34f9a.tar.xz zabbix-84ef2d972ab484757d91fe78f1fe6c1fdda34f9a.zip |
- added set of keys proc_cnt[*]
git-svn-id: svn://svn.zabbix.com/trunk@210 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/zabbix_agent/sysinfo.c | 63 | ||||
-rw-r--r-- | src/zabbix_agent/sysinfo.h | 1 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agent.c | 2 |
5 files changed, 67 insertions, 2 deletions
@@ -1,5 +1,6 @@ Changes for 1.0alpha11: + - added set of keys proc_cnt[*] - when pressing Acive in list of items, [all] selected unstead of [Server]. Fixed. - some triggers have incorrect status. Fixed. - global variable $ERROR_MSG will show details of operation failure diff --git a/configure.in b/configure.in index 43ef1791..cd4bff62 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,7 @@ AC_HEADER_STDC AC_CHECK_HEADERS(stdio.h stdlib.h string.h unistd.h netdb.h signal.h \ syslog.h time.h errno.h sys/types.h sys/stat.h netinet/in.h \ sys/socket.h ucd-snmp/ucd-snmp-config.h ucd-snmp/system.h \ - ucd-snmp/ucd-snmp-includes.h \ + ucd-snmp/ucd-snmp-includes.h dirent.h \ mtent.h fcntl.h sys/param.h sys/mount.h arpa/inet.h \ sys/vfs.h sys/pstat.h sys/sysinfo.h sys/statvfs.h \ sys/socket.h sys/loadavg.h netinet/in.h arpa/inet.h) diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c index 5a334569..b719e462 100644 --- a/src/zabbix_agent/sysinfo.c +++ b/src/zabbix_agent/sysinfo.c @@ -15,6 +15,9 @@ #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#ifdef HAVE_DIRENT_H + #include <dirent.h> +#endif /* Linux */ #ifdef HAVE_SYS_VFS_H #include <sys/vfs.h> @@ -64,6 +67,16 @@ COMMAND commands[]= { + {"proc_cnt[apache]" ,PROCCNT, "apache"}, + {"proc_cnt[inetd]" ,PROCCNT, "inetd"}, + {"proc_cnt[mysqld]" ,PROCCNT, "mysqld"}, + {"proc_cnt[syslogd]" ,PROCCNT, "syslogd"}, + {"proc_cnt[sshd]" ,PROCCNT, "sshd"}, + + {"proc_cnt[zabbix_agentd]" ,PROCCNT, "zabbix_agentd"}, + {"proc_cnt[zabbix_suckerd]" ,PROCCNT, "zabbix_suckerd"}, + {"proc_cnt[zabbix_trapperd]" ,PROCCNT, "zabbix_trapperd"}, + {"memory[total]" ,TOTALMEM, 0}, {"memory[shared]" ,SHAREDMEM, 0}, {"memory[buffers]" ,BUFFERSMEM, 0}, @@ -220,6 +233,56 @@ float FILESIZE(const char * filename) return FAIL; } +float PROCCNT(const char * procname) +{ + DIR *dir; + struct dirent *entries; + struct stat buf; + char filename[512]; + char line[512]; + char *name; + + FILE *f; + + int proccount=0; + + dir=opendir("/proc"); + while((entries=readdir(dir))!=NULL) + { + strcpy(filename,"/proc/"); + strcat(filename,entries->d_name); + strcat(filename,"/status"); + + if(stat(filename,&buf)==0) + { + fflush(stdout); + f=fopen(filename,"r"); + if(f==NULL) + { + continue; + } + fgets(line,512,f); + fclose(f); + +/* sscanf(line,"%s\t%s\n",line,name); + printf("%s\n",name); + fflush(stdout);*/ + + name=(char *)strtok(line,"\t"); + name=(char *)strtok(NULL,"\t"); + + name[strlen(name)-1]=0; + + if(strcmp(procname,name)==0) + { + proccount++; + } + } + } + closedir(dir); + return (float)proccount; +} + float INODE(const char * mountPoint) { #ifdef HAVE_SYS_STATVFS_H diff --git a/src/zabbix_agent/sysinfo.h b/src/zabbix_agent/sysinfo.h index 9c125700..d0819ff5 100644 --- a/src/zabbix_agent/sysinfo.h +++ b/src/zabbix_agent/sysinfo.h @@ -20,6 +20,7 @@ float DISK_WIO(void); float DISK_RBLK(void); float DISK_WBLK(void); float PING(void); +float PROCCNT(const char *procname); float PROCCOUNT(void); float PROCLOAD(void); float PROCLOAD5(void); diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index d0d276d5..c4e77e3a 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -1,4 +1,4 @@ -/* #define TEST_PARAMETERS */ +#define TEST_PARAMETERS #include "config.h" |