Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

[dev.icinga.com #1111] keep looping to get the instance_name #510

Closed
icinga-migration opened this issue Jan 12, 2011 · 2 comments
Closed

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/1111

Created by mfriedrich on 2011-01-12 16:00:42 +00:00

Assignee: (none)
Status: Closed (closed on 2011-05-19 11:43:27 +00:00)
Target Version: (none)
Last Update: 2014-12-08 14:46:13 +00:00 (in Redmine)


like housekeeping thread does.

https://secure.opsera.com/wsvn/wsvn/opsview/trunk/opsview-base/patches/ndoutils\_retry\_instance\_name.patch

diff -ur ndoutils-1.4b7.original/src/db.c ndoutils-1.4b7/src/db.c
--- ndoutils-1.4b7.original/src/db.c    2009-09-01 12:24:51.000000000 +0000
+++ ndoutils-1.4b7/src/db.c     2009-10-05 14:56:49.000000000 +0000
@@ -291,12 +291,25 @@
        int result=NDO_OK;
        int have_instance=NDO_FALSE;
        time_t current_time;
+       int retries=0;

        /* make sure we have an instance name */
        if(idi->instance_name==NULL)
                idi->instance_name=strdup("default");

        /* get existing instance */
+       /* Opsera patch. Keep looping to get the instance id from the select */
+       /* This is because there will be a constraint on the instance_name */
+       /* Indentation not corrected for easier patching */
+       while (have_instance == NDO_FALSE) {
+
+       if(retries>0) {
+               syslog(LOG_USER|LOG_INFO,"Did not find instance_name '%s' - retrying", idi->instance_name);
+       }
+       if(retries>1) {
+               sleep(1);
+       }
+
        if(asprintf(&buf,"SELECT instance_id FROM %s WHERE instance_name='%s'",ndo2db_db_tablenames[NDO2DB_DBTABLE_INSTANCES],idi->instance_name)==-1)
                buf=NULL;
        if((result=ndo2db_db_query(idi,buf))==NDO_OK){
@@ -326,7 +339,10 @@
                        switch(idi->dbinfo.server_type){
                        case NDO2DB_DBSERVER_MYSQL:
 #ifdef USE_MYSQL
-                               idi->dbinfo.instance_id=mysql_insert_id(&idi->dbinfo.mysql_conn);
+                               /* Part of Opsera patch to ignore id and re-search again */
+                               /*
+                               idi->dbinfo.instance_id=mysql_insert_id(&idi->dbinfo.mysql_conn);
+                               */
 #endif
                                break;
                        default:
@@ -335,6 +351,11 @@
                        }
                free(buf);
                }
+
+       retries++;
+
+       /* End while for instance_name */
+       }

        ts=ndo2db_db_timet_to_sql(idi,idi->data_start_time);
@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-05-19 11:43:27 +00:00

  • Status changed from New to Closed

i do think this could be used, if the current method fails, but not now.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2014-12-08 14:46:13 +00:00

  • Project changed from 18 to Core, Classic UI, IDOUtils
  • Category set to IDOUtils

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant