modify macro failed, why?

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

modify macro failed, why?

Postby edeed » 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.
edeed
 
Posts: 2
Joined: Wed Jul 06, 2011 11:48 pm

Re: modify macro failed, why?

Postby agriffin » Tue Aug 02, 2011 4:58 pm

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


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 12 guests