Ad Widget

Collapse

Initiate Action, pass variables, and execute script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • itguy12
    Junior Member
    • Jun 2011
    • 8

    #1

    Initiate Action, pass variables, and execute script

    I have searched the forum and tested as much as I can, but I now must turn to the experts for direct help.

    I want to create an action that passes variables from Zabbix to a script on the server. This script will make the necessary API calls to our issue tracking system for agents to look at. Based on my reading, here's what I thought was supposed to work:
    1. Place script in path indicated in AlertScriptsPath
    2. Create a new Media Type with script name (my-custom-script.sh)
    3. Create a new User (robot) and add Media with new Type. Set Send To as null.
    4. Create a new Action that sends a message to my new user. Place the variables in order the script is expecting them in Subject and Message. In my case, I want to keep it simple:
      Subject: {HOSTNAME}
      Message: {ITEM.LASTVALUE} {TRIGGER.NSEVERITY}


    This is not working. I also added another recipient (my email) to the action, and I receive the message okay. If I execute the custom script as the zabbix user from the server, it works as well (the script ignores the $1 input):
    Code:
    sudo su zabbix -c "/usr/local/bin/zabbix_scripts/my-custom-script.sh null host.domain.tld ERRORmsg 3"
    What am I doing wrong here?
  • Davidus
    Senior Member
    • Dec 2010
    • 281

    #2
    Ok, this worked for me

    On my RHEL 5.5, I added shell script file in /home/zabbix/bin
    Made script executable chmod +x my_file

    Zabbix side:

    Created new media type
    Description: test
    Type: scripts
    Name: my_file

    Also created new user and assigned test media type to it
    Created new action and said that my new user going to receive notifications. This is it, Its working!

    Comment

    • itguy12
      Junior Member
      • Jun 2011
      • 8

      #3
      Yes, you are correct. I adjusted a few components and found success. I am using LDAP for user management and created a new 'local' user in Zabbix (the user did not exist in the LDAP directory) and tried to assign the script/media type/notification to that 'robot' user. This seems to have been the cause of my problem. Once I changed the script/media type to my username and tested the action, it worked as expected.

      So now my question switches to the user management in Zabbix. If I use an LDAP directory for authentication, can I not use local users for the use case described above? Is there any documentation pertaining to user management with LDAP involved?

      Comment

      Working...