[Git][NTPsec/ntpsec][master] Add "-D N" and "-N" options. Debug and nice.

Gary E. Miller gitlab at mg.gitlab.com
Mon Aug 22 22:25:13 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
8ca84ac3 by Gary E. Miller at 2016-08-22T15:24:11-07:00
Add "-D N" and "-N" options.  Debug and nice.

Now I can leave in some debug printouts.
-N is good for cronjobs

- - - - -


2 changed files:

- docs/includes/ntpviz-body.txt
- ntpstats/ntpviz


Changes:

=====================================
docs/includes/ntpviz-body.txt
=====================================
--- a/docs/includes/ntpviz-body.txt
+++ b/docs/includes/ntpviz-body.txt
@@ -12,6 +12,7 @@
          [--peer-offsets=hosts | --all-peer-offsets]
          [--peer-jitters=hosts | --all-peer-jitters]
 	 [-o outdir]
+	 [-D N] [-N]
 
 == DESCRIPTION ==
 
@@ -36,6 +37,13 @@ default is for the period to be 7 days, the end time to match the last
 logfile entry, and the start time to be set so that adding the period
 just reaches the last logfile entry.
 
+The -D N set the debug level to N and outputs with more verbosity.  0
+is the default, quiet except for all ERRORs and some WARNINGs.  9 is
+painfully verbose.
+
+The -N option will force ntpviz to run "nice"ly.  This is appropriate
+when you run ntpvizz as a cron job.
+
 The plot options choose what graph is generated; invoke only one.  By
 default, the GNUPLOT for the graph is reported; with -g you get the
 rendered PNG.


=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -11,6 +11,7 @@ Usage: ntpviz [-d statsdir] [-g] [-n name] [-p days]
               [--peer-jitters=hosts | --all-peer-jitters]
               [--local-cpu-temp]
               [-o outdir]
+              [-D N] [-N]
 
 See the manual page for details.
 
@@ -288,7 +289,7 @@ iVBORw0KGgoAAAANSUhEUgAAAEAAAABKCAQAAACh+5ozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7O
 
 if __name__ == '__main__':
     try:
-        (options, arguments) = getopt.getopt(sys.argv[1:], "d:e:ghn:o:p:s:", [
+        (options, arguments) = getopt.getopt(sys.argv[1:], "d:e:ghn:o:p:s:D:N", [
             "local-offset", "local-error", "local-jitter", "local-stability",
             "local-offset-histogram",
             "all-peer-offsets", "peer-offsets=",
@@ -309,6 +310,8 @@ if __name__ == '__main__':
     show_peer_offsets = show_peer_jitters = None
     show_peer_rtt = None
     outdir = "ntpgraphs"
+    debug_level = 0
+    nice = 0
     for (switch, val) in options:
         if switch == "-d":
             statsdirs = val.split(",")
@@ -327,6 +330,11 @@ if __name__ == '__main__':
             starttime = iso_to_posix(val)
         elif switch == "-o":
             outdir = val
+        elif switch == "-D":
+            debug = int(val)      # Debug level, 0 to 9, 9 most verbose
+        elif switch == "-N":
+            # implemented as integer, in case the option needs to be extended
+            nice = 19             # run ntpviz "nice"ly
         elif switch == "--local-offset":
             show_local_offset = True
         elif switch == "--local-error":
@@ -351,6 +359,16 @@ if __name__ == '__main__':
             show_cpu_temp = True
     period = 24 * 60 * 60 * period_days
 
+    if 0 < debug:
+        sys.stderr.write("ntpviz: INFO: now running at debug: %s\n" % \
+            debug)
+
+    if 0 != nice:
+        nice = os.nice( nice )
+        if 2 < debug:
+            sys.stderr.write("ntpviz: INFO: now running at nice: %s\n" % \
+                nice)
+
     start_time = datetime.datetime.utcnow()
     start_time_secs = time.time()
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8ca84ac3516c67466f7ca6f9a192fcafb3bd9417
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160822/1e586e39/attachment.html>


More information about the vc mailing list