Sha256: 51bbbb79c45306c43a3d88467b69f43b87804fbce7e3c91fcf459dea8aff8d75

Contents?: true

Size: 616 Bytes

Versions: 1

Compression:

Stored size: 616 Bytes

Contents

#!/usr/bin/env ruby
require 'json'

def salt_state(output)
  out = JSON.parse(output)
  states = out["local"].values
  drifted_states = states.reject { |i| i["result"] }
  num_ok = states.count - drifted_states.count
  total = states.count
  state = num_ok == total ? "ok" : "warning"
  "#{state}:#{num_ok}:#{total}"
end

timeout = ARGV.shift || 240
begin
  out = `timeout -k 60s #{timeout}s salt-call state.highstate test=True --out=json --state-output=changes 2>/dev/null`
  if $?.exitstatus == 0
    puts salt_state(out)
  else
    puts "error:unknown:unknown"
  end
rescue
  puts "exception:unknown:unknown"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remon-0.1.0 lib/remon/scripts/salt-status