Re: [Nagios-users] SMS notification commands

2007-11-30 Thread mark redding
Hi,

A couple of questions for you.

1. When you run this interactively are you doing so from the account
that nagios is running under ? This could be the cause if the ssh key
information is not present for the 'nagios' account.
2. Have you defined the contact name correctly :- for example, I have
the following in my config for my on-call sysadmin.

define contact{
use mark
contact_nameoncall
alias   On Call Sys Admin
service_notification_optionsc,r
host_notification_options   d,r
service_notification_commands   service-notify-by-sms
host_notification_commands  host-notify-by-sms
}

and :-

define contact{
namemark
contact_namemark
alias   Mark Redding
service_notification_period 24x7
host_notification_period24x7
service_notification_optionsc,r
host_notification_options   d,r
service_notification_commands   service-notify-by-email
host_notification_commands  host-notify-by-email,host-notify-by-sms
email   [EMAIL PROTECTED]
pager   44
}


regards,
Mark

this is in addition to the usual

define contactgroup {
contactgroup_name   admin
alias   System Administrators
members nagaios,mark,fred,oncall
}

On 30/11/2007, Nick Pratley <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi, I need to be able to send notifications via SMS in the event that the
> email servers are unavailable, or the internet connection is down. There is
> a server on the same network as the Nagios host that has a modem installed
> and uses SMS Tools 3 to send messages. To send a message all I need to do is
> place a file in a certain directory on that server, in a simple format, and
> it does the rest.
>
>
>
> So, I created a script called 'notify-by-sms' in /usr/local/nagios/libexec
> which is as follows:
>
>
>
> TMPFILE=`/bin/mktemp notify.XX`
>
> /bin/echo -e $1 > $TMPFILE
>
> /usr/bin/scp $TMPFILE sms-server:/var/spool/sms/outgoing/
>
> rm $TMPFILE
>
>
>
> The script is owned by the user nagios and is executable. To run it I just
> need to pass it a string like "To: \n\n" as the
> only parameter. If I run it from the command line while logged in as nagios
> it works fine.
>
>
>
> I have the following in commands.cfg which I adapted from
> notify-service-by-email and notify-host-by-email:
>
>
>
> # 'notify-host-by-sms' command definition
>
> define command{
>
> command_name notify-host-by-sms
>
> command_line /usr/local/nagios/libexec/notify-by-sms "To:
> $CONTACTPAGER$\n\n* Nagios *\n\nNotification Type:
> $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: HOSTSTATE$\nAddress:
> $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"
>
> }
>
>
>
> # 'notify-service-by-sms' command definition
>
> define command{
>
> command_name notify-service-by-sms
>
> command_line /usr/local/nagios/libexec/notify-by-sms "To:
> $CONTACTPAGER$\n\n* Nagios *\n\nNotification Type:
> $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: HOSTALIAS$\nAddress:
> $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:
> $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"
>
>
>
> }
>
>
>
> I see the following in /usr/local/nagios/var/nagios.log, as
> an example (I have replaced some things with <...>):
>
>
>
> [1196327641] SERVICE NOTIFICATION:
> ;;SyncServer;CRITICAL;notify-service-by-sms;CRITICAL
> - Error Fetching http:///sync/ds [503] Service Temporarily
> Unavailable
>
>
>
> however the sms is not received. It does not even appear in the log on the
> SMS server which indicates the script isn't running or isn't able to scp the
> file to that server. I am using public key authentication to negate the need
> for a SSH password to be entered.
>
>
>
> Any ideas what the problem could be, when it runs manually from the command
> line but not through the nagios daemon?
>
>
>
> Thank you,
>
> Nick
>
>
>
>
> -
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> ___
> Nagios-users mailing list
> Nagios-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting
> any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>


-- 
bright blessings,
Mark

-
SF.Net email is sponsored by: The Future of Linux Business White P

Re: [Nagios-users] SMS notification commands

2007-11-29 Thread Peter Hallam
On Fri, 30 Nov, 15:24 +1000 Nick Pratley wrote:
> Thanks for the reply Peter, however that isn't what the problem is in my
> case. The /var/spool/sms/outgoing directory on that server is in fact
> world-writable. And as I said I can run it from the command line
> successfully while logged in as the nagios user, which I wouldn't be able to
> do if the permissions were not right.
> 
> Keep in mind that SMS Tools is running on a different server, and I'm using
> SCP to copy the file to that server.


Ah I overlooked it was being copied to a remote server.  As for running as the 
user nagios, how did you achieve that - with su or logging in directly?  I 
found that su doesn't work as expected.

Anyhow, as you say the outgoing dir is world-writeable on the remote server, 
then it should work AFAIK - though why don't you move the notify-by-sms script 
to the remote server and have a sommand on the nagios server such as:


