diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-29 11:23:01 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-29 11:23:01 +0000 |
commit | cbe396976c682e6534f8f42e497e41f2942371d6 (patch) | |
tree | aa6b077f5806e6e9cbd9f1c6e1beb67dae888d7e /src/zabbix_agent | |
parent | a61969dfc1d23d6ff823c60e4884ff0cc3fa8a81 (diff) | |
download | zabbix-cbe396976c682e6534f8f42e497e41f2942371d6.tar.gz zabbix-cbe396976c682e6534f8f42e497e41f2942371d6.tar.xz zabbix-cbe396976c682e6534f8f42e497e41f2942371d6.zip |
- added support of "system.cpu.util[]" key for HPUX (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2914 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_agent')
-rw-r--r-- | src/zabbix_agent/cpustat.c | 63 | ||||
-rw-r--r-- | src/zabbix_agent/diskdevices.c | 4 | ||||
-rw-r--r-- | src/zabbix_agent/interfaces.c | 4 | ||||
-rw-r--r-- | src/zabbix_agent/zabbix_agentd.c | 4 |
4 files changed, 54 insertions, 21 deletions
diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c index d733af46..862b9abb 100644 --- a/src/zabbix_agent/cpustat.c +++ b/src/zabbix_agent/cpustat.c @@ -284,45 +284,66 @@ void add_values_cpustat(int now,float cpu_user,float cpu_system,float cpu_nice,f void collect_stats_cpustat(FILE *outfile) { - FILE *file; - - char *s; - char line[MAX_STRING_LEN]; - int i; - int now; - float cpu_user, cpu_nice, cpu_system, cpu_idle; - /* Must be static */ - static int initialised=0; + static int initialised = 0; + int now = 0; + float cpu_user, cpu_nice, cpu_system, cpu_idle; - if( 0 == initialised) +#if defined(HAVE_PROC_STAT) + + FILE *file; + char line[MAX_STRING_LEN]; + +#elif defined(HAVE_SYS_PSTAT_H) /* HAVE_PROC_STAT */ + + struct pst_dynamic stats; + +#else /* HAVE_SYS_PSTAT_H */ + + return; + +#endif + + if(!initialised) { init_stats_cpustat(); - initialised=1; + initialised = 1; } - now=time(NULL); + now = time(NULL); - file=fopen("/proc/stat","r"); +#if defined(HAVE_PROC_STAT) + + file = fopen("/proc/stat","r"); if(NULL == file) { fprintf(stderr, "Cannot open [%s] [%s]\n","/proc/stat", strerror(errno)); return; } - i=0; + cpu_user = cpu_nice = cpu_system = cpu_idle = -1; while(fgets(line,1024,file) != NULL) { - if( (s=strstr(line,"cpu ")) == NULL) - continue; + if(strstr(line,"cpu ") == NULL) continue; - s=line; - - sscanf(s,"cpu %f %f %f %f",&cpu_user, &cpu_nice, &cpu_system, &cpu_idle); - add_values_cpustat(now,cpu_user, cpu_system, cpu_nice, cpu_idle); + sscanf(line, "cpu %f %f %f %f", &cpu_user, &cpu_nice, &cpu_system, &cpu_idle); break; } - fclose(file); + if(cpu_user < 0) + return; + +#elif defined(HAVE_SYS_PSTAT_H) /* HAVE_PROC_STAT */ + + pstat_getdynamic(&stats, sizeof( struct pst_dynamic ), 1, 0 ); + cpu_user = (float)stats.psd_cpu_time[CP_USER]; + cpu_nice = (float)stats.psd_cpu_time[CP_SYS]; + cpu_system = (float)stats.psd_cpu_time[CP_NICE]; + cpu_idle = (float)stats.psd_cpu_time[CP_IDLE]; + +#endif /* HAVE_SYS_PSTAT_H */ + + add_values_cpustat(now,cpu_user, cpu_system, cpu_nice, cpu_idle); report_stats_cpustat(outfile, now); + } diff --git a/src/zabbix_agent/diskdevices.c b/src/zabbix_agent/diskdevices.c index cd2df187..8b2f91da 100644 --- a/src/zabbix_agent/diskdevices.c +++ b/src/zabbix_agent/diskdevices.c @@ -443,6 +443,8 @@ void add_values_diskdevices(int now,int major,int diskno,float read_io_ops,float void collect_stats_diskdevices(FILE *outfile) { +#ifdef HAVE_PROC_STAT + FILE *file; char *s,*s2; @@ -506,4 +508,6 @@ void collect_stats_diskdevices(FILE *outfile) fclose(file); report_stats_diskdevices(outfile, now); + +#endif /* HAVE_PROC_STAT */ } diff --git a/src/zabbix_agent/interfaces.c b/src/zabbix_agent/interfaces.c index 7cb6c402..446d0ce0 100644 --- a/src/zabbix_agent/interfaces.c +++ b/src/zabbix_agent/interfaces.c @@ -320,6 +320,8 @@ void add_values_interfaces(int now,char *interface,float value_sent,float value_ void collect_stats_interfaces(FILE *outfile) { +#ifdef HAVE_PROC_NET_DEV + FILE *file; char *s; @@ -389,4 +391,6 @@ void collect_stats_interfaces(FILE *outfile) fclose(file); report_stats_interfaces(outfile, now); + +#endif /* HAVE_PROC_NET_DEV */ } diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index c6293e00..de3cc0bc 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -612,6 +612,9 @@ int main(int argc, char **argv) setproctitle("main process"); #endif + collect_statistics(); + +/* #ifdef HAVE_PROC_NET_DEV collect_statistics(); #else @@ -620,6 +623,7 @@ int main(int argc, char **argv) pause(); } #endif +*/ return SUCCEED; } |