Re: [Nagios-devel] patch: total macros

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] patch: total macros

Post by Guest »

--=-QRPD6Qqv5o3Noziow1ad
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Tue, 2004-10-19 at 00:16, Matthew Kent wrote:
> Enclosed is a patch (against latest cvs) to add some more macros,
> similar values to what tac.cgi displays, for use in notifications. They
> are filtered appropriately for the permissions of the contact being
> notified.

oops, missed a tiny change in my diff'ing.

Apologies,
--
Matthew Kent
http://magoazul.com

--=-QRPD6Qqv5o3Noziow1ad
Content-Disposition: attachment; filename=nagios-2.0a1-total_macros2.patch
Content-Type: text/x-patch; name=nagios-2.0a1-total_macros2.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

diff -u3 -r nagios_orig/base/notifications.c nagios/base/notifications.c
--- nagios_orig/base/notifications.c 2004-10-06 20:50:09.000000000 -0400
+++ nagios/base/notifications.c 2004-10-18 23:55:25.000000000 -0400
@@ -169,6 +169,9 @@
/* grab the macro variables for this contact */
grab_contact_macros(temp_notification->contact);

+ /* grab total host and service macros for this contact */
+ grab_host_and_service_total_macros(temp_notification->contact);
+
/* notify this contact */
result=notify_contact_of_service(temp_notification->contact,svc,type);

@@ -913,6 +916,9 @@
/* grab the macro variables for this contact */
grab_contact_macros(temp_notification->contact);

+ /* grab total host and service macros for this contact */
+ grab_host_and_service_total_macros(temp_notification->contact);
+
/* notify this contact */
result=notify_contact_of_host(temp_notification->contact,hst,type);

diff -u3 -r nagios_orig/base/utils.c nagios/base/utils.c
--- nagios_orig/base/utils.c 2004-10-06 20:50:09.000000000 -0400
+++ nagios/base/utils.c 2004-10-18 23:55:25.000000000 -0400
@@ -205,6 +205,8 @@
extern notification *notification_list;
extern command *command_list;
extern timeperiod *timeperiod_list;
+extern host *host_list;
+extern service *service_list;

extern int command_file_fd;
extern FILE *command_file_fp;
@@ -430,6 +432,21 @@
else if(!strcmp(temp_buffer,"HOSTGROUPALIAS"))
selected_macro=macro_x[MACRO_HOSTGROUPALIAS];

+ else if(!strcmp(temp_buffer,"TOTALHOSTUP"))
+ selected_macro=macro_x[MACRO_TOTALHOSTUP];
+
+ else if(!strcmp(temp_buffer,"TOTALHOSTDOWN"))
+ selected_macro=macro_x[MACRO_TOTALHOSTDOWN];
+
+ else if(!strcmp(temp_buffer,"TOTALHOSTUNREACHABLE"))
+ selected_macro=macro_x[MACRO_TOTALHOSTUNREACHABLE];
+
+ else if(!strcmp(temp_buffer,"TOTALHOSTDOWNUNHANDLED"))
+ selected_macro=macro_x[MACRO_TOTALHOSTDOWNUNHANDLED];
+
+ else if(!strcmp(temp_buffer,"TOTALHOSTUNREACHABLEUNHANDLED"))
+ selected_macro=macro_x[MACRO_TOTALHOSTUNREACHABLEUNHANDLED];
+
/* on-demand host macros */
else if(strstr(temp_buffer,"HOST") && strstr(temp_buffer,":")){
grab_on_demand_macro(temp_buffer);
@@ -520,6 +537,27 @@
else if(!strcmp(temp_buffer,"SERVICEDOWNTIME"))
selected_macro=macro_x[MACRO_SERVICEDOWNTIME];

+ else if(!strcmp(temp_buffer,"TOTALSERVICEOK"))
+ selected_macro=macro_x[MACRO_TOTALSERVICEOK];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICEWARNING"))
+ selected_macro=macro_x[MACRO_TOTALSERVICEWARNING];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICEUNKNOWN"))
+ selected_macro=macro_x[MACRO_TOTALSERVICEUNKNOWN];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICECRITICAL"))
+ selected_macro=macro_x[MACRO_TOTALSERVICECRITICAL];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICEWARNINGUNHANDLED"))
+ selected_macro=macro_x[MACRO_TOTALSERVICEWARNINGUNHANDLED];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICEUNKNOWNUNHANDLED"))
+ selected_macro=macro_x[MACRO_TOTALSERVICEUNKNOWNUNHANDLED];
+
+ else if(!strcmp(temp_buffer,"TOTALSERVICECRITICALUNHANDLED"))
+ selected_macro=macro_x[MACRO_TOTALSERVICECRITICALUNHANDLED];
+
/* on-demand service macros */
else if(strstr(temp_buffer,"SERVICE") && strstr(temp_buffer,":")){
grab_on_demand_macro(temp_buffer);
@@ -1897,6 +1935,235 @@
}


+/* grab host and service total macros for a particular contact

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked