Patch: SERVICECHECKCOMMAND macro
Jason Martin
jhmartin at toger.us
Mon Aug 9 22:55:42 CEST 2004
The attached patch against today's 2.0 CVS snapshot creates a
new macro named "SERVICECHECKCOMMAND". The purposes of this
macro is to make the command name used to check a given service
available as a macro. My purposes for implementing this was to
allow performance data processing scripts to make decisions on
how to parse the perf data of a given plugin from something
other than the Service Description, which is considered to be
freeform human readable as opposed to 'categorical'. There will
be a lot less variation in the check_command than in the service
description.
The expected output is to supply the first potion of the check
command, ie if the command is "check_ftp!foo!bar" the result
would be "check_ftp".
Thanks,
-Jason Martin
--
This message is PGP/MIME signed.
-------------- next part --------------
diff -U 3 -urN nagios-cvs/base/utils.c nagios-cvs2/base/utils.c
--- nagios-cvs/base/utils.c Mon Apr 5 20:14:39 2004
+++ nagios-cvs2/base/utils.c Mon Aug 9 13:48:34 2004
@@ -514,6 +514,9 @@
else if(!strcmp(temp_buffer,"SERVICEDOWNTIME"))
selected_macro=macro_x[MACRO_SERVICEDOWNTIME];
+ else if(!strcmp(temp_buffer,"SERVICECHECKCOMMAND"))
+ selected_macro=macro_x[MACRO_SERVICECHECKCOMMAND];
+
/* on-demand service macros */
else if(strstr(temp_buffer,"SERVICE") && strstr(temp_buffer,":")){
grab_on_demand_macro(temp_buffer);
@@ -654,6 +657,11 @@
free(macro_x[MACRO_SERVICEDESC]);
macro_x[MACRO_SERVICEDESC]=strdup(svc->description);
+ /* get the service description */
+ if(macro_x[MACRO_SERVICECHECKCOMMAND]!=NULL)
+ free(macro_x[MACRO_SERVICECHECKCOMMAND]);
+ macro_x[MACRO_SERVICECHECKCOMMAND]=strdup(svc->service_check_command);
+
/* get the plugin output */
if(macro_x[MACRO_SERVICEOUTPUT]!=NULL)
free(macro_x[MACRO_SERVICEOUTPUT]);
@@ -851,6 +859,7 @@
strip(macro_x[MACRO_SERVICEOUTPUT]);
strip(macro_x[MACRO_SERVICEPERFDATA]);
+ strip(macro_x[MACRO_SERVICECHECKCOMMAND]);
#ifdef DEBUG0
printf("grab_service_macros() end\n");
diff -U 3 -urN nagios-cvs/include/nagios.h.in nagios-cvs2/include/nagios.h.in
--- nagios-cvs/include/nagios.h.in Thu Mar 11 20:52:06 2004
+++ nagios-cvs2/include/nagios.h.in Mon Aug 9 13:47:51 2004
@@ -49,7 +49,7 @@
#define MAX_STATEID_LENGTH 2
#define MAX_PERCENTCHANGE_LENGTH 8
-#define MACRO_X_COUNT 60 /* size of macro_x[] array */
+#define MACRO_X_COUNT 61 /* size of macro_x[] array */
#define MACRO_HOSTNAME 0
#define MACRO_HOSTALIAS 1
@@ -111,6 +111,7 @@
#define MACRO_LASTHOSTUP 57
#define MACRO_LASTHOSTDOWN 58
#define MACRO_LASTHOSTUNREACHABLE 59
+#define MACRO_SERVICECHECKCOMMAND 60
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 211 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20040809/c4706182/attachment.sig>
More information about the Developers
mailing list