Created
August 21, 2012 13:02
-
-
Save jiphex/3415222 to your computer and use it in GitHub Desktop.
Xerox Workcenter printer status thingy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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