Ad Widget

Collapse

Zabbix 1.5.5 build 5973 - CPU wait state (system.cpu.util[,wait,avg1] not supported

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • disgruntleddutch
    Member
    • Oct 2006
    • 34

    #1

    Zabbix 1.5.5 build 5973 - CPU wait state (system.cpu.util[,wait,avg1] not supported

    With the agent compiled on RHEL4 and RHEL5 for some reason the agent is reporting that system.cpu.util[,idle,avg1] is not supported whereas the other CPU states are supported (system.cpu.util[,idle,avg1], system.cpu.util[,user,avg1], system.cpu.util[,nice,avg1], system.cpu.util[,system,avg1])

    Is this intentional or a bug?
  • IT team
    Junior Member
    • Dec 2008
    • 1

    #2
    I don't know if it was intentional to not support system.cpu.util[,wait,avg1], but I wrote a small fix, because I needed this feature too.

    I had a look to the source code, and I found very surprising that there was no mention at all about the wait state!

    Here is the diff :

    src/libs/zbxsysinfo/linux/cpu.c.diff
    156a157,163
    > else if( 0 == strcmp(type,"wait"))
    > {
    > if( 0 == strcmp(mode,"avg1")) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].wait1)
    > else if( 0 == strcmp(mode,"avg5")) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].wait5)
    > else if( 0 == strcmp(mode,"avg15")) SET_DBL_RESULT(result, collector->cpus.cpu[cpu_num].wait15)
    > else return SYSINFO_RET_FAIL;
    > }


    src/zabbix_agent/cpustat.h.diff
    73a74
    > zbx_uint64_t h_wait[MAX_CPU_HISTORY];
    90a92,94
    > double wait1;
    > double wait5;
    > double wait15;


    src/zabbix_agent/cpustat.c.diff
    186c186,187
    < zbx_uint64_t *cpu_interrupt
    ---
    > zbx_uint64_t *cpu_interrupt,
    > zbx_uint64_t *cpu_wait
    228c229
    < *cpu_user = *cpu_system = *cpu_nice = *cpu_idle = -1;
    ---
    > *cpu_user = *cpu_system = *cpu_nice = *cpu_idle = *cpu_wait = -1;
    237c238
    < sscanf(line, "%*s " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64, cpu_user, cpu_nice, cpu_system, cpu_idle);
    ---
    > sscanf(line, "%*s " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64 " " ZBX_FS_UI64, cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_wait);
    253a255
    > *cpu_wait = (zbx_uint64_t)stats.psd_cpu_time[CP_WAIT];
    266a269
    > *cpu_wait = (zbx_uint64_t)psp.psp_cpu_time[CP_WAIT];
    287a291
    > *cpu_wait = (zbx_uint64_t)cp_time[CP_WAIT];
    308a313
    > *cpu_wait = (zbx_uint64_t)all_states[CP_WAIT];
    327a333
    > *cpu_wait = (zbx_uint64_t)one_states[CP_WAIT];
    348c354,355
    < zbx_uint64_t cpu_interrupt
    ---
    > zbx_uint64_t cpu_interrupt,
    > zbx_uint64_t cpu_wait
    356a364
    > wait = 0, wait1 = 0, wait5 = 0, wait15 = 0,
    374a383
    > curr_cpu->h_wait[i] = wait = cpu_wait;
    376c385
    < all = cpu_user + cpu_system + cpu_nice + cpu_idle + cpu_interrupt;
    ---
    > all = cpu_user + cpu_system + cpu_nice + cpu_idle + cpu_wait + cpu_interrupt;
    394a404
    > wait ## t = curr_cpu->h_wait[i]; \
    396c406
    < all ## t = user ## t + system ## t + nice ## t + idle ## t + interrupt ## t; \
    ---
    > all ## t = user ## t + system ## t + nice ## t + idle ## t + wait ## t + interrupt ## t; \
    433a444,447
    >
    > CALC_CPU_LOAD(wait, 1);
    > CALC_CPU_LOAD(wait, 5);
    > CALC_CPU_LOAD(wait, 15);
    553c567
    < zbx_uint64_t cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_interrupt;
    ---
    > zbx_uint64_t cpu_user, cpu_nice, cpu_system, cpu_idle, cpu_interrupt, cpu_wait;
    557c571
    < if(0 != get_cpustat(i, &now, &cpu_user, &cpu_system, &cpu_nice, &cpu_idle, &cpu_interrupt))
    ---
    > if(0 != get_cpustat(i, &now, &cpu_user, &cpu_system, &cpu_nice, &cpu_idle, &cpu_interrupt, &cpu_wait))
    560c574
    < apply_cpustat(pcpus, i, now, cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_interrupt);
    ---
    > apply_cpustat(pcpus, i, now, cpu_user, cpu_system, cpu_nice, cpu_idle, cpu_interrupt, cpu_wait)

    Hope it was what you needed.

    Comment

    • mvrk
      Member
      • Oct 2008
      • 71

      #3
      Can you make a .patch?

      Making these alterations manually takes too many time...

      Comment

      Working...