Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: [RESOLVED] SMS Alert with Weboob

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    [RESOLVED] SMS Alert with Weboob

    Hello all,

    When an host is down, we would like to have an sms send via Shinken. I know there are possibilities via android or via gnokii but we want to avoid using a phone directly on the server.

    We know Weboob. It's really simple and it uses the web interface of your provider to send msn in commandline like if it was on your phone.

    [If you want more information in french : https://linuxfr.org/users/moules/jou...rveurs-par-sms (in french)]


    When I send a sms via weboob like this :

    Code:
    echo "serveur down"| /usr/bin/boobmsg post 06XXXXXXXX@sfr
    It work fine. I have my sms which said "Serveur Down"

    But I can't make it work with shinken.

    I try to add a new command in my command.cfg like this :

    Code:
    define command{
        command_name          host-notify-by-sms
        command_line /usr/bin/printf "%b" "Shinken Notification\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATE$ Additional Info : $SERVICEOUTPUT$ | /usr/bin/boobmsg post 06XXXXXXXX@sfr -e
    }
    I create a new contact name sms and a new contacts_group name sms and an hosts templates name sms (where there is the host-notify-by-sms).

    I have an host wich is down so I restart shinken and try my command

    I have this kind of message in my /var/log/shinken/nagios.log

    Code:
    [1321977756] HOST ALERT: RVisio;DOWN;HARD;3;PING CRITICAL - Packet loss = 100%
    [1321977756] HOST NOTIFICATION: sms;RVisio;DOWN;host-notify-by-sms;PING CRITICAL - Packet loss = 100%
    [1321977760] Warning : the notification command '/usr/bin/printf "%b" "Host DOWN alert for RVisio" | /usr/bin/boobmsg post 06XXXXXXXX@sfr -e' raised an error (exit code=1) : ''
    I try to make shinken owner of boobmsg, to give all right on it etc...

    I try things more simple like :
    Code:
     command_line echo "serveur down"| /usr/bin/boobmsg post 06XXXXXXXX@sfr
    But without more success. I try to take in on a script and to gave the path of the script in the command.cfg (and I have check right on it). The script alone work but in shinken he didn't work. In nagios.log, I have no error message with the script but I don't received the sms.

    Before let it down this solution, I would like to be sure it's not possible or I didn't miss something very important about configuring shinken.

    If you have any idea...


  2. #2
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: SMS Alert with Weboob

    Hello,

    The difinitions of the commands seems ok. Can you try to create a script sh looking like this :
    Code:
    echo $1| /usr/bin/boobmsg post 06XXXXXXXX@sfr
    And modify your command definition like :
    Code:
    define command{
        command_name          host-notify-by-sms
        command_line       /path/script.sh "server down"
    }
    By the way, try to find (if you can) why the script return 1 sometimes. It may help

    Another idea, try to run Shinken in debug mode, this may be interesting .

    Lastely, do you have the last version of Shinken ( 0.8 )? Just in case, even if it should have nothing to do with.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: SMS Alert with Weboob

    I try what you say
    I make this script
    Code:
    #!/bin/bash
    echo $1| /usr/bin/boobmsg post 06XXXXXXXX@sfr
    When I execute it alone, it work.

    I execute shinken on debug mode and I have this :

    Code:
    [1322040329] Warning : the notification command '/root/notify_sms.sh "serveur down"' raised an error (exit code=126) : '/bin/sh: /root/notify_sms.sh: Permission denied'
    It seems shinken want a sh script but my script is in bash.
    In case I made a chown shinken:shinken of my script and a chmod 777 with no result.

    I try to move my script with another files whitout success.


  4. #4
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,131

    Re: SMS Alert with Weboob

    But the shinken user don't have access to /root. Change the script directory in a classic one (your /var/plugins/nagios for example) and it should be ok.
    No direct support by personal message. Please open a thread so everyone can see the solution

  5. #5
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: SMS Alert with Weboob

    When you say "with no result", does that mean you still have a "Permission Denied" or " The notification ... raised an error (exit code=1"

    In the second case try to look in the code of this script to get where it returns 1 .

    @nap, Already tried no? Lillia said "I try to move my script with another file"

  6. #6
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,131

    Re: SMS Alert with Weboob

    Yes, anoter file, not directory. And if so, it can be good to get the new output so
    No direct support by personal message. Please open a thread so everyone can see the solution

  7. #7
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: SMS Alert with Weboob

    Thanks for your concern.
    I have tried to takeit in another directory but I tried again.
    I move my script into /usr/lib/nagios/plugins.

    I change my script. I think the exit code=1 was because I forgot to add exit 0 in the end of my script. I am not at ease with script :/

    Now I have no error in shinken :

    Code:
    [1322048614] HOST NOTIFICATION: sms;RVisio;DOWN;host-notify-by-sms;PING CRITICAL - Packet loss = 100%
    But I don't receive sms either... And when I execute the script alone it work.


  8. #8
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: SMS Alert with Weboob

    If you add exit 0 to your script you won't see the problem.

    Try add a :
    Code:
    exit $?
    This will return the return value of the boobmsg script.

    By the way boobmsg is a script or a bin? If it's a script you can try to open it and look at the code

  9. #9
    Junior Member
    Join Date
    Oct 2011
    Posts
    27

    Re: SMS Alert with Weboob

    I have the same message and I don't know how to find what means the exit code

    Code:
    [1322061196] Warning : the notification command '/usr/lib/nagios/plugins/notify_sms.sh "serveur down"' raised an error (exit code=1) : ''
    And boobmsg is a script but he is part of weboob so I just have this in it :

    Code:
    from weboob.applications.boobmsg import Boobmsg
    
    
    if __name__ == '__main__':
      Boobmsg.run()
    and if i go in ../weboob/applications/boobmsg I have the code of boobmsg but nothing on it who talk about an exit code if there is a problem.

  10. #10
    Administrator
    Join Date
    Jun 2011
    Posts
    216

    Re: SMS Alert with Weboob

    OK, I don't think this is the best idea to dig in this code now.

    Did you check the owner and the mod of the boobmsg file? Are you root when you manually launch boobmsg?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •