Ad Widget

Collapse

Calculated item ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxpower
    Member
    • Jul 2007
    • 31

    #1

    Calculated item ?

    Hi,

    is it possible to create a calculated item ?
    The idea is to calculate the CPU usage of a system with this formula:

    usage = idle * 100 / (user+nice+system+idle)

    this should give the cpu usage in percent.

    Now how do you make an item out of this ? I only have items for the single values system.cpu.util.[,user/nice/system/idle,avg1].
  • just2blue4u
    Senior Member
    • Apr 2006
    • 347

    #2
    Why don't you simply use the % free value?
    Code:
    system.cpu.util[,idle]
    100% - This value = total used CPU...
    Big ZABBIX is watching you!
    (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

    Comment

    • maxpower
      Member
      • Jul 2007
      • 31

      #3
      Hi just2blue4u,

      this is just 10% of an answer because the cpu usage was only an example. The question was how to calculate an item ?

      In reality i don't even get values for idle because Zabbix claims it is not supported (Solaris 10 not supported ?) so i don't know if the return value is in percent or something else and if it is not in percent the posted formular works. If it is in percent then maybe 100 - idle is the cpu usage but then again - how to make it an item ?

      Comment

      • swaterhouse
        Senior Member
        • Apr 2006
        • 268

        #4
        Cuurently items cannot have calculations. It has been asked for before but hasn't been done yet.

        Comment

        • Zapnix
          Junior Member
          • Apr 2006
          • 13

          #5
          because the last message dated from 2007, is this (no support for calculated values) still valid for recent versions of Zabbix?

          Cheers
          Zapnix

          Comment

          • nelsonab
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Sep 2006
            • 1233

            #6
            Yes, there is a workaround however to give this functionality.

            Using a userparameter you can write a script which will query the history table for the items in question and perform your calculation and then store this calculation as another item in the DB. The problem with this is your item does not get associated with the host you want as it will will likely have to be associated with the Zabbix server (where the script must run) and not the host you are running the calculation for.

            Option two is just write a userparameter which does the calculation on the host in question before sending the data to Zabbix. Yes this is not quite so useful if you ant to say add the bandwidth between four ports on a switch.
            RHCE, author of zbxapi
            Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
            Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

            Comment

            • Jun.Liu
              Member
              • Apr 2007
              • 91

              #7
              a simple approach for item calculation had been required many times and by many peoples. I do think the team should consider adding such functions.

              Comment

              • Calimero
                Senior Member
                • Nov 2006
                • 481

                #8
                Originally posted by nelsonab
                Using a userparameter you can write a script which will query the history table for the items in question and perform your calculation and then store this calculation as another item in the DB. The problem with this is your item does not get associated with the host you want as it will will likely have to be associated with the Zabbix server (where the script must run) and not the host you are running the calculation for.
                Instead of writing it as a userparameter, you can write an ExternalScript on the server side.

                Something like mycheck["hostname" "item1" "item2" "item3"] and then have that script query the database and do the math.

                As it's an external check, you can associate it with any machine though it will be run by zabbix_server.

                Comment

                Working...