Title: [opsview] [12008] Add performance data to 'Opsview Updates' plugin
Revision
12008
Author
dferguson
Date
2013-04-09 12:20:21 +0100 (Tue, 09 Apr 2013)

Log Message

Add performance data to 'Opsview Updates' plugin

By customer request, and also helps to check for historical info when looking at MSP customers

Modified Paths

Modified: trunk/CHANGES
===================================================================
--- trunk/CHANGES	2013-04-09 11:17:15 UTC (rev 12007)
+++ trunk/CHANGES	2013-04-09 11:20:21 UTC (rev 12008)
@@ -12,6 +12,7 @@
     New Opspack: MySQL Server, replacing existing MySQL
     New Opspack: Apache HTTP Server, replacing existing Apache HTTP
     Management URLs open in a new window for http and https methods
+    Added performance data to the 'Opsview Updates' plugin
     NOTICES:
     Removed OS - Linux Advanced opspack from fresh installs
     FIXES:

Modified: trunk/opsview-core/nagios-plugins/check_opsview_update
===================================================================
--- trunk/opsview-core/nagios-plugins/check_opsview_update	2013-04-09 11:17:15 UTC (rev 12007)
+++ trunk/opsview-core/nagios-plugins/check_opsview_update	2013-04-09 11:20:21 UTC (rev 12008)
@@ -146,6 +146,16 @@
 $dbh->disconnect;
 
 $dbh = Opsview->db_Main;
+
+my $num_hosts      = $schema->resultset("Hosts")->count();
+my $num_contacts   = $schema->resultset("Contacts")->count();
+my $num_slaves     = $schema->resultset("Monitoringservers")->count() - 1;
+my $num_slavenodes = $schema->resultset("Monitoringclusternodes")->count();
+my $num_keywords   = $schema->resultset("Keywords")->count();
+my $num_logins     = $dbh->selectrow_array(
+    'SELECT COUNT(*) FROM auditlogs WHERE text LIKE "Successful login:%" AND datetime > CONVERT_TZ(NOW() - INTERVAL 1 DAY, @@session.time_zone,"+00:00")'
+);
+
 my $useragents = $dbh->selectcol_arrayref(
     "SELECT id FROM useragents WHERE last_update > NOW() - INTERVAL 1 MONTH"
 );
@@ -199,25 +209,23 @@
     my %advanced_stats = (
         uuid           => Opsview::Systempreference->uuid,
         hosthash       => uc($hosthash),
-        num_hosts      => $schema->resultset("Hosts")->count(),
+        num_hosts      => $num_hosts,
         num_services   => $num_services,
-        num_slaves     => $schema->resultset("Monitoringservers")->count() - 1,
-        num_slavenodes => $schema->resultset("Monitoringclusternodes")->count(),
-        num_contacts   => $schema->resultset("Contacts")->count(),
-        num_keywords   => $schema->resultset("Keywords")->count(),
+        num_slaves     => $num_slaves,
+        num_slavenodes => $num_slavenodes,
+        num_contacts   => $num_contacts,
+        num_keywords   => $num_keywords,
         num_api        => $schema->resultset("ApiSessions")->search(
             {
                 _one_time_token_ => 0,
                 accessed_at    => { ">" => time - 60 * 60 * 24 }
             }
           )->count,
-        "user_agent[]" => $useragents,
-        instance_id    => Opsview::Config->opsview_instance_id,
-        avg_reload     => Opsview::Reloadtime->average_duration,
-        perl_version   => $],
-        num_logins     => $dbh->selectrow_array(
-            'SELECT COUNT(*) FROM auditlogs WHERE text LIKE "Successful login:%" AND datetime > CONVERT_TZ(NOW() - INTERVAL 1 DAY, @@session.time_zone,"+00:00")'
-        ),
+        "user_agent[]"    => $useragents,
+        instance_id       => Opsview::Config->opsview_instance_id,
+        avg_reload        => Opsview::Reloadtime->average_duration,
+        perl_version      => $],
+        num_logins        => $num_logins,
         remote_opsview_db => $remote_opsview_db,
         snmptraps         => $snmptraps,
         odw               => 0,
@@ -256,6 +264,46 @@
     exit(0);
 }
 
+$np->add_perfdata(
+    label => 'num_hosts',
+    value => $num_hosts,
+);
+
+$np->add_perfdata(
+    label => 'num_services',
+    value => $num_services,
+);
+
+$np->add_perfdata(
+    label => 'num_contacts',
+    value => $num_contacts,
+);
+
+$np->add_perfdata(
+    label => 'num_slaves',
+    value => $num_slaves,
+);
+
+$np->add_perfdata(
+    label => 'num_slavenodes',
+    value => $num_slavenodes,
+);
+
+$np->add_perfdata(
+    label => 'num_keywords',
+    value => $num_keywords,
+);
+
+$np->add_perfdata(
+    label => 'num_logins',
+    value => $num_logins,
+);
+
+$np->add_perfdata(
+    label => 'num_snmptraps',
+    value => $snmptraps,
+);
+
 # Stop actual send if development. Check after showstats
 if ( !$local_opsview_version ) {
     $np->nagios_exit(

_______________________________________________
Opsview-checkins mailing list
Opsview-checkins@lists.opsview.org
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to