Ad Widget

Collapse

Sms alert scripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mwai
    Junior Member
    • May 2009
    • 7

    #1

    Sms alert scripts

    I hav set up zabbix in an organization where the IT department is divided into groups. i.e we have system administrators, network administrators, itsecurity administrators and so on. I have created these guys in form of groups and i would like zabbix to send sms to the particular groups. My example here is restarting a server and test whether my sms script will send an sms alert only to the system admins group but it is not working. On the dashboard, it shows under actions it has sent but on my end i don't recieve anything. When i do a test with one of the scripts it is able to send but the second one i created is not able to. I would like to be helped where i am going wrong in the script since the scripts greps the condition based on the event and trigger.

    Below are the various scripts.

    Test SMS alert script (Working)

    Code:
    #!/bin/bash
    # Note: zabbix passes $1=receiptiant, $2=subject, $3=message to any script
    
    RECEIPIANT=$1
    SUBJECT=$2
    MESSAGE=$3
    
    HOSTNAME=' '
    PORT=13131
    USERNAME=' ' 
    PASSWORD=' '
    FROM=ZABBIX
    LYNX=/usr/bin/lynx
    TEXTENCODED=`echo -e "$SUBJECT $MESSAGE $(date)" | sed 's/ /%20/g'`
    
    $LYNX -dump "http://$HOSTNAME:$PORT/cgi-bin/sendsms?username=$USERNAME&password=$PASSWORD&from=$FROM&to=$RECEIPIANT&text=$TEXTENCODED"
    Script to Test Server Restart (Not Working)


    Code:
    #!/bin/bash
    # Note: zabbix passes $1=receiptiant, $2=subject, $3=message to any script
    
    RECEIPIANT=$1
    SUBJECT=$2
    MESSAGE=$3
    
    RESTARTED=`echo $1 $2 $3 | grep server restarted | wc -l`
    
    if [ $RESTARTED -ne 0 ]; then
    
    HOSTNAME=' '
    PORT=13131
    USERNAME=' '
    PASSWORD=' '
    FROM=ZABBIX
    LYNX=/usr/bin/lynx
    TEXTENCODED=`echo -e "$SUBJECT $MESSAGE $(date)" | sed 's/ /%20/g'`
    
    $LYNX -dump "http://$HOSTNAME:$PORT/cgi-bin/sendsms?username=$USERNAME&password=$PASSWORD&from=$FROM&to=$RECEIPIANT&text=$TEXTENCODED"
    fi
    The condition for a server restart as per the trigger is defined as average thus in the media, i have only activated NIWAHD

    I have stored the scripts in /etc/zabbix/alert.d/script.ds and so on

    Any idea where i am going wrong?
    Last edited by Mwai; 22-06-2009, 10:48. Reason: Forgot to include some comments
Working...