Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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



 '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/ 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 > ip=$1 > baseip=echo $ip | cut -d"." -f1-3 > echo $baseip".0" > ./ = – user152523 Jan 8 '13 at 20:33

Your Answer


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.