Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does any one know where to look to modify the notifications that nagios send to have only last 2 octet of the ip lets say my ip is 192.168. 1.1

I wanted to have x.x.1.1 os it can be replaced with xs or just view the last 2 octets

share|improve this question

2 Answers 2

You can edit notify-host-by-email or notify-service-by-email command definitions in /etc/nagios/objects/commands.cfg for supporting your format.

share|improve this answer

youd need to modify

/etc/nagios3/commands.cfg

eg

 'notify-host-by-email' command definition
define command{
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
    }

perhaps modify that a bit to pipe hostaddress thru the cut command and get just the octets you want... eg like in this example

share|improve this answer
    
This is not always in /etc/nagio3....it depends on your installation. –  mdpc Jan 8 '13 at 19:06
    
@mike looking at the link they had the script using cut to replace the last octet how do I do that for the first two I tried different combination and googled it but I couldtnt find any references on that not good in programming with shell your help is appreciated > cat test.sh > ip=$1 > baseip=echo $ip | cut -d"." -f1-3 > echo $baseip".0" > ./test.sh 192.168.133.14 = 192.168.133.0 –  user152523 Jan 8 '13 at 20:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.