Ad Widget

Collapse

Calculated Items in Templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SnIpY
    Junior Member
    • Jan 2017
    • 6

    #1

    Calculated Items in Templates

    I'm having a Template A with two items:

    Total Storage Space (External Check, Key: rds_stats.py["--metric","AllocatedStorage","--instance-id","{HOST.HOST}","--access-key","{$AWS_ACCESS_KEY}","--secret-key","{$AWS_SECRET_KEY}","--region","{$REGION}"])
    Available Storage Space (External Check, Key: rds_stats.py["--metric","FreeStorage","--instance-id","{HOST.HOST}","--access-key","{$AWS_ACCESS_KEY}","--secret-key","{$AWS_SECRET_KEY}","--region","{$REGION}"])

    Now I would like to add a third item to the same template, calculating the free storage space in percentage.

    According to the documentation https://www.zabbix.com/documentation...pes/calculated, it should look like this: 100*last("vfs.fs.size[/,free]")/last("vfs.fs.size[/,total]")

    So I've created this:

    100*last("rds_stats.py["--metric","FreeStorageSpace","--instance-id","{HOST.HOST}","--access-key","{$AWS_ACCESS_KEY}","--secret-key","{$AWS_SECRET_KEY}","--region","{$REGION}"]")/last("rds_stats.py["--metric","AllocatedStorage","--instance-id","{HOST.HOST}","--access-key","{$AWS_ACCESS_KEY}","--secret-key","{$AWS_SECRET_KEY}","--region","{$REGION}"]")
    But for some reason, this does not work. The error I am seeing is the following:
    Macro '{$AWS_ACCESS_KEY}' value is not numeric

    Any tips on how I an resolve this?
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    So on the begging you have:
    Code:
    last("rds_stats.py["--metric","FreeStorageSpace","<and_so_on>"
    so on first look it can be interpreted as last() arguments: "rds_stats.py[" then "FreeStorageSpace" ..
    Looks like messy quotations
    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

    • SnIpY
      Junior Member
      • Jan 2017
      • 6

      #3
      Made some changes and changed it into this:

      Code:
      100*last("rds_stats.py['--metric','FreeStorageSpace','--instance-id','{HOST.HOST}','--access-key','{$AWS_ACCESS_KEY}','--secret-key','{$AWS_SECRET_KEY}','--region','{$REGION}']")
      I did the same change to the item itself

      Now the error I am seeing is the following -> Item ... is not supported.

      I am seeing that error because the quotes need to be double for the item. If the quotes are not the same in the item and the calculated item, I am getting the Item not found item error.

      So whats the best approach here?
      1) I need double quotes in the formula, but can't seem to use them

      Comment

      • SnIpY
        Junior Member
        • Jan 2017
        • 6

        #4
        Backslashes to the resque!

        This eventually worked:

        Code:
        100*(last("rds_stats.py[\"--metric\",\"FreeStorageSpace\",\"--instance-id\",\"{HOST.HOST}\",\"--access-key\",\"{$AWS_ACCESS_KEY}\",\"--secret-key\",\"{$AWS_SECRET_KEY}\",\"--region\",\"{$REGION}\"]")/last("rds_stats.py[\"--metric\",\"AllocatedStorage\",\"--instance-id\",\"{HOST.HOST}\",\"--access-key\",\"{$AWS_ACCESS_KEY}\",\"--secret-key\",\"{$AWS_SECRET_KEY}\",\"--region\",\"{$REGION}\"]"))

        Comment

        • Alfista
          Senior Member
          • Mar 2017
          • 136

          #5
          Hi,
          I have similar problem with calculated Item and nothing helps to resolve it.
          I use:

          Code:
          100 - last("Template Synology:Syno.ssCpuIdle")
          where the Syno.ssCpuIdle is fully working item and its value is in %.

          Please can you help me what I do wrong, or how it works?
          Thanks.

          Comment

          Working...