Title: [opsview] [10348] merge in highest state calculation if exclude_handled is in use
Revision
10348
Author
aburzynski
Date
2012-10-09 12:17:38 +0100 (Tue, 09 Oct 2012)

Log Message

merge in highest state calculation if exclude_handled is in use

Modified Paths


Property Changed


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093
/branches/nagvis-iframe:9764-9786
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837
   + /branches/DEV-capside/release-3.9.0:6365-6370
/branches/DEV-extra-notification-data:6734-6746
/branches/DEV-odw-calculations:9016-9160
/branches/DEV-restapi-monitoringservers:9778
/branches/DEV-snmp-multi:7324-7376
/branches/US187:9403-9479
/branches/US198b:8875-8994
/branches/US310:9851-9873
/branches/enterprise/BRAN-3.14:6874,6882,6956
/branches/enterprise/DEV-professional:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093,10345,10347
/branches/nagvis-iframe:9764-9786
/branches/us168:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/US306-slaves:9804-9823
/commercial/branches/US307-network-map:9685-9837


Property changes on: trunk/opsview-core/installer/apache_ssl.conf
___________________________________________________________________
Deleted: svn:mergeinfo
   - /branches/DEV-capside/release-3.9.0/opsview-core/installer/apache_proxy_ssl.conf:6365-6370
/branches/DEV-extra-notification-data/opsview-core/installer/apache_proxy_ssl.conf:6734-6746
/branches/DEV-odw-calculations/opsview-core/installer/apache_proxy_ssl.conf:9016-9160
/branches/DEV-restapi-monitoringservers/opsview-core/installer/apache_proxy_ssl.conf:9778
/branches/DEV-snmp-multi/opsview-core/installer/apache_proxy_ssl.conf:7324-7376
/branches/US187/opsview-core/installer/apache_proxy_ssl.conf:9403-9479
/branches/US198b/opsview-core/installer/apache_proxy_ssl.conf:8875-8994
/branches/US310/opsview-core/installer/apache_proxy_ssl.conf:9851-9873
/branches/enterprise/BRAN-3.14/opsview-core/installer/apache_proxy_ssl.conf:6874,6882,6956
/branches/enterprise/DEV-professional/opsview-core/installer/apache_proxy_ssl.conf:6494-8475,8477-8478,8486,8490,8492,8494,8499-8500,8515,8518-8519,8524,8527-8529,8531-8532,8536,8538,8540-8544,8547-8552,8554,8557,8600-8601,8637,8749,8772,8897,8917,8944-8945,8947,8950-8952,8967,8969,8979,8982,8987,8998,9006,9008,9011,9013,9026,9033-9036,9038,9040,9042,9044,9048,9050-9053,9062,9064-9065,9069,9078,9081,9088,9096,9099-9101,9103,9105,9115,9118,9347,9353-9354,9411,9432,9445,9486,9538-9550,9569-9571,9620,9635,9637-9638,9645-9647,9693,9699,9721,9814,9825,9857,9879,9881,9939,10002,10029,10038-10041,10070,10086,10093
/branches/nagvis-iframe/opsview-core/installer/apache_proxy_ssl.conf:9764-9786
/branches/us168/opsview-core/installer/apache_proxy_ssl.conf:8759,8762-8763,8766-8768,8770,8774-8777,8794,8798-8799,8801-8803,8821-8822,8834,8837-8838,8932,8937,8947,8969,8977,8981,9004,9007,9009-9010,9012,9024,9049
/commercial/branches/US306-slaves/opsview-core/installer/apache_proxy_ssl.conf:9804-9823
/commercial/branches/US307-network-map/opsview-core/installer/apache_proxy_ssl.conf:9685-9837

Modified: trunk/opsview-core/lib/Opsview/Utils.pm
===================================================================
--- trunk/opsview-core/lib/Opsview/Utils.pm	2012-10-09 10:56:20 UTC (rev 10347)
+++ trunk/opsview-core/lib/Opsview/Utils.pm	2012-10-09 11:17:38 UTC (rev 10348)
@@ -95,21 +95,28 @@
 }
 
 # TODO: Should look into using Nagios::Plugin
-sub max_state {
-    my ( $a, $b ) = @_;
-    return 2 if ( $a == 2 || $b == 2 );
-    return 1 if ( $a == 1 || $b == 1 );
-    return 0 if ( $a == 0 || $b == 0 );
-    return 3 if ( $a == 3 || $b == 3 );
-    return 4 if ( $a == 4 || $b == 4 );
+{
+    my $default_order = [ 2, 1, 0, 3, 4 ];
+
+    sub max_state {
+        my ( $a, $b, $order ) = @_;
+
+        for my $state ( @{ $order || $default_order } ) {
+            return $state if $a == $state || $b == $state;
+        }
+    }
 }
 
-sub max_state_text {
-    my ( $a, $b ) = @_;
-    return "critical" if ( $a eq "critical" || $b eq "critical" );
-    return "warning"  if ( $a eq "warning"  || $b eq "warning" );
-    return "ok"       if ( $a eq "ok"       || $b eq "ok" );
-    return "unknown"  if ( $a eq "unknown"  || $b eq "unknown" );
+{
+    my $default_order = [qw( critical warning ok unknown )];
+
+    sub max_state_text {
+        my ( $a, $b, $order ) = @_;
+
+        for my $state ( @{ $order || $default_order } ) {
+            return $state if $a eq $state || $b eq $state;
+        }
+    }
 }
 
 sub convert_state_to_text {

Modified: trunk/opsview-core/lib/Runtime/ResultSet.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/ResultSet.pm	2012-10-09 10:56:20 UTC (rev 10347)
+++ trunk/opsview-core/lib/Runtime/ResultSet.pm	2012-10-09 11:17:38 UTC (rev 10348)
@@ -35,6 +35,9 @@
     "1"    => 1,
 };
 
+# critical, warning, uknown, ok, ?
+my $default_unhandled_order = [ 2, 1, 3, 0, 4 ];
+
 sub list_summary {
     my ( $self, $filters, $args ) = @_;
 
@@ -274,7 +277,8 @@
             $status->{computed_state} = convert_state_to_text(
                 max_state(
                     $highest_host_unhandled_state,
-                    $highest_service_unhandled_state
+                    $highest_service_unhandled_state,
+                    $default_unhandled_order
                 )
             );
             $status->{services}->{computed_state} =
@@ -399,16 +403,19 @@
     my ( $current_max, $hash ) = @_;
 
     # host is not ok - set to critical
-    return max_state( $current_max, 2 ) if $hash->{host_state} > 0;
+    return max_state( $current_max, 2, $default_unhandled_order )
+      if $hash->{host_state} > 0;
 
-    return max_state( $current_max, $hash->{host_state} );
+    return max_state( $current_max, $hash->{host_state},
+        $default_unhandled_order );
 }
 
 sub max_service_unhandled_state {
     my ( $current_max, $hash ) = @_;
 
     # return new max
-    return max_state( $current_max, $hash->{service_state} );
+    return max_state( $current_max, $hash->{service_state},
+        $default_unhandled_order );
 }
 
 # We run downtimes separately because there could be lots of downtime for each

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to