Added group support
This commit is contained in:
parent
e64b734564
commit
a998e80d27
4 changed files with 15 additions and 10 deletions
|
|
@ -90,6 +90,6 @@ Here you shoud set the argumentos. send_info_daemon.py is the daemon that send t
|
|||
|
||||
There other options how I/O where you can define a file log for check errors if you have problems with the service.
|
||||
|
||||
All's done!, you can init your service with **nssm strt MonitService** and let's go.
|
||||
All's done!, you can init your service with **nssm start MonitService** and let's go.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ def show_config_win():
|
|||
def send_data():
|
||||
print('Init daemon...')
|
||||
|
||||
url_monit=send_info_daemon.load_config()
|
||||
url_monit, group=send_info_daemon.load_config()
|
||||
|
||||
while True:
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ class WinConfig(QWidget):
|
|||
def __init__(self, url_monit='http://192.168.1.51/monit'):
|
||||
super().__init__()
|
||||
|
||||
url_monit=send_info_daemon.load_config()
|
||||
url_monit, group=send_info_daemon.load_config()
|
||||
|
||||
self.text=QLabel("Change monitoritation url, example: http://192.168.1.51/monit/api_token")
|
||||
self.input=QLineEdit(url_monit)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from pastafaristats import send_info_daemon
|
||||
|
||||
url=send_info_daemon.load_config()
|
||||
url, group=send_info_daemon.load_config()
|
||||
|
||||
if __name__=='__main__':
|
||||
send_info_daemon.run(url)
|
||||
|
|
|
|||
|
|
@ -64,10 +64,15 @@ def load_config():
|
|||
|
||||
url=config['DEFAULT']['url_server']
|
||||
|
||||
return url
|
||||
group=''
|
||||
|
||||
if 'group' in config:
|
||||
group=config['DEFAULT']['group']
|
||||
|
||||
return url, group
|
||||
|
||||
|
||||
def run(url):
|
||||
def run(url, group=''):
|
||||
|
||||
network_info=psutil.net_io_counters(pernic=False)
|
||||
|
||||
|
|
@ -93,7 +98,7 @@ def run(url):
|
|||
|
||||
mem_info=psutil.virtual_memory()
|
||||
|
||||
json_info=json.dumps({'net_info': network_info, 'cpu_idle': cpu_idle, 'cpus_idle': cpus_idle, 'cpu_number': cpu_number, 'disks_info': partitions, 'mem_info': mem_info, 'hostname': hostname})
|
||||
json_info=json.dumps({'net_info': network_info, 'cpu_idle': cpu_idle, 'cpus_idle': cpus_idle, 'cpu_number': cpu_number, 'disks_info': partitions, 'mem_info': mem_info, 'hostname': hostname, 'group': group})
|
||||
|
||||
data = urllib.parse.urlencode({'data_json': json_info})
|
||||
|
||||
|
|
@ -120,7 +125,7 @@ def run(url):
|
|||
print('Cannot connect to data server -> '+str(e))
|
||||
|
||||
#Reload config
|
||||
url=load_config()
|
||||
url, group=load_config()
|
||||
|
||||
|
||||
def start():
|
||||
|
|
@ -129,11 +134,11 @@ def start():
|
|||
|
||||
# Load configuration
|
||||
|
||||
url=load_config()
|
||||
url, group=load_config()
|
||||
|
||||
while True:
|
||||
|
||||
run(url)
|
||||
run(url, group)
|
||||
|
||||
sleep(60)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue