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

Thread: [RESOLVED] gnokii not working from shinken?

  1. #1
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    [RESOLVED] gnokii not working from shinken?

    Very weird problem (aren't they all )

    I can send SMS from terminal just fine, using:
    Code:
    echo "Something is wrong" | gnokii --sendsms xxxxxxxxx
    Command for notifying over SMS is also simplified to basics:
    Code:
    define command{
        command_name notify-host-by-sms
        command_line /bin/echo "Something is wrong" | /usr/bin/gnokii --sendsms $CONTACTPAGER$ 
    }
    I tried from command line to send SMS as root, as my user, and as shinken user, all messages went OK.

    But from Shinken, I get report in schedulerd.log:
    Code:
    2012-04-11 07:50:01,214 [1334123401] Warning : the notification command '/bin/echo "juhubruhu" | /usr/bin/gnokii --sendsms xxxxxxxxx -r' raised an error (exit code=255) : 'GNOKII Version 0.6.30'
    Is it possible that there is some timeout, because this command takes about 5 seconds or a little more to complete?
    Or something else?

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

    Re: gnokii not working from shinken?

    I think there is something wrong with $CONTACTPAGER$. Can you try to change the command by a simple echo in a file of it?
    No direct support by personal message. Please open a thread so everyone can see the solution

  3. #3
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    Sure.
    Code:
    command_line /bin/echo "Something is wrong $CONTACTPAGER$" >/tmp/output
    I again recieve some error:
    Code:
    2012-04-11 11:23:08,092 [1334136188] Warning : the notification command '/bin/echo "Something is wrong 04XXXXXXXX" >/tmp/output.txt' raised an error (exit code=2) : ''
    Is it maby just some quotes (", &#039 problem? Maby it is so obvious, that I just don't see it :-\

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

    Re: gnokii not working from shinken?

    I just edit your phone number (you don't want it public on the net isn't it?)

    We got the data we want, the pager is filed like it should. But there is something strange with /bin/echo.

    can you wrote a wrapper script, something like :

    #!/bin/bash
    /bin/echo "Something is wrong" | /usr/bin/gnokii --sendsms $1

    remember to chmod a+x it

    And call it with :
    /tmp/myscript.sh $CONTACTPAGER$
    in your command definition?

    we will see if it's a call or the echo that is the problem
    No direct support by personal message. Please open a thread so everyone can see the solution

  5. #5
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    Sorry, the same:
    Code:
    2012-04-11 11:50:08,402 [1334137808] Warning : the notification command '/tmp/send_sms.sh 04xxxxxxx' raised an error (exit code=2) : ''
    Correction, error code is this:
    Code:
    2012-04-11 12:40:01,359 [1334140801] Warning : the notification command '/tmp/send_sms.sh 04xxxxxxx' raised an error (exit code=255) : 'GNOKII Version 0.6.30'

  6. #6
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    If I run gnokii from command line, first line I get instantly is the same
    Code:
    GNOKII Version 0.6.30
    The second line is printed after the sms is sent (after about 5 seconds):
    Code:
    Send succeeded with reference 13!
    Also tried with send_sms.sh, that I created, result is the same, sms is sent successfully

  7. #7
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    How : :

    http://www.mail-archive.com/nagios-u.../msg22798.html
    According to this link I did (sometime in the past):
    Code:
    sudo chown -R shinken:shinken /dev/bus/usb/*
    chown -R shinken:shinken /dev/ttyACM0
    chmod 750 -R /dev/bus/usb/*
    chmod 750 /dev/ttyACM0
    and SMS was sucessfully sent from shinken user command line.

    But I have rebooted several times from then and it seems that this settings are overriden at reboot.
    shinken user was created with installation.
    Now I added shinken to plugdev and dialout groups.
    We'll see what will happen


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

    Re: gnokii not working from shinken?

    Oh yes, there is an important rule : "never send a command as root". Now you know why

    The groups should do the trick. If not, you can still add some lines in /etc/rc.local ;D
    No direct support by personal message. Please open a thread so everyone can see the solution

  9. #9
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    just curious, cause it still doesn't work (though it successfully sends SMS from command line, user shinken, even after reboot).
    exit-code=255

    I run shinken manually as root :/etc/init.d/shinken -d start

    Under which user are notification commands being run?

  10. #10
    Member
    Join Date
    Feb 2012
    Location
    Slovenia
    Posts
    65

    Re: gnokii not working from shinken?

    Ok, figured user (shinken) out by this:
    Code:
    #!/bin/bash
    /usr/bin/whoami > /var/log/whoami.log
    /bin/echo "Something is wrong" | /usr/bin/gnokii --sendsms $1 2>/var/log/sendEmail

    Now I got some more info I can work on: (sendEmail log file)
    Code:
    GNOKII Verzija 0.6.30
    Couldn't read /root/.config/gnokii/config config file.
    Cannot open logfile /root/.cache/gnokii/gnokii-errors
    WARNING: cannot open logfile, logs will be directed to stderr
    Naprave FB38 ni bilo mogo?e odpreti: Operation not permitted
    Telephone interface init failed: Command failed.
    Quitting.
    Command failed.
    Apr 12 11:05:20 dess-shinken sendEmail[24038]: Email was sent successfully! From: <shinken@mydomain.si> To: <my@email.com> Subject: [** PROBLEM Host Alert: 172.20.1.210 is DOWN Notification\n\nType: PROBLEM\nHost: 172.20.1.210\nState: DOWN\nAddress: 172.20.1.210\nInfo: CRITICAL - Host Unreachable (172.20.1.210)\n\nDate/Time: 12-04-2012\n] Server: [172.20.1.7:25]
    Now I don't understand anymore.. What else do I have to do to get Shinken/Gnokii working.
    Why is operation not permitted for shinken user, even though he is in correct groups (plugdev, dialout)?
    Must shinken be part of root group also?

Posting Permissions

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