Hi Joe:

In message <[email protected]>,
Joe Prosser writes:
>I'm trying to send the contents of a context to nagios and I need to
>use a different record separator than '\n'.
>
>Can this value be temporarily replaced?

No, but you can hide the ; as shown below. Also you can assign a ; to
a variable and use %{S} for example to substitute the value.

>This is the current action:
>desc=PROCESS_SERVICE_CHECK_RESULT;$1;DIAG_WARN;1;
>action=add   DIAG_WARN_$1 $2  Rate=$3/$4  ;\
>        set  DIAG_WARN_$1 30 (empty DIAG_WARN_$1) ;\
>        copy DIAG_WARN_$1 %sites ;\
>        write /usr/local/nagios/var/rw/nagios.cmd [%u] %s %sites ;\
>        write /tmp/secdebug.log [%u] %s %sites
>
>On a related note, is there a way to create a variable so I can use
>%OK,%WARN, and %CRIT instead of 0,1, and 2?
>Ideally it would span cfsets

You can use eval to set variables if you want. IIRC variables are global.
A sample rule I use:

# Set variables on SEC startup or soft restarts. These variables can be used
# in actions and contexts. They are not usable in patterns.
#   %notify - email addresses for notifications via email.
#   %eventStreamFile - same as argument given to ext_corr.o --file argument.
#   %nagiosCmd - the nagios external command file
#   %S - the control service for the module second component of --control
# CHANGEME - change variables below for your site.
type = single
desc = set variables and things on startup or restart of sec (core)
ptype = regexp
pattern = SEC_(STARTUP|RESTART|SOFTRESTART)
context = [ SEC_INTERNAL_EVENT ]
action = eval %notify (return "[email protected]"); \
         eval %eventStreamFile (return "/var/spool/nagios/event_stream"); \
         eval %nagiosCmd (return "/var/spool/nagios/nagios.cmd"); \
         eval %S (return "ZSecControl"); \
         eval %H ($foo=`/bin/hostname`; chomp($foo); return $foo);

I think you can also use:

   assign %OK 0; assign %WARN 1; assign %CRIT 2; assign %UNKNOWN 3

rather than the eval. Not quite sure why I was using eval in the first
place (except for setting %H).

To use the variables in your action:

    write %nagiosCmd ([%u] PROCESS_SERVICE_CHECK_RESULT;%H;%S;0;rotate|)

This also shows you how to use ; as a delimiter by hiding it inside of
matched ()'s.

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

------------------------------------------------------------------------------
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to