diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-08-11 10:56:39 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-08-11 10:56:39 +0000 |
| commit | 33ee73db866cc55bd83c4b6d9b6b7c7bd50defca (patch) | |
| tree | 30227aaaa8267da07cfe39d3b3e9b4fb86557bf7 /src | |
| parent | 0e72836bd88de7b81a3851e0ee179668108b28ad (diff) | |
| download | zabbix-33ee73db866cc55bd83c4b6d9b6b7c7bd50defca.tar.gz zabbix-33ee73db866cc55bd83c4b6d9b6b7c7bd50defca.tar.xz zabbix-33ee73db866cc55bd83c4b6d9b6b7c7bd50defca.zip | |
- support of proc_cnt[*] under Solaris. Thanks to Marc Ledent (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@894 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src')
| -rw-r--r-- | src/zabbix_agent/sysinfo.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/zabbix_agent/sysinfo.c b/src/zabbix_agent/sysinfo.c index ec5a59c9..d5ab2282 100644 --- a/src/zabbix_agent/sysinfo.c +++ b/src/zabbix_agent/sysinfo.c @@ -48,6 +48,12 @@ #ifdef HAVE_SYS_STATVFS_H #include <sys/statvfs.h> #endif +/* Solaris */ +#ifdef HAVE_SYS_PROCFS_H +/* This is needed to access the correct procfs.h definitions */ + #define _STRUCTURED_PROC 1 + #include <sys/procfs.h> +#endif #ifdef HAVE_SYS_LOADAVG_H #include <sys/loadavg.h> #endif @@ -710,8 +716,56 @@ double PROCCNT(const char * procname) closedir(dir); return (double)proccount; #else +#ifdef HAVE_PROC_0_PSINFO + DIR *dir; + struct dirent *entries; + struct stat buf; + char filename[MAX_STRING_LEN+1]; + + int fd; +/* In the correct procfs.h, the structure name is psinfo_t */ + psinfo_t psinfo; + + int proccount=0; + + dir=opendir("/proc"); + while((entries=readdir(dir))!=NULL) + { + strncpy(filename,"/proc/",MAX_STRING_LEN); + strncat(filename,entries->d_name,MAX_STRING_LEN); + strncat(filename,"/psinfo",MAX_STRING_LEN); + + if(stat(filename,&buf)==0) + { + fd = open (filename, O_RDONLY); + if (fd != -1) + { + if (read (fd, &psinfo, sizeof(psinfo)) == -1) + { + closedir(dir); + return FAIL; + } + else + { + if(strcmp(procname,psinfo.pr_fname)==0) + { + proccount++; + } + } + close (fd); + } + else + { + continue; + } + } + } + closedir(dir); + return (double)proccount; +#else return FAIL; #endif +#endif } double get_stat(const char *key) |
