modify macro failed, why?
Posted: Wed Jul 06, 2011 11:56 pm
# 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.
# 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.