whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Bazley <s...@apache.org>
Subject [whimsy.git] [1/1] Commit 62df2de: Initial code for system-related status checks
Date Fri, 01 Apr 2016 18:44:36 GMT
Commit 62df2de2682ab99e11ca7797f2f714beab1c7368:
    Initial code for system-related status checks


Branch: refs/heads/master
Author: Sebb <sebb@apache.org>
Committer: Sebb <sebb@apache.org>
Pusher: sebb <sebb@apache.org>

------------------------------------------------------------
www/status/monitors/system.rb                                | ++++++++++ 
------------------------------------------------------------
39 changes: 39 additions, 0 deletions.
------------------------------------------------------------


diff --git a/www/status/monitors/system.rb b/www/status/monitors/system.rb
new file mode 100644
index 0000000..029da34
--- /dev/null
+++ b/www/status/monitors/system.rb
@@ -0,0 +1,39 @@
+#
+# Monitor status of system
+# Currently only checks puppet
+#
+
+require 'time'
+
+def Monitor.system(previous_status)
+  name='puppet'
+  status = {}
+  status[name] = {
+    mtime: Time.now.gmtime.iso8601,
+    command: 'service puppet status'
+  }
+  begin
+    puppet = `service puppet status`.strip
+    if puppet.include? ' * agent is running'
+      status[name].merge! level: 'warning', title: puppet
+    end
+    rescue Exception => e
+      status[name] = {
+        level: 'danger',
+        data: {
+          exception: {
+            level: 'danger',
+            text: e.inspect,
+            data: e.backtrace
+          }
+        }
+      }
+  end
+  {data: status}
+end
+
+# for debugging purposes
+if __FILE__ == $0
+  require 'json'
+  puts JSON.pretty_generate(Monitor.system(nil))
+end

Mime
View raw message