define command {
command_namenotify-host-by-sms
command_line/usr/bin/ssh [EMAIL PROTECTED] 
"/some/path/notify-by-sms $CONTACTPAGER$ \"$TIME$ $HOSTALIAS$ $HOSTSTATE$ 
$NOTIFICATIONTYPE$ $HOSTOUTPUT$\""
}

In my mind it's cleaner than the scp method, though whether or not it'll work 
or not I'm not sure!

Regards,
Peter


pgpe1AKpkkHwB.pgp
Description: PGP signature
-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Re: [Nagios-users] SMS notification commands

2007-11-29 Thread Nick Pratley
Thanks for the reply Peter, however that isn't what the problem is in my
case. The /var/spool/sms/outgoing directory on that server is in fact
world-writable. And as I said I can run it from the command line
successfully while logged in as the nagios user, which I wouldn't be able to
do if the permissions were not right.

Keep in mind that SMS Tools is running on a different server, and I'm using
SCP to copy the file to that server.

Any other ideas?

Thanks anyway.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Peter
Hallam
Sent: Friday, 30 November 2007 2:33 PM
To: nagios-users@lists.sourceforge.net
Subject: Re: [Nagios-users] SMS notification commands

Having just solved this problem this week:

chmod g+w /var/spool/sms/outgoing
chgrp nagios /var/spool/sms/outgoing

This should enable nagios to write to the directory using your script.

Regards,
Peter.


-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null


Re: [Nagios-users] SMS notification commands

2007-11-29 Thread Peter Hallam
On Fri, 30 Nov, 13:20 +1000 Nick Pratley wrote:
> Hi, I need to be able to send notifications via SMS in the event that the
> email servers are unavailable, or the internet connection is down. There is
> a server on the same network as the Nagios host that has a modem installed
> and uses SMS Tools 3 to send messages. To send a message all I need to do is
> place a file in a certain directory on that server, in a simple format, and
> it does the rest.
>  
> Any ideas what the problem could be, when it runs manually from the command
> line but not through the nagios daemon?

Having just solved this problem this week:

chmod g+w /var/spool/sms/outgoing
chgrp nagios /var/spool/sms/outgoing

This should enable nagios to write to the directory using your script.

Regards,
Peter.


pgpObEhO8E6qd.pgp
Description: PGP signature
-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

[Nagios-users] SMS notification commands

2007-11-29 Thread Nick Pratley
Hi, I need to be able to send notifications via SMS in the event that the
email servers are unavailable, or the internet connection is down. There is
a server on the same network as the Nagios host that has a modem installed
and uses SMS Tools 3 to send messages. To send a message all I need to do is
place a file in a certain directory on that server, in a simple format, and
it does the rest.

 

So, I created a script called 'notify-by-sms' in /usr/local/nagios/libexec
which is as follows:

 

TMPFILE=`/bin/mktemp notify.XX`

/bin/echo -e $1 > $TMPFILE

/usr/bin/scp $TMPFILE sms-server:/var/spool/sms/outgoing/

rm $TMPFILE

 

The script is owned by the user nagios and is executable. To run it I just
need to pass it a string like "To: \n\n" as the
only parameter. If I run it from the command line while logged in as nagios
it works fine.

 

I have the following in commands.cfg which I adapted from
notify-service-by-email and notify-host-by-email:

 

# 'notify-host-by-sms' command definition

define command{

command_name notify-host-by-sms

command_line /usr/local/nagios/libexec/notify-by-sms "To:
$CONTACTPAGER$\n\n* Nagios *\n\nNotification Type:
$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: HOSTSTATE$\nAddress:
$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"

}

 

# 'notify-service-by-sms' command definition

define command{

command_name notify-service-by-sms

command_line /usr/local/nagios/libexec/notify-by-sms "To:
$CONTACTPAGER$\n\n* Nagios *\n\nNotification Type:
$NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: HOSTALIAS$\nAddress:
$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"

 

}

 

I see the following in /usr/local/nagios/var/nagios.log, as an example (I
have replaced some things with <...>):

 

[1196327641] SERVICE NOTIFICATION:
;;SyncServer;CRITICAL;notify-service-by-sms;CRITICA
L - Error Fetching http:///sync/ds [503] Service Temporarily
Unavailable

 

however the sms is not received. It does not even appear in the log on the
SMS server which indicates the script isn't running or isn't able to scp the
file to that server. I am using public key authentication to negate the need
for a SSH password to be entered.

 

Any ideas what the problem could be, when it runs manually from the command
line but not through the nagios daemon?

 

Thank you,

Nick

 

 

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null