#! /usr/bin/python3 # coding=utf-8 from aw_sender import AwZabbix from SetupMinersClass import SetupMiner, read_conf import sys import json def reboot_miner(miner, z, conf): for miner_dat in z.lld()['data']: if miner_dat["{#MINERNAME}"] == miner: miner_ip = miner_dat['{#IP}'] print(miner_ip) s = SetupMiner(miner_ip, conf=conf, telnets=['shutdown -r now'], sshs=['shutdown -r now']) print(s.result) break def main(): conf = read_conf() print(conf) zabbix_server = conf["zabbix_server"] aw_url = conf["aw_url"] hostname = conf["hostname"] minerconf = {"sshuser": conf["sshuser"], "sshpass": conf["sshpass"], "sshport": conf["sshport"], "telnetuser": conf["telnetuser"], "telnetpass": conf["telnetpass"], "telnetport": conf["telnetport"]} z = AwZabbix(zabbix_server, aw_url, hostname) if len(sys.argv) == 1: print('Need miner name to reboot as arg') elif len(sys.argv) == 2 and sys.argv[1] == 'test': print(z.lld()) elif len(sys.argv) == 2: # dc05-miner: CJ1554 04G hashrate = 0 miner = "{} {}".format(sys.argv[1].split()[1], sys.argv[1].split()[2]) print(miner) print(reboot_miner(miner, z, minerconf)) if __name__ == '__main__': main()