modify macro failed, why?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
edeed
Posts: 2
Joined: Wed Jul 06, 2011 11:48 pm

modify macro failed, why?

Post by edeed »

# 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.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: modify macro failed, why?

Post by agriffin »

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$
Locked