Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created August 21, 2012 13:02
Show Gist options
  • Save jiphex/3415222 to your computer and use it in GitHub Desktop.
Save jiphex/3415222 to your computer and use it in GitHub Desktop.
Xerox Workcenter printer status thingy
#!/usr/bin/env ruby
require 'snmp'
# usage: printerstatus.rb printer.host.name community.name
# no output unless error, returns zero if status is ok
SNMP::Manager.open(:Host=>ARGV[0],:Community=>ARGV[1]) do |manager|
resp = manager.get(["SNMPv2-SMI::mib-2.43.18.1.1.8.1.1"])
resp.each_varbind do |varbind|
exit(0) if varbind.value.to_s == "noSuchInstance"
exit(0) if varbind.value.to_s =~ /Power Saver/
puts varbind.value.to_s
exit 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment