root / pykota / trunk / bin / snmpprinterstatus @ 2146

Revision 2146, 1.7 kB (checked in by jerome, 19 years ago)

It seems that $Log$ is not implemented or doesn't work for some reason

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#! /usr/bin/env python
2# -*- coding: ISO-8859-15 -*-
3#
4# PyKota
5#
6# PyKota : Print Quotas for CUPS and LPRng
7#
8# (c) 2003, 2004, 2005 Jerome Alet <alet@librelogiciel.com>
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22#
23# $Id$
24#
25#
26
27import sys
28import os
29import time
30
31OIDS = ["hrPrinterDetectedErrorState", "hrPrinterStatus", "hrDeviceStatus"]
32SNMPCOMMAND = "snmpget -v1 -c public -Ov %(printer)s HOST-RESOURCES-MIB::%(oid)s.1" 
33
34def main() :
35    if len(sys.argv) != 2 :
36        sys.stderr.write("usage : snmpprinterstatus yourprinter.example.com\n")
37    else :   
38        printer = sys.argv[1]
39        while 1 :
40            try :
41                for oid in OIDS :   
42                    command = SNMPCOMMAND % locals()
43                    output = os.popen(command)
44                    result = output.read().strip()
45                    status = output.close()
46                    print oid, "===>", result
47            except KeyboardInterrupt :       
48                break
49            time.sleep(0.5)
50
51if __name__ == "__main__" :
52    sys.exit(main())
Note: See TracBrowser for help on using the browser.