Re: [Nagios-devel] RFE: host/service tuple as parent

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] RFE: host/service tuple as parent

Post by Guest »

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Fri, Feb 28, 2003 at 01:33:19PM -0500, Frank Sweetser wrote:
> I've identified at least some of the code points that would have to be
> modified (in the template config stuff only), and am willing to take a crack
> at it if no one else will.

Okay, here's a patch. It compiles, and hasn't broken anything for me yet...

--
Frank Sweetser fs at wpi.edu
WPI Network Engineer

--nFreZHaLTZJo0R7j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="add-parent-service.diff"

diff -u -r nagios-1.0.orig/base/checks.c nagios-1.0/base/checks.c
--- nagios-1.0.orig/base/checks.c 2002-11-17 20:15:13.000000000 -0500
+++ nagios-1.0/base/checks.c 2003-03-02 16:37:51.000000000 -0500
@@ -1416,7 +1416,8 @@
int result=HOST_UP;
int parent_result=HOST_UP;
host *parent_host=NULL;
- hostsmember *temp_hostsmember=NULL;
+ service *parent_service=NULL;
+ parent *temp_hostsmember=NULL;
host *child_host=NULL;
int return_result=HOST_UP;
int max_check_attempts=1;
@@ -1512,15 +1513,21 @@

/* if at least one parent host is up, this host is no longer unreachable - it is now down instead */
if(parent_host->status==HOST_UP){
-
- /* handle the hard host state change */
- handle_host_state(hst,HOST_DOWN,HARD_STATE);
+ if(temp_hostsmember->service_name!=NULL)
+ parent_service=find_service(temp_hostsmember->host_name,
+ temp_hostsmember->service_name, NULL);
+ else
+ parent_service=NULL;

+ if(parent_service==NULL || parent_service->current_state==STATE_OK)
+ /* handle the hard host state change */
+ handle_host_state(hst,HOST_DOWN,HARD_STATE);
+
break;
- }
- }
- }
- }
+ }
+ }
+ }
+ }


/* else the host is supposed to be up right now... */
@@ -1545,6 +1552,11 @@

/* find the parent host */
parent_host=find_host(temp_hostsmember->host_name,NULL);
+ if(temp_hostsmember->service_name!=NULL)
+ parent_service=find_service(temp_hostsmember->host_name,
+ temp_hostsmember->service_name, NULL);
+ else
+ parent_service=NULL;

/* check the parent host, assume its up if we can't find it, use the parent host's "old" status if we shouldn't propagate */
if(parent_host==NULL)
@@ -1555,7 +1567,8 @@
parent_result=parent_host->status;

/* if this parent host was up, the route is okay */
- if(parent_result==HOST_UP)
+ if(parent_result==HOST_UP && (parent_service==NULL ||
+ parent_service->current_state==STATE_OK))
route_blocked=FALSE;

/* we could break out of this loop once we've found one parent host that is up, but we won't because we want
diff -u -r nagios-1.0.orig/base/config.c nagios-1.0/base/config.c
--- nagios-1.0.orig/base/config.c 2002-07-05 01:36:01.000000000 -0400
+++ nagios-1.0/base/config.c 2003-03-02 17:08:20.000000000 -0500
@@ -1226,7 +1226,7 @@
contactgroupsmember *temp_contactgroupsmember;
host *temp_host;
host *temp_host2;
- hostsmember *temp_hostsmember;
+ parent *temp_hostsmember;
hostgroup *temp_hostgroup;
hostgroupmember *temp_hostgroupmember;
service *temp_service;
diff -u -r nagios-1.0.orig/cgi/config.c nagios-1.0/cgi/config.c
--- nagios-1.0.orig/cgi/config.c 2002-11-10 20:13:09.000000000 -0500
+++ nagios-1.0/cgi/config.c 2003-03-02 17:13:18.000000000 -0500
@@ -399,7 +399,7 @@

void display_hosts(void){
host *temp_host;
- hostsmember *temp_hostsmember;
+ parent *temp_hostsmember;
int options=0;
int odd=0;
char time_string[16];
diff -u -r nagios-1.0.orig/cgi/outages.c nagios-1.0/cgi/outages.c
--- nagios-1.0.orig/cgi/outages.c 2002-07-29 00:50:53.000000000 -0400
+++ nagios-1.0/cgi/outages.c 2003-03-02 17:19:06.000000000 -0500
@@ -613,11 +613,11 @@
}


-
/* tests whether or not a host is "blocked" by upstream parents (host is already assumed to be down or unreachable) */
int is_route_to_host_blocked(host *hst){
- hostsmember *temp_hostsmember;
+ parent *temp_hostsmember;
hoststatus *temp_hoststatus;
+ servicestatus *temp_servicestatus;

/* if the host has no parents, it is not being blocked

...[email truncated]...


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