-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrystaldiskinfo_to_zabbix.py
46 lines (33 loc) · 1.32 KB
/
crystaldiskinfo_to_zabbix.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
import json
import logging
from pprint import pprint
import config as cfg
import modules.parser.cdi_parser as parser
import modules.zabbix.send_device as send_device
import modules.zabbix.send_smart as send_smart
logger = logging.getLogger(__name__)
if __name__ == '__main__':
if (cfg.LOG_LEVEL.upper() == "ERROR"):
logging.basicConfig(level=logging.ERROR)
elif (cfg.LOG_LEVEL.upper() == "WARN"):
logging.basicConfig(level=logging.WARN)
elif (cfg.LOG_LEVEL.upper() == "INFO"):
logging.basicConfig(level=logging.INFO)
elif (cfg.LOG_LEVEL.upper() == "DEBUG"):
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)
logger.debug("START")
result = parser.parse(cfg.DISKINFO_TXT)
# for debug purpose, export parsed.json if configured
if (cfg.PARSED_JSON != ""):
logger.debug(f"Exporting parsed.json: {cfg.PARSED_JSON}")
with open(cfg.PARSED_JSON, 'w', encoding='UTF-8') as f:
f.write(json.dumps(result, indent=2, ensure_ascii=False))
# CDIの解釈データを送る
send_device.send_device_discovery(result)
send_device.send_device_data(result)
# SMART全データを送信する
send_smart.send_attribute_discovery(result)
send_smart.send_smart_data(result)
logger.debug("END")