]> git.siccegge.de Git - tools.git/commitdiff
Add verbose mode to make it more usefull as an icinga2 plugin
authorChristoph Egger <christoph@anonymous.siccegge.de>
Wed, 29 Oct 2014 22:10:43 +0000 (23:10 +0100)
committerChristoph Egger <christoph@anonymous.siccegge.de>
Wed, 29 Oct 2014 22:10:43 +0000 (23:10 +0100)
dnssec-check

index 25a45acf844d1df9b96af98fc52d06ef2bbb361c..a14508dbaa775e82eb3b32307b9a87d85f0fc007 100755 (executable)
@@ -57,17 +57,24 @@ def main():
     parser.add_option("-c", "--critical-days",
                       action="store", type=int, dest="crit", default=2,
                       help="minimum remaining validity in days before a warning is issued")
-    
+    parser.add_option("-v", action="store_true", dest="verbose", default=False)
+    parser.add_option("-q", action="store_false", dest="verbose")
         
     opts, _args = parser.parse_args()
+    if not opts.names:
+        parser.error("needs at least one DNS name")
+
     resolver = ub_ctx()
     resolver.add_ta_file(opts.ancor)
     encoding = sys.getfilesystemencoding()
 
     final = 0
-    for name in  opts.names:
-        result = check_dnssec_expire(resolver, idn2dname(name.decode(encoding)),
+    for name in opts.names:
+        name = idn2dname(name.decode(encoding))
+        result = check_dnssec_expire(resolver, name,
                                      timedelta(opts.warn), timedelta(opts.crit))
+        if result == 0 and opts.verbose:
+            print("OK %s" % name)
         if result == 2:
             final = 2
         elif result == 1 and final != 2: