# tar zxvf nagios-3.2.3.tar.gz
# cd nagios-3.2.3
# cp common/macros.c common/macros.c.enc
becase $SERVICESTATE$ is too long, SMS not friendly, Iwant modify WARNING to WR, CRITICAL to CR, UNKNOWN to UN. as:
# vi +2002 common/macros.c
---------------------------------------------------------------------------
case MACRO_SERVICESTATE:
if(temp_service->current_state==STATE_OK)
*output=(char *)strdup("OK");
else if(temp_service->current_state==STATE_WARNING)
*output=(char *)strdup("WR");
else if(temp_service->current_state==STATE_CRITICAL)
*output=(char *)strdup("CR");
else
*output=(char *)strdup("UN");
break;
case MACRO_SERVICESTATEID:
asprintf(output,"%d",temp_service->current_state);
break;
case MACRO_LASTSERVICESTATE:
if(temp_service->last_state==STATE_OK)
*output=(char *)strdup("OK");
else if(temp_service->last_state==STATE_WARNING)
*output=(char *)strdup("WR");
else if(temp_service->last_state==STATE_CRITICAL)
*output=(char *)strdup("CR");
else
*output=(char *)strdup("UN");
break;
---------------------------------------------------------------------------
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
But, in fact, I received alert email still is WARNING/CRITICAL/UNKNOWN, not WR/CR/UN.
how to modify?
thx.
modify macro failed, why?
Re: modify macro failed, why?
A better approach might be to just modify the notification command. Something like this:
Code: Select all
echo blah blah notification text | sed -e s/WARNING/WR/ -e s/CRITICAL/CR/ -e s/UNKNOWN/UN/ | mail -s subject $CONTACTEMAIL$