Ad Widget

Collapse

Creating alert from bash script

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

    #1

    Creating alert from bash script

    Hi,
    I want to create an alert from a bash script's output.
    If the script output has some specific text, then I'll send an email.

    I guess I can use "SSH checks" for this but I wonder is there any other mechanism exist on Zabbix? For example is Zabbix agent can run this bash script on the target server?

    Thanks!
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    Yes, zabbix agent can run the bash script as a custom item.

    Comment

    • yatta
      Member
      • Feb 2022
      • 82

      #3
      Thanks for te reply Timi,
      I have one more question: in the docs below it says "STEP 2 : Add the command to zabbix_agentd.conf"



      So I want to run a command at around 30 servers. Should I add this parameter to these 30 servers' "zabbix_agentd.conf" file, or only Zabbix server's "zabbix_agentd.conf" file?

      Regards.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        To each agents config file. Otherwise that agent does not know, what to do.

        Comment

        • Singularity
          Member
          • Aug 2020
          • 81

          #5
          I created tons of bash as well as python scripts for the client I work for. Zabbix can directly/indirectly execute any script.
          If it is bash script then define UserParameter inside the zabbix-agent.d folder maybe in custom.conf file. UserParameter = key[*], <path to bash script> '$1' '$2' ... n number of parameters
          If it not a bash script then work around is create the bash script which executes the required script. By this way the UserParameter always executes a bash script .
          Note : For scripts that takes more than 30 seconds to execute, it is always better to go with zabbix_sender.

          Comment

          • yatta
            Member
            • Feb 2022
            • 82

            #6
            Thanks cyber&singularity! I'll follow with custum items.

            Comment

            Working...