[icinga-checkins] icinga.org: dashing-icinga2/master: Add widget for checks/1min ( replaces version widget), thanks Tobias von der Krone

git at icinga.org git at icinga.org
Sun Nov 27 19:16:59 CET 2016


Module: dashing-icinga2
Branch: master
Commit: b1e1cb95fe3738b9ee651f1577883d1c64091a48
URL:    https://git.icinga.org/?p=dashing-icinga2.git;a=commit;h=b1e1cb95fe3738b9ee651f1577883d1c64091a48

Author: Michael Friedrich <michael.friedrich at icinga.com>
Date:   Sun Nov 27 16:15:15 2016 +0100

Add widget for checks/1min (replaces version widget), thanks Tobias von der Krone

---

 dashboards/icinga2.erb |    2 +-
 jobs/icinga2.rb        |   19 +++++++++++++++----
 lib/icinga2.rb         |    9 +++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/dashboards/icinga2.erb b/dashboards/icinga2.erb
index 5cdff06..add7475 100644
--- a/dashboards/icinga2.erb
+++ b/dashboards/icinga2.erb
@@ -16,7 +16,7 @@ $(function() {
     </li>
 
     <li data-row="1" data-col="2" data-sizex="1" data-sizey="1">
-      <div data-id="icinga-version" data-view="Simplemon" data-title="Version" style="background-color: #0095bf;"></div>
+      <div data-id="icinga-checks" data-view="List" data-unordered="true" data-title="Checks (1 min)" style="background-color: #0095bf;"></div>
     </li>
     <li data-row="1" data-col="3" data-sizex="1" data-sizey="1">
       <div data-id="icinga-host-meter" data-view="Meter" data-title="Host Problems" data-min="0" data-max="100" style="background-color: #0095bf;"></div>
diff --git a/jobs/icinga2.rb b/jobs/icinga2.rb
index 57f2df3..efd66cc 100644
--- a/jobs/icinga2.rb
+++ b/jobs/icinga2.rb
@@ -42,6 +42,16 @@ SCHEDULER.every '5s', :first_in => 0 do |job|
 
   puts "Meter widget: Hosts " + host_meter.to_s + "/" + host_meter_max.to_s + " Services " + service_meter.to_s + "/" + service_meter_max.to_s
 
+  # check stats
+  check_stats = [
+    {"label" => "Host (active)", "value" => icinga.host_active_checks_1min},
+    #{"label" => "Host (passive)", "value" => icinga.host_passive_checks_1min},
+    {"label" => "Service (active)", "value" => icinga.service_active_checks_1min},
+    #{"label" => "Service (passive)", "value" => icinga.service_passive_checks_1min},
+  ]
+  puts "Checks: " + check_stats.to_s
+
+
   ### Events
   send_event('icinga-version', {
    value: icinga.version,
@@ -53,10 +63,6 @@ SCHEDULER.every '5s', :first_in => 0 do |job|
    moreinfo: icinga.app_starttime
   })
 
-  send_event('icinga-latency', {
-   value: icinga.avg_latency.to_s + "s",
-   color: 'blue' })
-
   send_event('icinga-host-meter', {
    value: host_meter,
    max:   host_meter_max,
@@ -69,6 +75,11 @@ SCHEDULER.every '5s', :first_in => 0 do |job|
    moreinfo: "Total services: " + service_meter_max.to_s,
    color: 'blue' })
 
+  send_event('icinga-checks', {
+   items: check_stats,
+   moreinfo: "Avg latency: " + icinga.avg_latency.to_s + "s",
+   color: 'blue' })
+
   # down, critical, warning, unknown
   send_event('icinga-host-down', {
    value: icinga.host_count_down.to_s,
diff --git a/lib/icinga2.rb b/lib/icinga2.rb
index 86eb767..75be467 100644
--- a/lib/icinga2.rb
+++ b/lib/icinga2.rb
@@ -34,6 +34,10 @@ class Icinga2
   # general stats
   attr_reader :avg_latency
   attr_reader :avg_execution_time
+  attr_reader :host_active_checks_1min
+  attr_reader :host_passive_checks_1min
+  attr_reader :service_active_checks_1min
+  attr_reader :service_passive_checks_1min
 
   # host stats
   attr_reader :host_count_all
@@ -271,5 +275,10 @@ class Icinga2
     @service_count_in_downtime = cib_data["num_services_in_downtime"].to_int
     @service_count_acknowledged = cib_data["num_services_acknowledged"].to_int
 
+    # check stats
+    @host_active_checks_1min = cib_data["active_host_checks_1min"]
+    @host_passive_checks_1min = cib_data["passive_host_checks_1min"]
+    @service_active_checks_1min = cib_data["active_service_checks_1min"]
+    @service_passive_checks_1min = cib_data["passive_service_checks_1min"]
   end
 end



More information about the icinga-checkins mailing list