summaryrefslogtreecommitdiffstats
path: root/src/zabbix_agent/sysinfo.c
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-09-22 07:47:42 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-09-22 07:47:42 +0000
commit84ef2d972ab484757d91fe78f1fe6c1fdda34f9a (patch)
treec11288cb85bf7907eebd90ae2c858817f5eb8172 /src/zabbix_agent/sysinfo.c
parent3f10c5e24cdbf46f432067f0ec1695141704aff4 (diff)
downloadzabbix-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
Diffstat (limited to 'src/zabbix_agent/sysinfo.c')
-rw-r--r--src/zabbix_agent/sysinfo.c63
1 files changed, 63 insertions, 0 deletions
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