forked from FreiFunkMuenster/node-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (42 loc) · 1.65 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf8 -*-
#
# (c) 2015 dray <dresen@itsecteam.ms>
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License or any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. See the
# GNU General Public License for more details.
#
# For a copy of the GNU General Public License
# see <http://www.gnu.org/licenses/>.
#
#
import argparse
from JsonManager import JsonManager
from GraphiteManager import GraphiteManager
parser = argparse.ArgumentParser(description='This Script gets information about Freifunk Muenster')
parser.add_argument('--server', required=True, help='Server')
parser.add_argument('--port', required=True, help='Port', default=2003)
parser.add_argument('--socket', help='Alfred-Socket', default='/run/alfred.sock')
parser.add_argument('--domain', help='Freifunk Domäne', default='legacy')
parser.add_argument('--local', help='Load local json files (alfred_158.json,alfred_159.json)', action='store_true')
parser.add_argument('--print-only', help='Print only', action='store_true')
args = parser.parse_args()
jsonManager = JsonManager()
if args.local:
jsonManager.loadJson()
else:
jsonManager.loadJsonFromAlfred(args.socket)
jsonManager.processJson158()
jsonManager.processJson159()
jsonManager.processJson160()
graphiteManager = GraphiteManager(args.server, args.port, args.domain)
graphiteManager.prepareMessage(jsonManager.result)
if args.print_only:
graphiteManager.printout()
else:
graphiteManager.send()