Skip to content

Instantly share code, notes, and snippets.

@fcingolani
Last active October 5, 2016 18:13
Show Gist options
  • Save fcingolani/b152563a95b952829701e733bb5e1347 to your computer and use it in GitHub Desktop.
Save fcingolani/b152563a95b952829701e733bb5e1347 to your computer and use it in GitHub Desktop.
Sensu check script for Umbraco's distributed cache last synced IDs
#! /usr/bin/env ruby
#
# check-umbraco-lastsyncedids.rb
#
# DESCRIPTION:
# Checks several Umbraco lastsynced.txt and compares their contents.
# Will trigger a CRIT or WARN if their difference is beyond thresholds.
#
# OUTPUT:
# plain text
#
# PLATFORMS:
# Windows
#
# DEPENDENCIES:
# gem: sensu-plugin
# REQUIRES: ActiveSupport version 4.0 or above.
#
# USAGE:
# check-umbraco-lastsyncedids.rb [-w N] [-c N] [files]
#
# EXAMPLE:
# check-umbraco-lastsyncedids.rb C:/inetpub/site/App_Data/TEMP/DistCache/umbracoBE/LMW3SVC1ROOT-lastsynced.txt //umbracoFE01/c$/inetpub/site/App_Data/TEMP/DistCache/umbracoFE01/LMW3SVC1ROOT-lastsynced.txt //umbracoFE02/c$/inetpub/site/App_Data/TEMP/DistCache/umbracoFE02/LMW3SVC1ROOT-lastsynced.txt
#
# LICENSE:
# Copyright 2016 <mail@fcingolani.com.ar>
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
#
require 'sensu-plugin/check/cli'
class CheckUmbracoLastSyncedIds < Sensu::Plugin::Check::CLI
option :warn,
:short => '-w WARN',
:proc => proc {|a| a.to_i },
:default => 3
option :crit,
:short => '-c CRIT',
:proc => proc {|a| a.to_i },
:default => 5
def run
ids = argv.map do |file|
File.read(file).to_i
end
diff = ids.max - ids.min
message ids.join(', ')
critical if diff > config[:crit]
warning if diff > config[:warn]
ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment