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/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
/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/US307-network-map:9686-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/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,9825
/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:9686-9837
Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES 2012-08-15 14:19:37 UTC (rev 9841)
+++ trunk/CHANGES 2012-08-15 14:34:27 UTC (rev 9842)
@@ -3,7 +3,9 @@
????? ???
FEATURES:
ENHANCEMENTS:
+ REST API for listing currently running monitoring servers
NOTICES:
+ Removed runtime.opsview_monitoringclusters, which was not used
FIXES:
Fixed possible issues when removing Debian packages
Modified: trunk/opsview-core/bin/db_runtime
===================================================================
--- trunk/opsview-core/bin/db_runtime 2012-08-15 14:19:37 UTC (rev 9841)
+++ trunk/opsview-core/bin/db_runtime 2012-08-15 14:34:27 UTC (rev 9842)
@@ -36,7 +36,7 @@
function dump_status {
echo "SET FOREIGN_KEY_CHECKS=0;"
- eval mysqldump $user_parms $db nagios_objects nagios_hoststatus nagios_servicestatus nagios_scheduleddowntime nagios_acknowledgements opsview_hostgroups opsview_hostgroup_hosts opsview_hosts opsview_contact_hosts opsview_contact_objects opsview_contact_services opsview_host_objects opsview_host_services opsview_monitoringclusternodes opsview_monitoringclusters opsview_performance_metrics opsview_viewports opsview_servicechecks opsview_servicegroups
+ eval mysqldump $user_parms $db nagios_objects nagios_hoststatus nagios_servicestatus nagios_scheduleddowntime nagios_acknowledgements opsview_hostgroups opsview_hostgroup_hosts opsview_hosts opsview_contact_hosts opsview_contact_objects opsview_contact_services opsview_host_objects opsview_host_services opsview_monitoringservers opsview_monitoringclusternodes opsview_performance_metrics opsview_viewports opsview_servicechecks opsview_servicegroups
echo "SET FOREIGN_KEY_CHECKS=1;"
}
@@ -223,7 +223,7 @@
alias varchar(255) NOT NULL DEFAULT '',
icon_filename varchar(128) NOT NULL DEFAULT '',
hostgroup_id int NOT NULL DEFAULT 0, # Links to leaf hostgroup
- monitored_by int NOT NULL DEFAULT 0, # Links to opsview_monitoringclusters
+ monitored_by int NOT NULL DEFAULT 0, # Links to opsview_monitoringservers
primary_node int, # Links to opsview_monitoringclusternodes
secondary_node int,
num_interfaces INT NOT NULL DEFAULT 0,
@@ -236,18 +236,20 @@
INDEX (num_children)
) ENGINE=InnoDB;
- CREATE TABLE opsview_monitoringclusters (
- id int NOT NULL DEFAULT 0 PRIMARY KEY,
+ CREATE TABLE opsview_monitoringservers (
+ id int NOT NULL DEFAULT 0,
name varchar(64) NOT NULL DEFAULT '',
- hostname varchar(64), # These two only make sense for the master
- ip varchar(255)
- ) ENGINE=InnoDB;
+ activated BOOLEAN DEFAULT 1 NOT NULL,
+ passive BOOLEAN DEFAULT 0 NOT NULL,
+ nodes TEXT NOT NULL,
+ PRIMARY KEY (id)
+ ) ENGINE=InnoDB COMMENT="Runtime list of monitoring servers";
CREATE TABLE opsview_monitoringclusternodes (
id int NOT NULL DEFAULT 0 PRIMARY KEY,
name varchar(64) NOT NULL DEFAULT '', # This will be the hostname of the node
ip varchar(255) NOT NULL DEFAULT ''
- ) ENGINE=InnoDB;
+ ) ENGINE=InnoDB COMMENT="Runtime list of monitoring cluster nodes";
# Set primary key for t/78configdumpend.t test
# Primary has to be auto increment id because service_object_id is 0 and calculated afterwards
@@ -307,7 +309,7 @@
INSERT INTO schema_version (major_release, version) VALUES ('3.9', '1');
INSERT INTO schema_version (major_release, version) VALUES ('3.11', '6');
INSERT INTO schema_version (major_release, version) VALUES ('3.13', '9');
- INSERT INTO schema_version (major_release, version) VALUES ('3.15', '6');
+ INSERT INTO schema_version (major_release, version) VALUES ('3.15', '8');
-- 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-08-15 14:19:37 UTC (rev 9841)
+++ trunk/opsview-core/bin/ndoutils_configdumpend 2012-08-15 14:34:27 UTC (rev 9842)
@@ -145,16 +145,22 @@
" );
rename_table($table);
-$table = copy_table( 'opsview_monitoringclusters' );
+$table = copy_table( 'opsview_monitoringservers' );
$dbh->do( "
INSERT INTO $table
-SELECT monitoringservers.id, monitoringservers.name, oh.name, oh.ip
+SELECT monitoringservers.id, monitoringservers.name, monitoringservers.activated, monitoringservers.passive,
+ GROUP_CONCAT(hosts.name)
FROM
$opsview_db.monitoringservers monitoringservers
LEFT JOIN
- $opsview_db.hosts oh
+ $opsview_db.monitoringclusternodes
ON
- monitoringservers.host = oh.id
+ monitoringservers.id = monitoringclusternodes.monitoringcluster
+LEFT JOIN
+ $opsview_db.hosts hosts
+ON
+ monitoringservers.host = hosts.id
+GROUP BY monitoringservers.id
" );
rename_table($table);
Modified: trunk/opsview-core/filelist
===================================================================
--- trunk/opsview-core/filelist 2012-08-15 14:19:37 UTC (rev 9841)
+++ trunk/opsview-core/filelist 2012-08-15 14:34:27 UTC (rev 9842)
@@ -268,6 +268,7 @@
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewHostObjects.pm lib/Runtime/Schema/OpsviewHostObjects.pm
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewHostServices.pm lib/Runtime/Schema/OpsviewHostServices.pm
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewHosts.pm lib/Runtime/Schema/OpsviewHosts.pm
+f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewMonitoringserver.pm lib/Runtime/Schema/OpsviewMonitoringserver.pm
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewPerformanceMetrics.pm lib/Runtime/Schema/OpsviewPerformanceMetrics.pm
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewServicechecks.pm lib/Runtime/Schema/OpsviewServicechecks.pm
f nagios:nagios 0644 /usr/local/nagios/lib/Runtime/Schema/OpsviewServicegroups.pm lib/Runtime/Schema/OpsviewServicegroups.pm
Modified: trunk/opsview-core/installer/upgradedb_runtime.pl
===================================================================
--- trunk/opsview-core/installer/upgradedb_runtime.pl 2012-08-15 14:19:37 UTC (rev 9841)
+++ trunk/opsview-core/installer/upgradedb_runtime.pl 2012-08-15 14:34:27 UTC (rev 9842)
@@ -1273,6 +1273,28 @@
$db->updated;
}
+if ( $db->is_lower('3.15.7') ) {
+ $db->print( "Removing unused table opsview_monitoringclusters" );
+ $dbh->do( "DROP TABLE opsview_monitoringclusters" );
+ $db->updated;
+}
+if ( $db->is_lower('3.15.8') ) {
+ $db->print( "Adding monitoring servers to runtime db" );
+ $dbh->do(
+ qq{
+CREATE TABLE opsview_monitoringservers (
+ id int NOT NULL DEFAULT 0,
+ name varchar(64) NOT NULL DEFAULT '',
+ activated BOOLEAN DEFAULT 1 NOT NULL,
+ passive BOOLEAN DEFAULT 0 NOT NULL,
+ nodes TEXT NOT NULL,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB COMMENT="Runtime list of monitoring servers"
+ }
+ );
+ $db->updated;
+}
+
if ( $db_changed || $db->changed || $nagios_db->changed ) {
print "Finished updating database", $/;
}
Copied: trunk/opsview-core/lib/Runtime/Schema/OpsviewMonitoringserver.pm (from rev 9825, branches/enterprise/DEV-professional/opsview-core/lib/Runtime/Schema/OpsviewMonitoringserver.pm)
===================================================================
--- trunk/opsview-core/lib/Runtime/Schema/OpsviewMonitoringserver.pm (rev 0)
+++ trunk/opsview-core/lib/Runtime/Schema/OpsviewMonitoringserver.pm 2012-08-15 14:34:27 UTC (rev 9842)
@@ -0,0 +1,115 @@
+use utf8;
+
+package Runtime::Schema::OpsviewMonitoringserver;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Runtime::Schema::OpsviewMonitoringserver - Runtime list of monitoring servers
+
+=cut
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+
+=head1 TABLE: C<opsview_monitoringservers>
+
+=cut
+
+__PACKAGE__->table( "opsview_monitoringservers" );
+
+=head1 ACCESSORS
+
+=head2 id
+
+ data_type: 'integer'
+ default_value: 0
+ is_nullable: 0
+
+=head2 name
+
+ data_type: 'varchar'
+ default_value: (empty string)
+ is_nullable: 0
+ size: 64
+
+=head2 activated
+
+ data_type: 'tinyint'
+ default_value: 1
+ is_nullable: 0
+
+=head2 passive
+
+ data_type: 'tinyint'
+ default_value: 0
+ is_nullable: 0
+
+=head2 nodes
+
+ data_type: 'text'
+ is_nullable: 0
+
+=cut
+
+__PACKAGE__->add_columns(
+ "id",
+ {
+ data_type => "integer",
+ default_value => 0,
+ is_nullable => 0
+ },
+ "name",
+ {
+ data_type => "varchar",
+ default_value => "",
+ is_nullable => 0,
+ size => 64
+ },
+ "activated",
+ {
+ data_type => "tinyint",
+ default_value => 1,
+ is_nullable => 0
+ },
+ "passive",
+ {
+ data_type => "tinyint",
+ default_value => 0,
+ is_nullable => 0
+ },
+ "nodes",
+ {
+ data_type => "text",
+ is_nullable => 0
+ },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key( "id" );
+
+__PACKAGE__->has_many(
+ "hosts",
+ "Runtime::Schema::OpsviewHosts",
+ { "foreign.monitored_by" => "self.id" },
+ { join_type => "inner" }
+);
+
+# Created by DBIx::Class::Schema::Loader v0.07025 @ 2012-08-13 14:19:50
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1LsKpwiNe3Ap/MJCM0i9BA
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;
Modified: trunk/opsview-core/t/var/runtime.test.db
===================================================================
--- trunk/opsview-core/t/var/runtime.test.db 2012-08-15 14:19:37 UTC (rev 9841)
+++ trunk/opsview-core/t/var/runtime.test.db 2012-08-15 14:34:27 UTC (rev 9842)
@@ -12931,7 +12931,7 @@
`name` varchar(64) NOT NULL DEFAULT '',
`ip` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
-) ENGINE=InnoDB;
+) ENGINE=InnoDB COMMENT='Runtime list of monitoring cluster nodes';
LOCK TABLES `opsview_monitoringclusternodes` WRITE;
@@ -12940,19 +12940,21 @@
UNLOCK TABLES;
-DROP TABLE IF EXISTS `opsview_monitoringclusters`;
-CREATE TABLE `opsview_monitoringclusters` (
+DROP TABLE IF EXISTS `opsview_monitoringservers`;
+CREATE TABLE `opsview_monitoringservers` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(64) NOT NULL DEFAULT '',
- `hostname` varchar(64) DEFAULT NULL,
- `ip` varchar(255) DEFAULT NULL,
+ `activated` tinyint(1) NOT NULL DEFAULT '1',
+ `passive` tinyint(1) NOT NULL DEFAULT '0',
+ `nodes` text NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB;
+) ENGINE=InnoDB COMMENT='Runtime list of monitoring servers';
-LOCK TABLES `opsview_monitoringclusters` WRITE;
-/*!40000 ALTER TABLE `opsview_monitoringclusters` DISABLE KEYS */;
-/*!40000 ALTER TABLE `opsview_monitoringclusters` ENABLE KEYS */;
+LOCK TABLES `opsview_monitoringservers` WRITE;
+/*!40000 ALTER TABLE `opsview_monitoringservers` DISABLE KEYS */;
+INSERT INTO `opsview_monitoringservers` VALUES (1,'Master Monitoring Server',1,0,'opsview');
+/*!40000 ALTER TABLE `opsview_monitoringservers` ENABLE KEYS */;
UNLOCK TABLES;
@@ -13606,7 +13608,7 @@
INSERT INTO `schema_version` VALUES ('3.9','1');
INSERT INTO `schema_version` VALUES ('3.11','6');
INSERT INTO `schema_version` VALUES ('3.13','10');
-INSERT INTO `schema_version` VALUES ('3.15','6');
+INSERT INTO `schema_version` VALUES ('3.15','8');
/*!40000 ALTER TABLE `schema_version` ENABLE KEYS */;
UNLOCK TABLES;
Copied: trunk/opsview-web/lib/Opsview/Web/Controller/REST/Runtime/Monitoringserver.pm (from rev 9825, branches/enterprise/DEV-professional/opsview-web/lib/Opsview/Web/Controller/REST/Runtime/Monitoringserver.pm)
===================================================================
--- trunk/opsview-web/lib/Opsview/Web/Controller/REST/Runtime/Monitoringserver.pm (rev 0)
+++ trunk/opsview-web/lib/Opsview/Web/Controller/REST/Runtime/Monitoringserver.pm 2012-08-15 14:34:27 UTC (rev 9842)
@@ -0,0 +1,88 @@
+#
+# AUTHORS:
+# Copyright (C) 2003-2012 Opsview Limited. All rights reserved
+#
+# This file is part of Opsview
+#
+#
+package Opsview::Web::Controller::REST::Runtime::Monitoringserver;
+
+use Moose;
+use namespace::autoclean;
+
+BEGIN { extends 'Opsview::Web::ControllerBase::REST' }
+
+sub apply_restrictions : Private {
+ my ( $self, $c ) = @_;
+ my $rs = $c->model( "RuntimeSchema::OpsviewMonitoringserver" );
+
+ # List monitoring servers where the hosts are visible to the current user
+ $rs =
+ $c->forward( "/common/apply_restrictions",
+ [ $rs, { "hosts" => "contacts" } ]
+ );
+ $c->stash( rs => $rs );
+}
+
+sub monitoringserver : Chained("/rest/runtime_root") : Args(0) :
+ PathPart("monitoringserver") : ActionClass('REST') {
+ shift->apply_restrictions(shift);
+}
+
+sub monitoringserver_GET : Does(ACL) : AllowedRole(VIEWSOME) :
+ AllowedRole(VIEWALL) : ACLDetachTo(/access_denied) {
+ my ( $self, $c ) = @_;
+ my $rs = $c->stash->{rs};
+ my $filters = $c->stash->{status_params} || { %{ $c->req->params } };
+
+ $rs = $rs->search(
+ {},
+ {
+ "+select" =>
+ [ "me.id", "me.name", "me.activated", "me.passive", "me.nodes", ],
+ "+as" => [ "id", "name", "activated", "passive", "nodes", ],
+ "group_by" => ["me.id"],
+ }
+ );
+
+ if ( $filters->{include_hosts} ) {
+ $rs = $rs->search(
+ {},
+ {
+ join => "hosts",
+ "+select" => [ \"GROUP_CONCAT(hosts.name)" ],
+ "+as" => "hostnames",
+ }
+ );
+ }
+
+ my $result = {};
+ my @list;
+ while ( my $ms = $rs->next ) {
+
+ my $hash = {
+ id => $ms->id,
+ name => $ms->name,
+ activated => $ms->activated,
+ passive => $ms->passive,
+ };
+
+ # Magic! As runtime DB stores this as a comma separated list, we use this knowledge to quickly construct the list
+ # of nodes
+ $hash->{nodes} =
+ [ map { { name => $_ } } ( split( ",", $ms->nodes ) ) ];
+
+ if ( $filters->{include_hosts} ) {
+ $hash->{hosts} =
+ [ map { { name => $_ } }
+ ( split( ",", $ms->get_column("hostnames") ) ) ];
+ }
+ push @list, $hash;
+ }
+ $result->{list} = \@list;
+
+ $c->stash( "rest" => $result );
+}
+
+__PACKAGE__->meta->make_immutable;
+1;