Ad Widget

Collapse

Creating a trigger for a text-based item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nasomers
    Junior Member
    • Dec 2016
    • 8

    #1

    Creating a trigger for a text-based item

    Hello all!

    I have created an item for updates/packages for Linux systems, which returns a text list of the packages and respective version.

    I want to create a trigger that alerts when this item returns any text, but I can't get a trigger to work. I know that the item works as when I visit "Latest Data" I can see the text list of packages there.

    Thanks so much!

    Here's what I'm using for the item

    Code:
    UserParameter=system.sw.debianupdates-list,apt-get dist-upgrade -s  |sed -n 's/^Inst \(.*\) (.*/\1,/p' | tr '\n' ' '
  • batchenr
    Senior Member
    • Sep 2016
    • 440

    #2
    Originally posted by nasomers
    Hello all!

    I have created an item for updates/packages for Linux systems, which returns a text list of the packages and respective version.

    I want to create a trigger that alerts when this item returns any text, but I can't get a trigger to work. I know that the item works as when I visit "Latest Data" I can see the text list of packages there.

    Thanks so much!

    Here's what I'm using for the item

    Code:
    UserParameter=system.sw.debianupdates-list,apt-get dist-upgrade -s  |sed -n 's/^Inst \(.*\) (.*/\1,/p' | tr '\n' ' '
    you can look at this direction -
    set the trigger with .nodata=0 or .nodata=1 for this item

    for me the easiest way is to create a bash script

    #!/bin/bash

    CHECK=$(apt-get dist-upgrade -s |sed -n 's/^Inst \(.*\) (.*/\1,/p' | tr '\n' ' ')

    if [[ -n $CHECK ]]; then
    echo 0
    else
    echo 1
    fi
    and then set the trigger like this :
    {server.office.local:system.sw.debianupdates-list.last(0)}=0

    and if the script returns 0 when the check command is not null it will fire a trigger
    Last edited by batchenr; 25-01-2017, 15:27.

    Comment

    • nasomers
      Junior Member
      • Dec 2016
      • 8

      #3
      Originally posted by batchenr
      you can look at this direction -
      set the trigger with .nodata=0 or .nodata=1 for this item
      Sorry, new to Zabbix. Could you expand on this a little? Thanks!

      Comment

      • batchenr
        Senior Member
        • Sep 2016
        • 440

        #4
        Originally posted by nasomers
        Sorry, new to Zabbix. Could you expand on this a little? Thanks!
        i never set a trigger for this but i think you can set a trigger like
        {server.office.local:system.sw.debianupdates.nodat a(600)}=0
        it will fire the trigger - but again im no expert either
        i will always prefer making my own scripts.

        Comment

        • nasomers
          Junior Member
          • Dec 2016
          • 8

          #5
          Originally posted by batchenr
          i never set a trigger for this but i think you can set a trigger like


          it will fire the trigger - but again im no expert either
          i will always prefer making my own scripts.
          Unfortunately I get an error trying to save that, says the trigger expression is invalid and cannot be used.

          Comment

          • nasomers
            Junior Member
            • Dec 2016
            • 8

            #6
            I want the trigger to list the packages in the actual alert on the dashboard. I have it configured now to alert when there are updates available at all and how many, but I want to know what the packages are so I can discern if they may be service affecting or not.

            Thanks

            Comment

            • batchenr
              Senior Member
              • Sep 2016
              • 440

              #7
              Originally posted by nasomers
              I want the trigger to list the packages in the actual alert on the dashboard. I have it configured now to alert when there are updates available at all and how many, but I want to know what the packages are so I can discern if they may be service affecting or not.

              Thanks
              you cant with the dash board because if you will have a
              long string it will cut a half of it.

              Comment

              Working...