From 89a5d7491d1d5e18290ea41f71afb89852756cf1 Mon Sep 17 00:00:00 2001
From: Per Cederqvist <ceder@lysator.liu.se>
Date: Fri, 11 Feb 2011 09:13:57 +0000
Subject: [PATCH] check_cups can now invoke lpstat without the -h option.

---
 check_cups | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/check_cups b/check_cups
index 52cf87c..fa6eae0 100755
--- a/check_cups
+++ b/check_cups
@@ -18,7 +18,10 @@ def check_queue(host, queue):
     worst_user = None
     ctr = 0
 
-    fd = os.popen("lpstat -h %s -o %s" % (host, queue))
+    if host is None:
+        fd = os.popen("lpstat -o %s" % (queue, ))
+    else:
+        fd = os.popen("lpstat -h %s -o %s" % (host, queue))
     for line in fd:
 	ctr = ctr + 1
         qid, who, size, when = line.strip().split(None, 3)
@@ -49,4 +52,7 @@ def check_queue(host, queue):
 	
     
 if __name__ == '__main__':
-    check_queue(sys.argv[1], sys.argv[2])
+    if len(sys.argv) == 2:
+        check_queue(None, sys.argv[1])
+    else:
+        check_queue(sys.argv[1], sys.argv[2])        
-- 
GitLab