just some coding style fixes
This commit is contained in:
parent
5b09f02d68
commit
b17283b305
1 changed files with 30 additions and 38 deletions
52
linspector
52
linspector
|
|
@ -9,7 +9,6 @@ import logging
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parseArgs():
|
def parseArgs():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Linspector is for monitoring the vital information of hosts, services and devices in a network.",
|
description="Linspector is for monitoring the vital information of hosts, services and devices in a network.",
|
||||||
|
|
@ -18,57 +17,50 @@ def parseArgs():
|
||||||
|
|
||||||
parser.add_argument("action", choices=["start", "stop", "restart", "attach"],
|
parser.add_argument("action", choices=["start", "stop", "restart", "attach"],
|
||||||
help="defines if linspector should beeing attached, started, stopped or restarted.")
|
help="defines if linspector should beeing attached, started, stopped or restarted.")
|
||||||
parser.add_argument("--version", action="version", version="%(prog)s "+str(VERSION))
|
parser.add_argument("--version", action="version", version="%(prog)s " + str(VERSION))
|
||||||
parser.add_argument("-c", "--config", default="./linspector.json",
|
parser.add_argument("-c", "--config", default="./linspector.json",
|
||||||
help="select configfile to use")
|
help="select configfile to use")
|
||||||
parser.add_argument("-l", "--logfile", default="./log/linspector.log", metavar="FILE",
|
parser.add_argument("-l", "--logfile", default="./log/linspector.log", metavar="FILE",
|
||||||
help="set logfile to use")
|
help="set logfile to use")
|
||||||
parser.add_argument("-p", "--pidfile", default="./tmp/linspector.pid", metavar="FILE",
|
parser.add_argument("-p", "--pidfile", default="./tmp/linspector.pid", metavar="FILE",
|
||||||
help="set the pidfile to use (default: /tmp/linspector.pid)")
|
help="set the pidfile to use (default: /tmp/linspector.pid)")
|
||||||
|
|
||||||
|
output = parser.add_mutually_exclusive_group()
|
||||||
output=parser.add_mutually_exclusive_group()
|
output.add_argument("-q", "--quiet", action="store_const", dest="loglevel", const=logging.ERROR,
|
||||||
output.add_argument("-q","--quiet", action="store_const", dest="loglevel", const=logging.ERROR,
|
help="output only errors")
|
||||||
help="output only errors")
|
|
||||||
output.add_argument("-w", "--warning", action="store_const", dest="loglevel", const=logging.WARNING,
|
output.add_argument("-w", "--warning", action="store_const", dest="loglevel", const=logging.WARNING,
|
||||||
help="output warnings")
|
help="output warnings")
|
||||||
output.add_argument("-v","--verbose", action="store_const", dest="loglevel", const=logging.INFO,
|
output.add_argument("-v", "--verbose", action="store_const", dest="loglevel", const=logging.INFO,
|
||||||
help="output infos")
|
help="output infos")
|
||||||
output.add_argument("-d", "--debug", action="store_const", dest="loglevel", const=logging.DEBUG,
|
output.add_argument("-d", "--debug", action="store_const", dest="loglevel", const=logging.DEBUG,
|
||||||
help="output debug infos")
|
help="output debug infos")
|
||||||
output.set_defaults(loglevel=logging.INFO)
|
output.set_defaults(loglevel=logging.INFO)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args=parseArgs()
|
args = parseArgs()
|
||||||
log=Logger(args.logfile , args.loglevel)
|
log = Logger(args.logfile, args.loglevel)
|
||||||
|
|
||||||
log.i("parsed arguments")
|
log.i("parsed arguments")
|
||||||
|
|
||||||
if args.action=="start":
|
if args.action == "start":
|
||||||
log.i("starting linspector: reading config...")
|
log.i("starting linspector: reading config...")
|
||||||
config=Config(args.config, log)
|
config = Config(args.config, log)
|
||||||
log.d("parsed config: " + str(config))
|
log.d("parsed config: " + str(config))
|
||||||
for hg in config.hostgroups:
|
for hg in config.hostgroups:
|
||||||
log.i(str(hg))
|
log.i(str(hg))
|
||||||
elif args.action=="stop":
|
elif args.action == "stop":
|
||||||
log.i("stopping linspector is currently unsupported")
|
log.i("stopping linspector is currently unsupported")
|
||||||
elif args.action=="restart":
|
elif args.action == "restart":
|
||||||
sp.call("./linspector stop")
|
sp.call("./linspector stop")
|
||||||
sp.call("./linspector start --config " + args.config + " --logfile " + args.logfile + " --pidfile " + args.pidfile)
|
sp.call(
|
||||||
elif args.action=="attach":
|
"./linspector start --config " + args.config + " --logfile " + args.logfile + " --pidfile " + args.pidfile)
|
||||||
|
elif args.action == "attach":
|
||||||
log.i("attaching linspector is currently unsupported")
|
log.i("attaching linspector is currently unsupported")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log.close()
|
log.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue