1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00

Cleanup some code (#355)

* Format with isort

* Format with Black

* Fix CRLF

* Format with shellcheck

* Fix some warning

* Fix PHP style

* Dont modifiy check_mk files

* Fixes
This commit is contained in:
Jellyfrog
2021-03-18 12:24:30 +01:00
committed by GitHub
parent 5aa62834cb
commit 61064dc9fe
58 changed files with 1665 additions and 1335 deletions

View File

@@ -1,39 +1,45 @@
#!/usr/bin/env python3
import io
import re
import os
import json
import os
import re
version = 1
error = 0
error_string = ''
error_string = ""
logfile = '/var/log/backupninja.log'
logfile = "/var/log/backupninja.log"
backupninja_datas = {
'last_actions': 0,
'last_fatal': 0,
'last_error': 0,
'last_warning': 0}
"last_actions": 0,
"last_fatal": 0,
"last_error": 0,
"last_warning": 0,
}
if not os.path.isfile(logfile):
error_string = 'file unavailable'
error_string = "file unavailable"
error = 1
break
with io.open(logfile,'r') as f:
with io.open(logfile, "r") as f:
for line in reversed(list(f)):
match = re.search('^(.*) [a-zA-Z]*: FINISHED: ([0-9]+) actions run. ([0-9]+) fatal. ([0-9]+) error. ([0-9]+) warning.$', line)
match = re.search(
"^(.*) [a-zA-Z]*: FINISHED: ([0-9]+) actions run. ([0-9]+) fatal. ([0-9]+) error. ([0-9]+) warning.$",
line,
)
if match:
backupninja_datas['last_actions'] = int(match.group(2))
backupninja_datas['last_fatal'] = int(match.group(3))
backupninja_datas['last_error'] = int(match.group(4))
backupninja_datas['last_warning'] = int(match.group(5))
backupninja_datas["last_actions"] = int(match.group(2))
backupninja_datas["last_fatal"] = int(match.group(3))
backupninja_datas["last_error"] = int(match.group(4))
backupninja_datas["last_warning"] = int(match.group(5))
break
output = {'version': version,
'error': error,
'errorString': error_string,
'data': backupninja_datas}
output = {
"version": version,
"error": error,
"errorString": error_string,
"data": backupninja_datas,
}
print(json.dumps(output))