Andrew Bogott has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/143332

Change subject: Simplify check_puppetrun.
......................................................................

Simplify check_puppetrun.

Previously it had different modes; now it just checks anything.

Now:

It reports staleness first.  If fresh, it reports compile failures.
If compile is working, it reports errors.  If no errors, it reports
time since last run.

Change-Id: I5a4439b18758a0915bc4ac6666f8f22435fb1689
---
M modules/base/files/monitoring/check_puppetrun
1 file changed, 33 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/32/143332/1

diff --git a/modules/base/files/monitoring/check_puppetrun 
b/modules/base/files/monitoring/check_puppetrun
index d16a6f3..52606bf 100755
--- a/modules/base/files/monitoring/check_puppetrun
+++ b/modules/base/files/monitoring/check_puppetrun
@@ -23,20 +23,15 @@
 warn = 0
 crit = 0
 enabled_only = false
-failures = false
 
 opt = OptionParser.new
 
-opt.on("--critical [CRIT]", "-c", Integer, "Critical threshold, time or failed 
resources") do |f|
+opt.on("--critical [CRIT]", "-c", Integer, "Critical staleness threshold, time 
in seconds") do |f|
     crit = f.to_i
 end
 
-opt.on("--warn [WARN]", "-w", Integer, "Warning thresold, time of failed 
resources") do |f|
+opt.on("--warn [WARN]", "-w", Integer, "Warning staleness threshold, time in 
seconds") do |f|
     warn = f.to_i
-end
-
-opt.on("--check-failures", "-f", "Check for failed resources instead of time 
since run") do |f|
-    failures = true
 end
 
 opt.on("--only-enabled", "-e", "Only alert if Puppet is enabled") do |f|
@@ -94,50 +89,35 @@
 
 time_since_last_run = Time.now.to_i - lastrun
 
-unless failures
-    if enabled_only && enabled == false
-        puts "OK: Puppet is currently disabled, not alerting. Last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        exit 0
-    end
-
-    if time_since_last_run >= crit
-        puts "CRITICAL: Puppet last ran #{time_since_last_run} seconds ago, 
expected < #{crit}"
-        exit 2
-
-    elsif time_since_last_run >= warn
-        puts "WARNING: Puppet last ran #{time_since_last_run} seconds ago, 
expected < #{warn}"
-        exit 1
-
-    else
-        if enabled
-            puts "OK: Puppet is currently enabled, last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        else
-            puts "OK: Puppet is currently disabled, last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        end
-
-        exit 0
-    end
-else
-    if enabled_only && enabled == false
-        puts "OK: Puppet is currently disabled, not alerting. Last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        exit 0
-    end
-
-    if failcount >= crit
-        puts "CRITICAL: Puppet last ran had #{failcount} failures, expected < 
#{crit}"
-        exit 2
-
-    elsif failcount >= warn
-        puts "WARNING: Puppet last ran had #{failcount} failures, expected < 
#{warn}"
-        exit 1
-
-    else
-        if enabled
-            puts "OK: Puppet is currently enabled, last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        else
-            puts "OK: Puppet is currently disabled, last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
-        end
-
-        exit 0
-    end
+if enabled_only && enabled == false
+    puts "OK: Puppet is currently disabled, not alerting. Last run 
#{time_since_last_run} seconds ago with #{failcount} failures"
+    exit 0
 end
+
+if time_since_last_run >= crit
+    puts "CRITICAL: Puppet last ran #{time_since_last_run} seconds ago, 
expected < #{crit}"
+    exit 2
+end
+
+if time_since_last_run >= warn
+    puts "WARNING: Puppet last ran #{time_since_last_run} seconds ago, 
expected < #{warn}"
+    exit 1
+end
+
+if failcount == 99
+    puts "CRITICAL: Complete puppet failure."
+    exit 2
+end
+
+if failcount > 0
+    puts "CRITICAL: Puppet has ${failcount} failures."
+    exit 2
+end
+
+if enabled
+    puts "OK: Puppet is currently enabled, last run #{time_since_last_run} 
seconds ago with #{failcount} failures"
+else
+    puts "OK: Puppet is currently disabled, last run #{time_since_last_run} 
seconds ago with #{failcount} failures"
+end
+
+exit 0

-- 
To view, visit https://gerrit.wikimedia.org/r/143332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a4439b18758a0915bc4ac6666f8f22435fb1689
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to