BIND 10 trac2062, updated. fdc9afcf5e90f2d6cacf9da65cb8ab1d7e515fd0 [2026] Add command line arguments for help and output-file
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jul 2 03:55:17 UTC 2012
The branch, trac2062 has been updated
via fdc9afcf5e90f2d6cacf9da65cb8ab1d7e515fd0 (commit)
from 83e396404b5f484f1d2462664948ee6031abe638 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fdc9afcf5e90f2d6cacf9da65cb8ab1d7e515fd0
Author: Mukund Sivaraman <muks at isc.org>
Date: Mon Jul 2 08:53:57 2012 +0530
[2026] Add command line arguments for help and output-file
-----------------------------------------------------------------------
Summary of changes:
src/bin/showtech/b10-showtech.1 | 13 +++++
src/bin/showtech/b10-showtech.xml | 25 +++++++++
src/bin/showtech/showtech.py.in | 107 ++++++++++++++++++++++++-------------
3 files changed, 109 insertions(+), 36 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/showtech/b10-showtech.1 b/src/bin/showtech/b10-showtech.1
index d549573..b331713 100644
--- a/src/bin/showtech/b10-showtech.1
+++ b/src/bin/showtech/b10-showtech.1
@@ -37,6 +37,19 @@ b10-showtech \- BIND 10 system information display tool
The
\fBb10\-showtech\fR
program collects and outputs a variety of information about the system that BIND 10 is running on\&. This information can be useful to people involved in debugging and technical support\&.
+.SH "ARGUMENTS"
+.PP
+\-h
+.RS 4
+Displays usage instructions\&.
+.RE
+.PP
+\-o \fIoutput\-file\fR
+.RS 4
+If an output file is specified, the output of
+\fBb10\-showtech\fR
+is written to this file\&. By default, the output is written to standard output\&.
+.RE
.SH "SEE ALSO"
.PP
diff --git a/src/bin/showtech/b10-showtech.xml b/src/bin/showtech/b10-showtech.xml
index 503fdd9..fe11ed1 100644
--- a/src/bin/showtech/b10-showtech.xml
+++ b/src/bin/showtech/b10-showtech.xml
@@ -58,6 +58,31 @@
</refsect1>
<refsect1>
+ <title>ARGUMENTS</title>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>-h</term>
+ <listitem><para>
+ Displays usage instructions.
+ </para></listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>-o <replaceable class="parameter">output-file</replaceable></term>
+ <listitem><para>
+ If an output file is specified, the output
+ of <command>b10-showtech</command> is written to this file. By
+ default, the output is written to standard output.
+ </para></listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </refsect1>
+
+ <refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
diff --git a/src/bin/showtech/showtech.py.in b/src/bin/showtech/showtech.py.in
index 8cb5ee2..5b67847 100755
--- a/src/bin/showtech/showtech.py.in
+++ b/src/bin/showtech/showtech.py.in
@@ -21,63 +21,95 @@ BIND 10 showtech program.
"""
import sys; sys.path.append ('@@PYTHONPATH@@')
+import getopt
import isc.util.process
from isc.sysinfo import *
isc.util.process.rename()
+def usage():
+ print("Usage: %s [-h] [-o <output-file>]" % sys.argv[0], \
+ file=sys.stderr)
+ exit(1)
+
def main():
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "o:h", \
+ ["output", "help"])
+ except getopt.GetoptError as e:
+ print(str(e))
+ usage()
+ exit(1)
+
+ output_filename = None
+ for option, arg in opts:
+ if option in ("-o", "--output"):
+ output_filename = arg
+ elif option in ("-h", "--help"):
+ usage()
+ else:
+ assert False, "unhandled option"
+
+ if output_filename is None:
+ f = sys.stdout
+ else:
+ f = open(output_filename, 'w')
+
s = SysInfoFromFactory()
- print('BIND 10 ShowTech tool')
- print('=====================')
+ f.write('BIND 10 ShowTech tool\n')
+ f.write('=====================\n')
- print('\nCPU');
- print(' + Number of processors: ' + str(s.get_num_processors()))
- print(' + Endianness: ' + s.get_endianness())
+ f.write('\nCPU\n');
+ f.write(' + Number of processors: %d\n' % (s.get_num_processors()))
+ f.write(' + Endianness: %s\n' % (s.get_endianness()))
- print('\nPlatform');
- print(' + Operating system: ' + s.get_platform_name())
- print(' + Distribution: ' + s.get_platform_distro())
- print(' + Kernel version: ' + s.get_platform_version())
+ f.write('\nPlatform\n');
+ f.write(' + Operating system: %s\n' % (s.get_platform_name()))
+ f.write(' + Distribution: %s\n' % (s.get_platform_distro()))
+ f.write(' + Kernel version: %s\n' % (s.get_platform_version()))
+
+ f.write(' + SMP kernel: ')
if s.get_platform_is_smp():
- print(' + SMP kernel: yes')
+ f.write('yes')
else:
- print(' + SMP kernel: no')
- print(' + Machine name: ' + s.get_platform_machine())
- print(' + Hostname: ' + s.get_platform_hostname())
- print(' + Uptime: %d seconds' % (s.get_uptime()))
+ f.write('no')
+ f.write('\n')
+
+ f.write(' + Machine name: %s\n' % (s.get_platform_machine()))
+ f.write(' + Hostname: %s\n' % (s.get_platform_hostname()))
+ f.write(' + Uptime: %d seconds\n' % (s.get_uptime()))
l = s.get_loadavg()
- print(' + Loadavg: %f %f %f' % (l[0], l[1], l[2]))
+ f.write(' + Loadavg: %f %f %f\n' % (l[0], l[1], l[2]))
- print('\nMemory');
- print(' + Total: %d bytes' % (s.get_mem_total()))
- print(' + Free: %d bytes' % (s.get_mem_free()))
- print(' + Cached: %d bytes' % (s.get_mem_cached()))
- print(' + Buffers: %d bytes' % (s.get_mem_buffers()))
- print(' + Swap total: %d bytes' % (s.get_mem_swap_total()))
- print(' + Swap free: %d bytes' % (s.get_mem_swap_free()))
+ f.write('\nMemory\n');
+ f.write(' + Total: %d bytes\n' % (s.get_mem_total()))
+ f.write(' + Free: %d bytes\n' % (s.get_mem_free()))
+ f.write(' + Cached: %d bytes\n' % (s.get_mem_cached()))
+ f.write(' + Buffers: %d bytes\n' % (s.get_mem_buffers()))
+ f.write(' + Swap total: %d bytes\n' % (s.get_mem_swap_total()))
+ f.write(' + Swap free: %d bytes\n' % (s.get_mem_swap_free()))
- print('\n\nNetwork');
- print('-------\n');
+ f.write('\n\nNetwork\n');
+ f.write('-------\n\n');
- print('Interfaces')
- print('~~~~~~~~~~\n')
+ f.write('Interfaces\n')
+ f.write('~~~~~~~~~~\n\n')
- print(s.get_net_interfaces())
+ f.write(s.get_net_interfaces())
- print('Routing table')
- print('~~~~~~~~~~~~~\n')
- print(s.get_net_routing_table())
+ f.write('\nRouting table\n')
+ f.write('~~~~~~~~~~~~~\n\n')
+ f.write(s.get_net_routing_table())
- print('Statistics')
- print('~~~~~~~~~~\n')
- print(s.get_net_stats())
+ f.write('\nStatistics\n')
+ f.write('~~~~~~~~~~\n\n')
+ f.write(s.get_net_stats())
- print('Connections')
- print('~~~~~~~~~~~\n')
- print(s.get_net_connections())
+ f.write('\nConnections\n')
+ f.write('~~~~~~~~~~~\n\n')
+ f.write(s.get_net_connections())
try:
if os.getuid() != 0:
@@ -88,5 +120,8 @@ def main():
except Exception:
pass
+ if f != sys.stdout:
+ f.close()
+
if __name__ == '__main__':
main()
More information about the bind10-changes
mailing list