Ad Widget

Collapse

Different output for CPU utilisation using TOP command and proc.cpu.util item key.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paras
    Junior Member
    • Aug 2017
    • 7

    #1

    Different output for CPU utilisation using TOP command and proc.cpu.util item key.

    Hello Guyz,

    I am confused between different outputs I am getting for CPU utilisation .
    I am using fedora core 25, here is my 'lscpu' output-

    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    CPU(s): 4
    On-line CPU(s) list: 0-3
    Thread(s) per core: 2
    Core(s) per socket: 2
    Socket(s): 1
    NUMA node(s): 1
    Vendor ID: GenuineIntel
    CPU family: 6
    Model: 142
    Model name: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    Stepping: 9
    CPU MHz: 2469.616
    CPU max MHz: 2500.0000
    CPU min MHz: 400.0000
    BogoMIPS: 5424.00
    Virtualization: VT-x
    L1d cache: 32K
    L1i cache: 32K
    L2 cache: 256K
    L3 cache: 3072K
    NUMA node0 CPU(s): 0-3.

    Using top command I am getting CPU util for firefox as between 0.7 - 1.0 %-

    2461 zealapp 20 0 2682964 388604 163548 S 1.0 4.8 12:47.75 firefox

    Using Item Key

    proc.cpu.util[firefox] , I am getting 4.0 %.

    Both should show same output right ?
    Can anyone please throw some light ?
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    Originally posted by Paras
    Using top command I am getting CPU util for firefox as between 0.7 - 1.0 %-

    2461 zealapp 20 0 2682964 388604 163548 S 1.0 4.8 12:47.75 firefox

    Using Item Key

    proc.cpu.util[firefox] , I am getting 4.0 %.

    Both should show same output right ?
    Yes but only if method of obtainig metric data is exactly the same.
    Look on src/libs/zbxsysinfo/linux/proc.c::PROC_CPU_UTIL function in zabbix source code where in body of this function you can find comment:
    Code:
            /* proc.cpu.util[<procname>,<username>,(user|system),<cmdline>,(avg1|avg5|avg15)] */
            /*                   0          1           2            3             4          */
    and:
    Code:
            /* utilization type parameter (user|system) */
            if (NULL == (tmp = get_rparam(request, 2)) || '\0' == *tmp || 0 == strcmp(tmp, "total"))
    You are passing only first parameter and few lines below you can find another part:
    Code:
            /* mode parameter (avg1|avg5|avg15) */
            if (NULL == (tmp = get_rparam(request, 4)) || '\0' == *tmp || 0 == strcmp(tmp, "avg1"))
    Which means that by using key "proc.cpu.util[firefox]" you will be measuring total CPU usage of all firefox proceesses (system+user) and it will be avg1.

    First: definitely top does not show you CPU avg1 per process but between samples.
    Second: zabbix metric aggregates total CPU usage of all firefox processes together.
    So as long as methods of obtaining data about process(es) are different by definition you will never see the same monitoring data.
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment

    • Paras
      Junior Member
      • Aug 2017
      • 7

      #3
      Thankyou, I got it now

      Comment

      Working...