Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/CHANGES 2012-10-04 23:37:06 UTC (rev 10294)
@@ -5,6 +5,7 @@
ENHANCEMENTS:
Attributes are now allowed to use numbers in the name
Added enhanced monitoring for Oracle/PostgreSQL (new service checks to existing Host template), Microsoft SQL, Windows Server 2008 via WMI (Base/DNS/Exchange/IIS Terminal Services)
+ /rest/runtime/network?fromhostname=host now returns list back roughly based on depth of host
NOTICES:
FIXES:
Fixed apache configuration for redundancy, specifically removing apache_proxy_ssl.conf and replacing with apache_ssl.conf
Modified: trunk/opsview-core/bin/db_runtime
===================================================================
--- trunk/opsview-core/bin/db_runtime 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/bin/db_runtime 2012-10-04 23:37:06 UTC (rev 10294)
@@ -324,6 +324,7 @@
INSERT INTO schema_version (major_release, version) VALUES ('3.13', '11');
INSERT INTO schema_version (major_release, version) VALUES ('3.15', '9');
INSERT INTO schema_version (major_release, version, created_at) VALUES ('20120925hstpths', 'install', NOW());
+ INSERT INTO schema_version (major_release, version, created_at) VALUES ('20121004hstdepth', 'install', NOW());
-- Nagios portion of runtime database
source $topdir/../bin/ndo_mysql.sql;
Modified: trunk/opsview-core/bin/ndoutils_configdumpend
===================================================================
--- trunk/opsview-core/bin/ndoutils_configdumpend 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/bin/ndoutils_configdumpend 2012-10-04 23:37:06 UTC (rev 10294)
@@ -519,7 +519,7 @@
my $set_host_matpath = $dbh->prepare_cached(
qq{
- INSERT INTO $table (object_id, matpath) VALUES(?, ?)
+ INSERT INTO $table (object_id, matpath, depth) VALUES(?, ?, ?)
}
);
@@ -539,7 +539,7 @@
my $make_tree;
$make_tree = sub {
- my ( $id, @tree ) = @_;
+ my ( $id, $depth, @tree ) = @_;
return unless $id;
@@ -547,16 +547,16 @@
if (@parents) {
for my $parent (@parents) {
- $make_tree->( $parent, @tree, $id );
+ $make_tree->( $parent, $depth + 1, @tree, $id );
}
}
else { # reached root
push @tree, $id;
my $matpath = join( ',', reverse @tree ) . ",";
- $set_host_matpath->execute( $object_id, $matpath );
+ $set_host_matpath->execute( $object_id, $matpath, $depth );
}
};
- $make_tree->($object_id);
+ $make_tree->( $object_id, 1 );
};
for my $host_id (@$all_host_ids) {
$set_host_matpath->($host_id);
Modified: trunk/opsview-core/installer/upgradedb_runtime.pl
===================================================================
--- trunk/opsview-core/installer/upgradedb_runtime.pl 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/installer/upgradedb_runtime.pl 2012-10-04 23:37:06 UTC (rev 10294)
@@ -1337,6 +1337,18 @@
$db->updated;
}
+unless (
+ $db->is_installed(
+ "20121004hstdepth", "Adding hosts network depth", "all"
+ )
+ )
+{
+ $dbh->do(
+ qq{ ALTER TABLE opsview_hosts_matpaths ADD COLUMN depth INT UNSIGNED NOT NULL DEFAULT 0}
+ );
+ $db->updated;
+}
+
if ( $db_changed || $db->changed || $nagios_db->changed ) {
print "Finished updating database", $/;
}
Modified: trunk/opsview-core/lib/Runtime/ResultSet/OpsviewTopologyMap.pm
===================================================================
--- trunk/opsview-core/lib/Runtime/ResultSet/OpsviewTopologyMap.pm 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/lib/Runtime/ResultSet/OpsviewTopologyMap.pm 2012-10-04 23:37:06 UTC (rev 10294)
@@ -62,7 +62,10 @@
)->all;
$self = $self->search(
{ 'matpaths.matpath' => { '-like' => [ uniq(@matpaths) ] } },
- { join => { host => 'matpaths' } }
+ {
+ join => { host => 'matpaths' },
+ order_by => [ "matpaths.depth", "me.id" ],
+ }
);
$num_filters++;
}
@@ -160,19 +163,27 @@
# filter objects (hostgrups/monitored by etc.)
$self = $self->filter_objects( $filters, $args );
- my @list = ();
- my $last_object_id = 0;
- my $req_limit = $filters->{rows} ? $filters->{rows} - 1 : 0;
- my $limit_reached = -1;
- my %host_ids = ();
+ my @list = ();
+ my $req_limit = $filters->{rows} ? $filters->{rows} - 1 : 0;
+ my $limit_reached = -1;
+ my %host_ids = ();
while ( my $row = $self->next ) {
- ++$host_ids{ $row->{opsview_host_id} };
-
+ my $new_host;
+ unless ( exists $host_ids{ $row->{opsview_host_id} } ) {
+ $host_ids{ $row->{opsview_host_id} } = {
+ name => $row->{name},
+ parents => [],
+ children => [],
+ };
+ $new_host++;
+ }
next if $limit_reached > 0;
- if ( $last_object_id != $row->{opsview_host_id} ) {
+ my $this_host = $host_ids{ $row->{opsview_host_id} };
+ if ($new_host) {
+
# loaded all host parents and children - now just count allrows
if ( $limit_reached == 0 ) {
$limit_reached = 1;
@@ -184,21 +195,15 @@
$limit_reached = 0;
}
- push @list,
- {
- name => $row->{name},
- parents => [],
- children => [],
- };
+ push @list, $this_host;
- $last_object_id = $row->{opsview_host_id};
}
if ( $row->{parent_id} ) {
- push @{ $list[-1]->{parents} },
+ push @{ $this_host->{parents} },
$row->{parent_visible} ? $row->{parent_name} : undef;
}
if ( $row->{child_id} ) {
- push @{ $list[-1]->{children} },
+ push @{ $this_host->{children} },
$row->{child_visible} ? $row->{child_name} : undef;
}
}
Modified: trunk/opsview-core/t/var/runtime.test.db
===================================================================
--- trunk/opsview-core/t/var/runtime.test.db 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/t/var/runtime.test.db 2012-10-04 23:37:06 UTC (rev 10294)
@@ -12930,6 +12930,7 @@
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`object_id` int(10) NOT NULL,
`matpath` text NOT NULL,
+ `depth` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `object_id` (`object_id`)
) ENGINE=InnoDB;
@@ -12937,20 +12938,20 @@
LOCK TABLES `opsview_hosts_matpaths` WRITE;
/*!40000 ALTER TABLE `opsview_hosts_matpaths` DISABLE KEYS */;
-INSERT INTO `opsview_hosts_matpaths` VALUES (1,116,'116,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (2,135,'116,135,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (3,136,'116,136,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (4,137,'116,137,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (5,138,'116,138,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (6,115,'116,115,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (7,117,'116,117,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (8,118,'116,118,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (9,119,'116,119,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (10,120,'116,120,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (11,214,'214,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (12,215,'215,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (13,224,'224,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (14,225,'225,');
+INSERT INTO `opsview_hosts_matpaths` VALUES (1,116,'116,',1);
+INSERT INTO `opsview_hosts_matpaths` VALUES (2,135,'116,135,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (3,136,'116,136,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (4,137,'116,137,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (5,138,'116,138,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (6,115,'116,115,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (7,117,'116,117,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (8,118,'116,118,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (9,119,'116,119,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (10,120,'116,120,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (11,214,'214,',1);
+INSERT INTO `opsview_hosts_matpaths` VALUES (12,215,'215,',1);
+INSERT INTO `opsview_hosts_matpaths` VALUES (13,224,'224,',1);
+INSERT INTO `opsview_hosts_matpaths` VALUES (14,225,'225,',1);
/*!40000 ALTER TABLE `opsview_hosts_matpaths` ENABLE KEYS */;
UNLOCK TABLES;
@@ -13659,6 +13660,7 @@
INSERT INTO `schema_version` VALUES ('2.12','2',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('2.14','3',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('20120925hstpths','all','Adding hosts matpaths','2012-09-25 10:02:56',0);
+INSERT INTO `schema_version` VALUES ('20121004hstdepth','all','Adding hosts network depth','2012-10-04 15:39:40',0);
INSERT INTO `schema_version` VALUES ('3.0','1',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.11','6',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.13','11',NULL,NULL,NULL);
Modified: trunk/opsview-core/t/var/runtime.topology_test.db
===================================================================
--- trunk/opsview-core/t/var/runtime.topology_test.db 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-core/t/var/runtime.topology_test.db 2012-10-04 23:37:06 UTC (rev 10294)
@@ -5990,11 +5990,13 @@
/*!40000 ALTER TABLE `opsview_hosts` ENABLE KEYS */;
UNLOCK TABLES;
+
DROP TABLE IF EXISTS `opsview_hosts_matpaths`;
CREATE TABLE `opsview_hosts_matpaths` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`object_id` int(10) NOT NULL,
`matpath` text NOT NULL,
+ `depth` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `object_id` (`object_id`)
) ENGINE=InnoDB;
@@ -6002,25 +6004,25 @@
LOCK TABLES `opsview_hosts_matpaths` WRITE;
/*!40000 ALTER TABLE `opsview_hosts_matpaths` DISABLE KEYS */;
-INSERT INTO `opsview_hosts_matpaths` VALUES (1,16,'16,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (2,17,'16,17,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (3,10,'16,10,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (4,15,'16,3,15,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (5,15,'16,5,15,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (6,19,'16,19,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (7,3,'16,3,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (8,4,'16,4,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (9,5,'16,5,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (10,6,'16,3,6,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (11,21,'16,21,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (12,12,'16,12,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (13,7,'16,7,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (14,8,'16,8,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (15,20,'16,20,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (16,9,'16,3,6,9,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (17,18,'16,18,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (18,13,'16,13,');
-INSERT INTO `opsview_hosts_matpaths` VALUES (19,1,'16,1,');
+INSERT INTO `opsview_hosts_matpaths` VALUES (1,16,'16,',1);
+INSERT INTO `opsview_hosts_matpaths` VALUES (2,17,'16,17,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (3,10,'16,10,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (4,15,'16,3,15,',3);
+INSERT INTO `opsview_hosts_matpaths` VALUES (5,15,'16,5,15,',3);
+INSERT INTO `opsview_hosts_matpaths` VALUES (6,19,'16,19,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (7,3,'16,3,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (8,4,'16,4,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (9,5,'16,5,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (10,6,'16,3,6,',3);
+INSERT INTO `opsview_hosts_matpaths` VALUES (11,21,'16,21,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (12,12,'16,12,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (13,7,'16,7,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (14,8,'16,8,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (15,20,'16,20,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (16,9,'16,3,6,9,',4);
+INSERT INTO `opsview_hosts_matpaths` VALUES (17,18,'16,18,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (18,13,'16,13,',2);
+INSERT INTO `opsview_hosts_matpaths` VALUES (19,1,'16,1,',2);
/*!40000 ALTER TABLE `opsview_hosts_matpaths` ENABLE KEYS */;
UNLOCK TABLES;
@@ -6354,6 +6356,7 @@
INSERT INTO `schema_version` VALUES ('2.12','2',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('2.14','3',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('20120925hstpths','all','Adding hosts matpaths','2012-09-25 10:02:56',0);
+INSERT INTO `schema_version` VALUES ('20121004hstdepth','all','Adding hosts network depth','2012-10-04 16:26:37',0);
INSERT INTO `schema_version` VALUES ('3.0','1',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.11','6',NULL,NULL,NULL);
INSERT INTO `schema_version` VALUES ('3.13','11',NULL,NULL,NULL);
Modified: trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Runtime.pm
===================================================================
--- trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Runtime.pm 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-web/t/tests/Test/Opsview/Web/REST/Runtime.pm 2012-10-04 23:37:06 UTC (rev 10294)
@@ -478,16 +478,16 @@
'allrows' => 4,
'list' => [
{
+ 'name' => 'cisco',
+ 'children' => [ 'monitored_by_slave', 'cisco4' ],
+ 'parents' => ['opsview']
+ },
+ {
'name' => 'monitored_by_slave',
'children' => [],
'parents' => [ 'cisco', 'cisco3' ]
},
{
- 'name' => 'cisco',
- 'children' => [ 'monitored_by_slave', 'cisco4' ],
- 'parents' => ['opsview']
- },
- {
'name' => 'cisco4',
'children' => ['fake_ipv6'],
'parents' => ['cisco']
Modified: trunk/opsview-web/t/var/api-status/host_fromhostname.testcase
===================================================================
--- trunk/opsview-web/t/var/api-status/host_fromhostname.testcase 2012-10-04 22:54:54 UTC (rev 10293)
+++ trunk/opsview-web/t/var/api-status/host_fromhostname.testcase 2012-10-04 23:37:06 UTC (rev 10294)
@@ -16,6 +16,7 @@
"num_services" : "3",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"handled" : "0",
@@ -41,6 +42,7 @@
"num_services" : "3",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"handled" : "0",
@@ -55,7 +57,7 @@
{
"alias" : "cisco2",
"current_check_attempt" : "0",
- "downtime" : "2",
+ "downtime" : "1",
"flapping" : "1",
"icon" : "cisco",
"last_check" : "0",
@@ -65,6 +67,7 @@
"num_services" : "3",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"handled" : "0",
@@ -88,6 +91,7 @@
"num_services" : "3",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"handled" : "0",
@@ -111,6 +115,7 @@
"num_services" : "3",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"handled" : "1",
@@ -136,6 +141,7 @@
"num_services" : "5",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"critical" : {
@@ -162,6 +168,7 @@
"num_services" : "6",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"critical" : {
@@ -189,6 +196,7 @@
"num_services" : "6",
"output" : "Dummy output",
"state" : "up",
+ "state_duration" : "1349367730",
"state_type" : "soft",
"summary" : {
"critical" : {