[Git][NTPsec/ntpsec][master] 3 commits: gps-log: tweak the help
Gary E. Miller
gitlab at mg.gitlab.com
Fri Jan 6 02:55:32 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
6aaf9506 by Gary E. Miller at 2017-01-05T18:00:10-08:00
gps-log: tweak the help
- - - - -
0bd67255 by Gary E. Miller at 2017-01-05T18:32:12-08:00
gps-log: add man page, move into ntpclients, install by default.
- - - - -
cbb038d8 by Gary E. Miller at 2017-01-05T18:54:40-08:00
gps-log: add -w WAIT option. Fix issue #227.
- - - - -
6 changed files:
- contrib/README
- + docs/gps-log.txt
- + docs/includes/gps-log-body.txt
- contrib/gps-log → ntpclients/gps-log
- + ntpclients/gps-log-man.txt
- wscript
Changes:
=====================================
contrib/README
=====================================
--- a/contrib/README
+++ b/contrib/README
@@ -6,9 +6,6 @@ cpu-temp-log is a tool to use the output of 'sensors -u' and write the
motherboard temperatures to stdout. Useful to create a log that can be used
by 'ntpviz --local-temps'
-gps-log is a tool to log gpsd data and write the data to stdout. Useful
-to create a log that can be used by 'ntpviz --local-gps'
-
smartctl-temp-log for hard drives. It is a tool to read a hard drive's
SMART data to get the disk temperature and write the temperature
to stdout. Useful to create a log that can be used by 'ntpviz
=====================================
docs/gps-log.txt
=====================================
--- /dev/null
+++ b/docs/gps-log.txt
@@ -0,0 +1,18 @@
+= gps-log - log gpsd data for use by ntpviz =
+
+[cols="10%,90%",frame="none",grid="none",style="verse"]
+|==============================
+|image:pic/dogsnake.gif[]|
+{millshome}pictures.html[from 'Alice's Adventures in Wonderland', Lewis Carroll]
+
+S is for snakeoil.
+
+|==============================
+
+'''''
+
+include::includes/gps-log-body.txt[]
+
+'''''
+
+include::includes/footer.txt[]
=====================================
docs/includes/gps-log-body.txt
=====================================
--- /dev/null
+++ b/docs/includes/gps-log-body.txt
@@ -0,0 +1,88 @@
+// This is the body of the manual page for gps-log
+// It's included in two places: once for the docs/ HTML
+// tree, and once to make an individual man page.
+
+== SYNOPSIS ==
+[verse]
+gps-log [-h] [-l LOGFILE] [-o] [-w WAIT] [-v] [-V]
+
+ -h, --help show this help message and exit
+ -l LOGFILE, --logfile LOGFILE
+ append log data to LOGFILE instead of stdout
+ -o, --once log one line, then exit
+ -w WAIT, --wait WAIT wait WAIT seconds after each log line, default 5
+ -v, --verbose be verbose
+ -V, --version show program's version number and exit
+
+== DESCRIPTION ==
+
+gps-log connects to a local gpsd daemon and logs the number of satellites
+in use and the Time Dilution of Precision (TDOP). gps-log can run as
+any user, no special priviledges are required.
+
+The default is to write the data to stdout about one every fice seconds.
+The log file looks like:
+
+-----------------------------------------------------
+# Time Device TDOP nSat
+1483668619.0 /dev/ttyS0 0.820000 7
+1483668624.0 /dev/ttyS0 0.820000 7
+1483668629.0 /dev/ttyS0 0.820000 7
+-----------------------------------------------------
+
++Time+ is the POSIX time of when the log line is written.
+
++Device+ is the GPS device the data came from.
+
++TDOP+ is the Time Dilution of Precision as reported by the GPS. Some
+GPS always output a static TDOP.
+
++nSat+ is the number of satellites in use.
+
+== OPTIONS ==
+
++-h, --help+::
+ Displays usage information and exits.
+
++-l LOGFILE, --logfile LOGFILE+::
+ Append log data to LOGFILE instead of stdout
+
++-o, --once+::
+ Log one line, then exit.
+
++-v, --verbose+::
+ Be verbose
+
++-w WAIT, --wait WAIT+::
+ Wait WAIT seconds after each log line. The default is 5 seconds. This
+ is just the minimum wait time. gpsd may be reporting data at a much
+ slower interval.
+
++-V, --version+::
+ show program's version number and exit
+
+== USAGE ==
+
++gps-log+::
+ This the simplest use of this program. It can be used to check the
+ status of the local gpsd daemon.
+
++gps-log -f /var/log/ntpstats/gpsd -w 60+ &::
+ This will continuous log te gpsd data in the background to the file
+ /var/log/ntpstats/gpsd. Only log every 60 seconds.
+
+== EXIT STATUS ==
+
+One of the following exit values will be returned:
+
+0 (EXIT_SUCCESS)::
+ Successful program execution.
+1 (EXIT_FAILURE)::
+ The operation failed or the command syntax was not valid.
+
+== AUTHORS ==
+
+Gary E. Miller
+
+// end
+
=====================================
contrib/gps-log → ntpclients/gps-log
=====================================
--- a/contrib/gps-log
+++ b/ntpclients/gps-log
@@ -1,5 +1,21 @@
#!/usr/bin/env python
# coding: utf-8
+"""\
+usage: gps-log [-h] [-o] [-l LOGFILE] [-v] [-V]
+
+gpsd log file generator
+
+optional arguments:
+ -h, --help show this help message and exit
+ -l LOGFILE, --logfile LOGFILE
+ append log data to LOGFILE instead of stdout
+ -o, --once log one line, then exit
+ -w WAIT, --wait WAIT wait WAIT seconds after each log line, default 5
+ -v, --verbose be verbose
+ -V, --version show program's version number and exit
+
+See the manual page for details.
+"""
from __future__ import print_function
@@ -19,12 +35,11 @@ except ImportError as e:
try:
import argparse
-except ImportError as e:
+except ImportError:
sys.stderr.write("""
gps-log: can't find the Python argparse module
If your Python version is < 2.7, then manual installation is needed:
# pip install argparse
-%s
""")
sys.exit(1)
@@ -34,15 +49,22 @@ parser = argparse.ArgumentParser(description="gpsd log file generator",
See the manual page for details.
""")
+parser.add_argument('-l', '--logfile',
+ dest='logfile',
+ help="append log data to LOGFILE instead of stdout",
+ nargs=1)
+
parser.add_argument('-o', '--once',
action="store_true",
dest='once',
help="log one line, then exit")
-parser.add_argument('-l', '--logfile',
- dest='logfile',
- help="append log data to FILE instead of stdout",
- nargs=1)
+parser.add_argument('-w', '--wait',
+ default=5,
+ dest='wait',
+ help="wait WAIT seconds after each log line, default 5",
+ nargs=1,
+ type=int)
parser.add_argument('-v', '--verbose',
action="store_true",
@@ -117,7 +139,8 @@ if __name__ == '__main__':
print('parse error\n')
out.flush()
- time.sleep(5) # set to whatever
+ # wait a bit before next log
+ time.sleep(args.wait[0])
except (KeyboardInterrupt, SystemExit): # when you press ctrl+c
if args.verbose:
=====================================
ntpclients/gps-log-man.txt
=====================================
--- /dev/null
+++ b/ntpclients/gps-log-man.txt
@@ -0,0 +1,19 @@
+= gps-log(1) =
+:doctype: manpage
+
+== NAME ==
+gps-log - log gpsd data
+
+include::../docs/includes/gps-log-body.txt[]
+
+== EXIT STATUS ==
+
+One of the following exit values will be returned:
+
+0 (EXIT_SUCCESS)::
+ Successful program execution.
+1 (EXIT_FAILURE)::
+ The operation failed or the command syntax was not valid.
+
+// end
+
=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -136,6 +136,7 @@ def afterparty(ctx):
os.system("cd %s/pylib; ln -sf ../libntp/ntpc.so ntpc.so " % (bldnode,))
python_scripts = [
+ "ntpclients/gps-log",
"ntpclients/ntpdig",
"ntpclients/ntpkeygen",
"ntpclients/ntpmon",
@@ -206,6 +207,7 @@ def build(ctx):
ctx.manpage(1, "ntpclients/ntptrace-man.txt")
ctx.manpage(1, "ntpclients/ntpviz-man.txt")
ctx.manpage(8, "ntpclients/ntpwait-man.txt")
+ ctx.manpage(1, "ntpclients/gps-log-man.txt")
# Skip running unit tests on a cross compile build
if not ctx.env.ENABLE_CROSS:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/cd6d8b8129d6a88a19b059523498934bd7d860c9...cbb038d80a4a6ffd27fc275777ef32a305921b29
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170106/fbbf1ffd/attachment.html>
More information about the vc
mailing list