Page 1 of 1
How to make nagios send me brief and informative alerts?
Posted: Tue Apr 09, 2019 7:08 pm
by t3dus
How do I make nagios send me brief and informative alerts via sms? The current long winded ones get broken up into multiple messages which is super annoying because I get multiple messages regarding a single outage.
I want something like the folks talked about
here
What I don't understand is if I was to add this code to commands.cfg how I get certain notifications to use that vs the long winded alert.
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%.120s" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%.120s" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" | /usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
}
Re: How to make nagios send me brief and informative alerts?
Posted: Wed Apr 10, 2019 7:43 am
by scottwilkerson
You would just change the
host_notification_commands and
service_notification_commands for the contact you want to receive these to
notify-host-by-sms and
notify-service-by-sms
https://assets.nagios.com/downloads/nag ... ml#contact
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 12:50 pm
by t3dus
I did that in the contacts.cfg file but it isn't sending anything to my phone via text.
Code: Select all
define contact{
contact_name mattphone
alias Matt
service_notification_commands notify-service-by-sms
host_notification_commands notify-host-by-sms
email REMOVED NUMBER FOR [email protected]
pager REMOVED NUMBER FOR [email protected]
}
and added "mattphone" to the contact groups.
Code: Select all
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members sysadmins,gldgmail,gidalerts,bp,mattphone
}
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 12:53 pm
by scottwilkerson
Have you tried testing these from the command line to see if the command works?
Code: Select all
/usr/bin/printf "%.120s" "host_alias is CRITICAL" |/usr/local/bin/gnokii --sendsms 'REMOVED NUMBER FOR [email protected]' -r
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:00 pm
by t3dus
Oh I see the issue. it comes back with the error
Code: Select all
-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:15 pm
by scottwilkerson
t3dus wrote:Oh I see the issue. it comes back with the error
Code: Select all
-bash: /usr/local/bin/gnokii: No such file or directory
Do I have to use gnokii or what do you suggest I use?
I don't even know what gnokii is....
If this is a email to text notification, I would suggest setting them up like your email commands
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:16 pm
by t3dus
Ok I got it working. This is what I did..
I change the command to the following
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail -s --sendsms $CONTACTPAGER$
}
My next question is how can I get it so it doesn't text me "S:--sendsms"
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:24 pm
by scottwilkerson
change it to this
Code: Select all
define command{
command_name notify-host-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/bin/mail $CONTACTPAGER$
}
define command{
command_name notify-service-by-sms
command_line /usr/bin/printf "%b" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" |/usr/bin/mail $CONTACTPAGER$
}
the -s flag is defining the subject
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:41 pm
by t3dus
So I narrowed it down with your commands to where it says
but is there a way to ditch the "S:" and "M:"
Re: How to make nagios send me brief and informative alerts?
Posted: Thu Apr 11, 2019 1:49 pm
by scottwilkerson
t3dus wrote:but is there a way to ditch the "S:" and "M:"
My guess is your mail to sms provider is adding them to the message, where: