]> granicus.if.org Git - icinga2/commitdiff
Improve output for the ido check task
authorGunnar Beutner <gunnar@beutner.name>
Thu, 12 Mar 2015 10:51:02 +0000 (11:51 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 12 Mar 2015 10:51:02 +0000 (11:51 +0100)
refs #8688

lib/db_ido/db_ido-check.conf
lib/db_ido/idochecktask.cpp

index 5994733d9e1fc2fc22629470449412e6db43e9ba..510c7a6e736d3f74f2e0a53c5f777d6f7e41ebc9 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 template CheckCommand "ido-check-command" {
-        execute = IdoCheck
+       execute = IdoCheck
 }
 
 object CheckCommand "ido" {
index 5a077596c39d562d3971c8366d0c1bed7bfb5d07..b5d51c9907df891d7f592459333955af8029692b 100644 (file)
@@ -58,6 +58,13 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
        if (resolvedMacros && !useResolvedMacros)
                return;
 
+       if (idoType.IsEmpty()) {
+               cr->SetOutput("Macro 'ido_type' must be set.");
+               cr->SetState(ServiceUnknown);
+               checkable->ProcessCheckResult(cr);
+               return;
+       }
+
        String idoName = MacroProcessor::ResolveMacros("$ido_name$", resolvers, checkable->GetLastCheckResult(),
            NULL, MacroProcessor::EscapeCallback(), resolvedMacros, useResolvedMacros);
 
@@ -87,9 +94,14 @@ void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult
 
        double qps = conn->GetQueryCount(60) / 60.0;
 
-       if (!conn->GetConnected() && conn->GetShouldConnect()) {
-               cr->SetOutput("Could not connect to the database server.");
-               cr->SetState(ServiceCritical);
+       if (!conn->GetConnected()) {
+               if (conn->GetShouldConnect()) {
+                       cr->SetOutput("Could not connect to the database server.");
+                       cr->SetState(ServiceCritical);
+               } else {
+                       cr->SetOutput("Not currently enabled: Another cluster instance is responsible for the IDO database.");
+                       cr->SetState(ServciceOK);
+               }
        } else {
                String schema_version = conn->GetSchemaVersion();