Author:   Lars Michelsen <[email protected]>
Date:     Sun Dec 29 19:45:21 2013 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Sun Dec 29 19:45:21 2013 +0100

FIX: The NagiosBP backend is now usable again

---

 ChangeLog                                          |    1 +
 .../server/core/classes/GlobalBackendnagiosbp.php  |   80 +++++++++++++++-----
 2 files changed, 63 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a02c11..3bce533 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@ Core:
   * FIX: Encoding _origtarget URL parameter handed over to multisite now
   * FIX: The NDO backend is now usable again with maps and automaps
     (Just for the next stable release - on the later releases it will be 
dropped)
+  * FIX: The NagiosBP backend is now usable again
   * FIX: Fixed host alias attribute in livestatus backend
 
 1.8b1
diff --git a/share/server/core/classes/GlobalBackendnagiosbp.php 
b/share/server/core/classes/GlobalBackendnagiosbp.php
index 5241f5f..3220e91 100644
--- a/share/server/core/classes/GlobalBackendnagiosbp.php
+++ b/share/server/core/classes/GlobalBackendnagiosbp.php
@@ -174,30 +174,30 @@ class GlobalBackendnagiosbp implements 
GlobalBackendInterface {
 
     private function getBPState($state) {
         if($state == null)
-            $state = 'UNKNOWN';
-        return $state;
+            $state = UNKNOWN;
+        return state_num($state);
     }
 
     private function getBPCounts($bp) {
         $c = Array(
-            'PENDING' => Array(
+            PENDING => Array(
                 'normal'   => 0,
             ),
-            'OK' => Array(
+            OK => Array(
                 'normal'   => 0,
                 'downtime' => 0,
             ),
-            'WARNING' => Array(
+            WARNING => Array(
                 'normal'   => 0,
                 'ack'      => 0,
                 'downtime' => 0,
             ),
-            'CRITICAL' => Array(
+            CRITICAL => Array(
                 'normal'   => 0,
                 'ack'      => 0,
                 'downtime' => 0,
             ),
-            'UNKNOWN' => Array(
+            UNKNOWN => Array(
                 'normal'   => 0,
                 'ack'      => 0,
                 'downtime' => 0,
@@ -308,23 +308,67 @@ class GlobalBackendnagiosbp implements 
GlobalBackendInterface {
             foreach($bp['components'] AS $comp) {
                 if(isset($comp['service'])) {
                     // Service
-                    $ret[$key][] = Array(
-                        'host_name'           => $comp['host'],
-                        'service_description' => $comp['service'],
-                        'state'               => 
$this->getBPState($comp['hardstate']),
-                        'output'              => '',
+                    //$ret[$key][] = Array(
+                    //    STATE => $this->getBPState($comp['hardstate']),
+                    //    OUTPUT => '',
+                    //    ALIAS => $comp['host'],
+                    //    DESCRIPTION => $comp['service'],
+                    //);
+                    $ret[$key][] = array(
+                        $this->getBPState($comp['hardstate']),
+                        '',  // output
+                        0,
+                        0,
+                        1,  // state type
+                        1, // current attempt
+                        1, // max check attempts
+                        null,  // last check
+                        null,  // next check
+                        null, // last hard state change
+                        null, // last state change
+                        '', // perfdata
+                        $comp['service'],  // display name
+                        $comp['service'],  // alias
+                        '',  // address
+                        '',  // notes
+                        '', // check command
+                        null,
+                        null, // dt author
+                        null, // dt data
+                        null, // dt start
+                        null, // dt end
+                        $comp['service'] // descr
                     );
                 } else {
                     // BP
-                    $childBP = Array(
-                        'host_name'           => $comp['subprocess'],
-                        'service_description' => $comp['display_name'],
-                        'state'               => 
$this->getBPState($comp['hardstate']),
-                        'output'              => '',
+                    $childBP = array(
+                        $this->getBPState($comp['hardstate']),
+                        '',  // output
+                        0,
+                        0,
+                        1,  // state type
+                        1, // current attempt
+                        1, // max check attempts
+                        null,  // last check
+                        null,  // next check
+                        null, // last hard state change
+                        null, // last state change
+                        '', // perfdata
+                        $comp['display_name'],  // display name
+                        $comp['display_name'],  // alias
+                        '',  // address
+                        '',  // notes
+                        '', // check command
+                        null,
+                        null, // dt author
+                        null, // dt data
+                        null, // dt start
+                        null, // dt end
+                        $comp['display_name'] // descr
                     );
 
                     if(isset($bps[$comp['subprocess']]['external_info']))
-                        $childBP['output'] = 
$bps[$comp['subprocess']]['external_info'];
+                        $childBP[OUTPUT] = 
$bps[$comp['subprocess']]['external_info'];
 
                     $ret[$key][] = $childBP;
                 }


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to