Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2012-09-24 15:53:38 UTC (rev 10148)
+++ trunk/CHANGES 2012-09-24 19:48:32 UTC (rev 10149)
@@ -6,6 +6,7 @@
ENHANCEMENTS:
REST API for listing currently running monitoring servers
REST API for /status/hostgroup can now return information about service groups
+ REST API for /status/hostgroup allows searching from a point in the heirarchy downwards using fromhostgroupid
Remove some specified words from device interface ifDescr information to reduce instances of duplicate interface ids being used (level 3 added)
Warnings on multiple hosts using same IP when hosts are configured for MRTG
NOTICES:
Modified: trunk/opsview-core/lib/Runtime/ResultSet/OpsviewHostgroups.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/ResultSet/OpsviewHostgroups.pm 2012-09-24 15:53:38 UTC (rev 10148)
+++ trunk/opsview-core/lib/Runtime/ResultSet/OpsviewHostgroups.pm 2012-09-24 19:48:32 UTC (rev 10149)
@@ -31,6 +31,9 @@
$args ||= {};
$args->{extra_columns} = [qw(matpath leaf)];
+ # Save this for lookups later
+ my $allhgs_rs = $self;
+
# Filter by access first
$self = $self->search( { parentid => $filters->{parentid} } )
if ( exists $filters->{parentid} );
@@ -48,6 +51,18 @@
$self = $self->search( { "host_objects.hostname" => $filters->{host} } )
if ( exists $filters->{host} );
+ if ( exists $filters->{fromhostgroupid} ) {
+ my $input = convert_to_arrayref( $filters->{fromhostgroupid} );
+ my $search = [];
+ foreach my $p (@$input) {
+ my $hg = $allhgs_rs->find( { id => $p } );
+ if ($hg) {
+ push @$search, $hg->matpath . "%";
+ }
+ }
+ $self = $self->search( { "me.matpath" => { "-like" => $search } } );
+ }
+
if ( exists $filters->{only_leaves} ) {
$self = $self->search( { "lft" => \"=rgt-1" } );
}
Added: trunk/opsview-web/t/var/api-status/hostgroup_fromhostgroupid.testcase
===================================================================
--- trunk/opsview-web/t/var/api-status/hostgroup_fromhostgroupid.testcase (rev 0)
+++ trunk/opsview-web/t/var/api-status/hostgroup_fromhostgroupid.testcase 2012-09-24 19:48:32 UTC (rev 10149)
@@ -0,0 +1,107 @@
+GET /rest/status/hostgroup?fromhostgroupid=3&_only_leaves_=1
+ENDCONTENT
+{
+ "list" : [
+ {
+ "computed_state" : "critical",
+ "downtime" : "2",
+ "hostgroupid" : "4",
+ "hosts" : {
+ "down" : {
+ "handled" : "1",
+ "unhandled" : "1"
+ },
+ "handled" : "7",
+ "total" : "8",
+ "unhandled" : "1",
+ "up" : {
+ "handled" : "6"
+ }
+ },
+ "leaf" : "1",
+ "matpath" : [
+ {
+ "id" : "1",
+ "name" : "Opsview"
+ },
+ {
+ "id" : "3",
+ "name" : "UK"
+ }
+ ],
+ "name" : "Leaf",
+ "services" : {
+ "computed_state" : "unknown",
+ "handled" : "4",
+ "ok" : {
+ "handled" : "1"
+ },
+ "total" : "19",
+ "unhandled" : "15",
+ "unknown" : {
+ "handled" : "3",
+ "unhandled" : "15"
+ }
+ }
+ },
+ {
+ "computed_state" : "critical",
+ "downtime" : null,
+ "hostgroupid" : "2",
+ "hosts" : {
+ "handled" : "2",
+ "total" : "2",
+ "unhandled" : "0",
+ "up" : {
+ "handled" : "2"
+ }
+ },
+ "leaf" : "1",
+ "matpath" : [
+ {
+ "id" : "1",
+ "name" : "Opsview"
+ },
+ {
+ "id" : "3",
+ "name" : "UK"
+ }
+ ],
+ "name" : "Monitoring Servers",
+ "services" : {
+ "computed_state" : "critical",
+ "critical" : {
+ "unhandled" : "2"
+ },
+ "handled" : "2",
+ "ok" : {
+ "handled" : "2"
+ },
+ "total" : "4",
+ "unhandled" : "2"
+ }
+ }
+ ],
+ "summary" : {
+ "handled" : "15",
+ "host" : {
+ "down" : "2",
+ "handled" : "9",
+ "total" : "10",
+ "unhandled" : "1",
+ "up" : "8"
+ },
+ "service" : {
+ "critical" : "2",
+ "handled" : "6",
+ "ok" : "3",
+ "total" : "23",
+ "unhandled" : "17",
+ "unknown" : "18"
+ },
+ "total" : "33",
+ "totalhgs" : "16",
+ "unhandled" : "18"
+ }
+}
+