[Nagios-devel] [patch] new directive check_args
Posted: Sat Dec 06, 2003 8:24 pm
This is a multi-part message in MIME format.
--------------040600010309070306040508
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
we ~50 near identical machines.
running the nearly the same service on multiple ports.
instead of coding the check_command into every template definition
i thought it would be easier to just pass the argument which is
different to each one and make use of the templates to do the heavy
lifting when I need to change things
cheers
Ian
--------------040600010309070306040508
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="nagios.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="nagios.patch"
Index: base/checks.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/nagios/nagios/base/checks.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 checks.c
--- base/checks.c 5 Dec 2003 02:01:44 -0000 1.12.2.1
+++ base/checks.c 6 Dec 2003 11:24:34 -0000
@@ -216,7 +216,7 @@
grab_service_macros(svc);
=20
/* get the raw command line */
- get_raw_command_line(svc->service_check_command,raw_command,sizeof(raw_=
command));
+ get_raw_command_line(svc->service_check_command,svc->service_check_args=
, raw_command,sizeof(raw_command));
strip(raw_command);
=20
/* process any macros contained in the argument */
@@ -1673,6 +1673,7 @@
char *temp_ptr;
int early_timeout=3DFALSE;
char temp_plugin_output[MAX_PLUGINOUTPUT_LENGTH];
+ int command_len=3D0;
=09
=20
#ifdef DEBUG0
@@ -1717,6 +1718,14 @@
/* get the raw command line */
strncpy(raw_check_command,temp_command->command_line,sizeof(raw_check_c=
ommand));
raw_check_command[sizeof(raw_check_command)-1]=3D'\x0';
+ if ( hst->host_check_args !=3D NULL ) {
+ command_len =3Dstrlen(raw_check_command);
+ raw_check_command[command_len] =3D '\x0';
+
+ if (command_len host_check_args, sizeof(raw_=
check_command) - command_len );
+ }
+ }
=20
/* process any macros in the check command */
process_macros(raw_check_command,&processed_check_command[0],(int)sizeo=
f(processed_check_command),0);
@@ -1724,6 +1733,10 @@
=09
#ifdef DEBUG3
printf("\t\tRaw Command: %s\n",hst->host_check_command);
+ if (hst->host_check_args !=3D NULL )=20
+ printf("\t\tRaw Args : %s\n",hst->host_check_args);
+ else=20
+ printf("\t\tRaw Args : null\n");
printf("\t\tProcessed Command: %s\n",processed_check_command);
#endif
=20
@@ -1741,7 +1754,11 @@
hst->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]=3D'\x0';
=20
/* log the timeout */
- snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host check comman=
d '%s' for host '%s' timed out after %d seconds\n",hst->host_check_comman=
d,hst->name,host_check_timeout);
+ if (hst->host_check_args !=3D NULL )
+ snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host ch=
eck command '%s%s' for host '%s' timed out after %d seconds\n",
+ hst->host_check_command,hst->host_check_args,hst->name,h=
ost_check_timeout);
+ else=20
+ snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host ch=
eck command '%s' for host '%s' timed out after %d seconds\n",hst->host_ch=
eck_command,hst->name,host_check_timeout);
temp_buffer[sizeof(temp_buffer)-1]=3D'\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
}
Index: base/nagios.h.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/nagios/nagios/base/Attic/nagios.h.in,v
retrieving revision 1.4
diff -u -r1.4 nagios.h.in
--- base/nagios.h.in 8 Aug 2002 05:00:51 -0000 1.4
+++ base/nagios.h.in 6 Dec 2003 11:24:35 -0000
@@ -414,7 +414,7 @@
char *my_strsep(char **,const char *); /* Solaris does
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
--------------040600010309070306040508
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
we ~50 near identical machines.
running the nearly the same service on multiple ports.
instead of coding the check_command into every template definition
i thought it would be easier to just pass the argument which is
different to each one and make use of the templates to do the heavy
lifting when I need to change things
cheers
Ian
--------------040600010309070306040508
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="nagios.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="nagios.patch"
Index: base/checks.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/nagios/nagios/base/checks.c,v
retrieving revision 1.12.2.1
diff -u -r1.12.2.1 checks.c
--- base/checks.c 5 Dec 2003 02:01:44 -0000 1.12.2.1
+++ base/checks.c 6 Dec 2003 11:24:34 -0000
@@ -216,7 +216,7 @@
grab_service_macros(svc);
=20
/* get the raw command line */
- get_raw_command_line(svc->service_check_command,raw_command,sizeof(raw_=
command));
+ get_raw_command_line(svc->service_check_command,svc->service_check_args=
, raw_command,sizeof(raw_command));
strip(raw_command);
=20
/* process any macros contained in the argument */
@@ -1673,6 +1673,7 @@
char *temp_ptr;
int early_timeout=3DFALSE;
char temp_plugin_output[MAX_PLUGINOUTPUT_LENGTH];
+ int command_len=3D0;
=09
=20
#ifdef DEBUG0
@@ -1717,6 +1718,14 @@
/* get the raw command line */
strncpy(raw_check_command,temp_command->command_line,sizeof(raw_check_c=
ommand));
raw_check_command[sizeof(raw_check_command)-1]=3D'\x0';
+ if ( hst->host_check_args !=3D NULL ) {
+ command_len =3Dstrlen(raw_check_command);
+ raw_check_command[command_len] =3D '\x0';
+
+ if (command_len host_check_args, sizeof(raw_=
check_command) - command_len );
+ }
+ }
=20
/* process any macros in the check command */
process_macros(raw_check_command,&processed_check_command[0],(int)sizeo=
f(processed_check_command),0);
@@ -1724,6 +1733,10 @@
=09
#ifdef DEBUG3
printf("\t\tRaw Command: %s\n",hst->host_check_command);
+ if (hst->host_check_args !=3D NULL )=20
+ printf("\t\tRaw Args : %s\n",hst->host_check_args);
+ else=20
+ printf("\t\tRaw Args : null\n");
printf("\t\tProcessed Command: %s\n",processed_check_command);
#endif
=20
@@ -1741,7 +1754,11 @@
hst->plugin_output[MAX_PLUGINOUTPUT_LENGTH-1]=3D'\x0';
=20
/* log the timeout */
- snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host check comman=
d '%s' for host '%s' timed out after %d seconds\n",hst->host_check_comman=
d,hst->name,host_check_timeout);
+ if (hst->host_check_args !=3D NULL )
+ snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host ch=
eck command '%s%s' for host '%s' timed out after %d seconds\n",
+ hst->host_check_command,hst->host_check_args,hst->name,h=
ost_check_timeout);
+ else=20
+ snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host ch=
eck command '%s' for host '%s' timed out after %d seconds\n",hst->host_ch=
eck_command,hst->name,host_check_timeout);
temp_buffer[sizeof(temp_buffer)-1]=3D'\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
}
Index: base/nagios.h.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/nagios/nagios/base/Attic/nagios.h.in,v
retrieving revision 1.4
diff -u -r1.4 nagios.h.in
--- base/nagios.h.in 8 Aug 2002 05:00:51 -0000 1.4
+++ base/nagios.h.in 6 Dec 2003 11:24:35 -0000
@@ -414,7 +414,7 @@
char *my_strsep(char **,const char *); /* Solaris does
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]