Ad Widget

Collapse

UserParameter - CPU load

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hostit1
    Junior Member
    • Sep 2006
    • 6

    #1

    UserParameter - CPU load

    Hello,

    I hope that someone can shed some light and maybe offer some suggestions.
    I am trying to get the cpu load in a percentage format and I am able to do this via command line. The syntax is a little different for a single processor and a multiple processor and it does not round off (no big deal).

    So I am testing my syntax in the UserParameter settings of the zabbix_agentd.conf file.

    I am able to get the mysql.version to work, but I am not able to get the procload's to work (single.procload or multiple.procload), so I thought that I would try something simple and I added the w command just to test thiings out. Does anyone know how I can get the procloads to show up in zabbix. I created the configuration item to be a numeric float and multiplier to be set at 1.

    Any suggestions would be greatly appreciated.

    Sincerely,

    Tim Rice

    UserParameter=mysql.version,mysql -V
    UserParameter=test.what,w
    UserParameter=single.procload,expr 100 - `top -b -n 2 -d 1 | grep Cpu | tail -1 | awk '{print $8}' | sed -e 's/.%//g' | tr -d .`
    UserParameter=multiple.procload,expr 100 - `top -Cb -n 2 -d 1 | grep -A 1 "CPU states" | tail -1 | awk '{print $8}' | sed -e 's/.%//g' | tr -d .`
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    ZABBIX 1.1.2:

    UserParameter=single.procload,expr 100 - `top -b -n 2 -d 1 | grep Cpu | tail -1 | awk '{print $$8}' | sed -e 's/.%//g' | tr -d .`
    UserParameter=multiple.procload,expr 100 - `top -Cb -n 2 -d 1 | grep -A 1 "CPU states" | tail -1 | awk '{print $$8}' | sed -e 's/.%//g' | tr -d .`

    ZABBIX 1.1, 1.1.1:

    UserParameter=single.procload,expr 100 - `top -b -n 2 -d 1 | grep Cpu | tail -1 | awk '{print $ 8}' | sed -e 's/.%//g' | tr -d .`
    UserParameter=multiple.procload,expr 100 - `top -Cb -n 2 -d 1 | grep -A 1 "CPU states" | tail -1 | awk '{print $ 8}' | sed -e 's/.%//g' | tr -d .`
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • hostit1
      Junior Member
      • Sep 2006
      • 6

      #3
      Thanks a bunch! I will test it out and update the board with the results.

      Sincerely,

      Tim Rice

      Comment

      • hostit1
        Junior Member
        • Sep 2006
        • 6

        #4
        I did test the version 1.1 and everything WORKS great!

        Thanks for the info.

        You may want to add the below to your cookbook as it seems to be giving accurate CPU details.


        UserParameter=single.procload,expr 100 - `top -b -n 2 -d 1 | grep Cpu | tail -1 | awk '{print $$8}' | sed -e 's/.%//g' | tr -d .`
        UserParameter=multiple.procload,expr 100 - `top -Cb -n 2 -d 1 | grep -A 1 "CPU states" | tail -1 | awk '{print $$8}' | sed -e 's/.%//g' | tr -d .`

        ZABBIX 1.1, 1.1.1:

        UserParameter=single.procload,expr 100 - `top -b -n 2 -d 1 | grep Cpu | tail -1 | awk '{print $ 8}' | sed -e 's/.%//g' | tr -d .`
        UserParameter=multiple.procload,expr 100 - `top -Cb -n 2 -d 1 | grep -A 1 "CPU states" | tail -1 | awk '{print $ 8}' | sed -e 's/.%//g' | tr -d .`

        Comment

        • RandySpinaGE
          Member
          • Jun 2006
          • 57

          #5
          FYI - If you want to use Floating Point

          IDLE=`sar -A -u 1 2 | grep Average | grep -A 1 "%idle" | tail -n 1 | awk -F" " '{print $7}'`; echo $IDLE | awk '{print 100.0 - $1}'

          I dont know if UserParameter can use the semicolon..Actually I use a tiny script.

          Comment

          • hostit1
            Junior Member
            • Sep 2006
            • 6

            #6
            Thanks so much for the direction.

            Didn't think of sar, but your way is much better than top. I also noticed that some machines report the CPU usage in different columns.

            UserParameter=cpu.load,sar -A -u 1 2 | grep Average | grep -A 1 "%idle" | tail -n 1 | awk -F" " '{print 100.0 - $7}'

            I created an ITEM in Unix_t called CPU Percentage Load as a "Zabbix Agent"
            The Key is: cpu.load[,avg10]
            Type of Information: Numeric (float)
            Multiplier of 1 used (Rather have it set than unset)
            Update interval (30 seconds)

            Then I created a trigger of:
            {Unix_t:cpu.load[,avg10].last(1)}>50
            (I am not very good at expressions, but it seems to work)

            Thanks again for the help.

            Tim Rice

            Comment

            • Kristjan
              Junior Member
              • Jan 2006
              • 5

              #7
              Tried similar user parameter but when starting or stopping the agent I always get this error: "/etc/zabbix/zabbix_agentd.conf: line 85: -P: command not found"

              I feel like turning blind..

              The user pararmeter is like this:

              UserParameter=cpu.four,sar -P ALL 1 2 | grep Average | grep -A 5 "%idle" | tail -n 1 | awk -F " " '{print 100.0 - $ 7}'

              and I am using v 1.1.1 on Redhat Enterprise Linux 4. Got the same error when trying the top version.

              Comment

              • Kristjan
                Junior Member
                • Jan 2006
                • 5

                #8
                fixed it. Moving the sar command to shell script and using it for UserParameter worked better for some reason

                Comment

                Working...