Update of /cvsroot/nagios-db/nagios-db/neb/mysql
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27430
Modified Files:
inserter.c
Log Message:
- Make hostgroups/servicegroups persistant across restarts.
Without this the ids could shift when a new group is added breaking a bookmark someone may have added.
- Cleanup my other stupid mistakes with configured flag.
Index: inserter.c
===================================================================
RCS file: /cvsroot/nagios-db/nagios-db/neb/mysql/inserter.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** inserter.c 29 Jan 2005 03:13:01 -0000 1.7
--- inserter.c 29 Jan 2005 05:00:27 -0000 1.8
***************
*** 20,23 ****
--- 20,25 ----
* - Adding a verbose mode.
* - Cleanup sql statements for uniformity.
+ * - Error in sql before loading startup host/service data causes multiple
+ * 'inserter unloading' msg's
* - General tidying.
*/
***************
*** 177,182 ****
/* Now that we have a database connection, clear out the previous config info */
asprintf(&tmp,
! "delete from hostgroup");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
--- 179,185 ----
/* Now that we have a database connection, clear out the previous config info */
+ /* clear out our memberships, we reload these each time */
asprintf(&tmp,
! "delete from hostgroup_membership");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
***************
*** 184,188 ****
asprintf(&tmp,
! "delete from servicegroup");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
--- 187,191 ----
asprintf(&tmp,
! "delete from servicegroup_membership");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
***************
*** 195,204 ****
free(tmp);
! asprintf(&tmp,
! "update host,service set host.configured = false and service.configured = false");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
free(tmp);
/* run out these queries right now, we need to mark all host/services as unconfigured
* before the large initial update which sets them back to TRUE as to weed out any dead
--- 198,218 ----
free(tmp);
! /* this will leave any dead (removed from config hosts/hostgroups/servicegroups) as configured = false */
! asprintf(&tmp, "update host,service set host.configured = false, service.configured = false");
! // err handling
! buffer(&query_buf, tmp, ++query_buf_count);
! free(tmp);
!
! asprintf(&tmp, "update hostgroup set hostgroup.configured = false");
! // err handling
! buffer(&query_buf, tmp, ++query_buf_count);
! free(tmp);
!
! asprintf(&tmp, "update servicegroup set servicegroup.configured = false");
// err handling
buffer(&query_buf, tmp, ++query_buf_count);
free(tmp);
+
/* run out these queries right now, we need to mark all host/services as unconfigured
* before the large initial update which sets them back to TRUE as to weed out any dead
***************
*** 238,241 ****
--- 252,261 ----
write_to_logs_and_console(log,NSLOG_INFO_MESSAGE,TRUE);
+ /* now that we've loaded (possibly from the retention file) flag that they haven't been checked */
+ asprintf(&tmp, "update host,service set host.has_been_checked = false, service.has_been_checked = false");
+ // err handling
+ buffer(&query_buf, tmp, ++query_buf_count);
+ free(tmp);
+
/* .... and insert new config info. Start with hostgroups. */
for(groupcount=0, hg = hostgroup_list; hg ; hg = hg->next)
***************
*** 251,256 ****
"INSERT INTO hostgroup ("
"name,"
! "alias"
! ") VALUES (%s,%s)",
NULL_STRING(groupName),
NULL_STRING(groupAlias));
--- 271,280 ----
"INSERT INTO hostgroup ("
"name,"
! "alias,"
! "configured"
! ") VALUES (%s,%s,TRUE)"
! " ON DUPLICATE KEY UPDATE "
! "alias=VALUES(alias),"
! "configured=TRUE",
NULL_STRING(groupName),
NULL_STRING(groupAlias));
***************
*** 399,403 ****
if (delayed_unload == TRUE){
nebmodule_deinit(0,0);
! return 0;
}
--- 423,427 ----
if (delayed_unload == TRUE){
nebmodule_deinit(0,0);
! return -1;
}
|