summaryrefslogtreecommitdiffstats
path: root/src/zabbix_agent/sysinfo.c
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-09-26 13:37:27 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-09-26 13:37:27 +0000
commit966810d3151c097803ad41b9d63efafc9493d0a6 (patch)
treebdaff784b697b8500bab5cc8296dc2fea11ae934 /src/zabbix_agent/sysinfo.c
parent4d3082cd6d40905230e86b1ffff475ffcf3ec401 (diff)
downloadzabbix-966810d3151c097803ad41b9d63efafc9493d0a6.tar.gz
zabbix-966810d3151c097803ad41b9d63efafc9493d0a6.tar.xz
zabbix-966810d3151c097803ad41b9d63efafc9493d0a6.zip
Fixes in function PROCCNT.
git-svn-id: svn://svn.zabbix.com/trunk@218 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_agent/sysinfo.c')
-rw-r--r--src/zabbix_agent/sysinfo.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c
index 04b332af..9a31a51f 100644
--- a/src/zabbix_agent/sysinfo.c
+++ b/src/zabbix_agent/sysinfo.c
@@ -241,7 +241,7 @@ float PROCCNT(const char * procname)
struct stat buf;
char filename[512];
char line[512];
- char *name;
+ char name1[256],name2[256];
FILE *f;
@@ -265,19 +265,26 @@ float PROCCNT(const char * procname)
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++;
- }
+ if(sscanf(line,"%s\t%s\n",name1,name2)==2)
+ {
+ if(strcmp(name1,"Name:") == 0)
+ {
+ if(strcmp(procname,name2)==0)
+ {
+ proccount++;
+ }
+ }
+ else
+ {
+ closedir(dir);
+ return FAIL;
+ }
+ }
+ else
+ {
+ closedir(dir);
+ return FAIL;
+ }
}
}
closedir(dir);