Ad Widget

Collapse

Creating alert with bash exit code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yatta
    Member
    • Feb 2022
    • 82

    #1

    Creating alert with bash exit code

    Hi,
    I'm trying to create a basic alert regarding to a command's exit code.

    Command is just greps output of a script;

    "Item" is like below;

    Code:
    #!/bin/bash
    echo {$SSH.USER.PASSWORD} | sudo -S sh /script/linux_check.sh | grep "Down"
    So if the command catches "down", exit code is = 0

    And the trigger expression is like below;


    Code:
    last(/linux_instance_check.sh/ssh.run[cmd1.command])=0
    But it's not creating alert.

    Is the trigger expression should be something else?

    Thanks!
  • yatta
    Member
    • Feb 2022
    • 82

    #2
    echo $? solved the problem!

    Comment

    • yatta
      Member
      • Feb 2022
      • 82

      #3
      Hi,
      I have some another problem, it seems Zabbix creates fake alerts as I understand.

      I created an SSH Item with the command below;


      Code:
        #!/bin/bash
        echo {$SSH.USER.PASSWORD} | sudo -S sh /script/linux_check.sh | grep "Down" | echo $?
      And if I run this command on the server manually, output is 1, that means there is no "Down" text on the output.

      And I created a trigger like below;

      Click image for larger version  Name:	Capture.jpg Views:	0 Size:	97.4 KB ID:	443615

      So if the output is other than 0, no alert should be created but Zabbix creates the alert!

      Any idea why?

      Comment

      • yatta
        Member
        • Feb 2022
        • 82

        #4
        Any help why Zabbix creating fake alert?

        Comment


        • Hamardaban
          Hamardaban commented
          Editing a comment
          Check what data the item received (in the latest data)
          Last edited by Hamardaban; 26-04-2022, 10:40.
      Working...