Fix Build e domenticanza nel routermon
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
GIT_HASH=$(git rev-parse --short HEAD)
|
GIT_HASH=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
echo "Building UPSmon"
|
echo "Building UPSmon"
|
||||||
cp ../pyutils/utils.py ../upsmon/
|
cp ../pyutils/utils.py ../upsmon/
|
||||||
docker build --build-arg BUILD_VER=${GIT_HASH} -f ../upsmon/upsmon.Dockerfile -t upsmon:influx3 ../upsmon
|
docker build --build-arg BUILD_VER=${GIT_HASH} -f ../upsmon/upsmon.Dockerfile -t upsmon:influx3 ../upsmon
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ LOGGER: logging.Logger
|
|||||||
##################
|
##################
|
||||||
###### MAIN ######
|
###### MAIN ######
|
||||||
##################
|
##################
|
||||||
def main():
|
def main() -> int:
|
||||||
INTERVAL = int(env['INTERVAL'])
|
INTERVAL = int(env['INTERVAL'])
|
||||||
|
try:
|
||||||
# Init InfluxDB-v3 Client
|
# Init InfluxDB-v3 Client
|
||||||
write_client = InfluxDBClient3(host=env['INFLUXDB_URL'],
|
write_client = InfluxDBClient3(host=env['INFLUXDB_URL'],
|
||||||
token=env['INFLUXDB_TOKEN'],
|
token=env['INFLUXDB_TOKEN'],
|
||||||
@@ -27,6 +28,12 @@ def main():
|
|||||||
password=env['MIKROTIK_PASSWORD'],
|
password=env['MIKROTIK_PASSWORD'],
|
||||||
plaintext_login=True)
|
plaintext_login=True)
|
||||||
api = connection.get_api()
|
api = connection.get_api()
|
||||||
|
except Exception as e:
|
||||||
|
LOGGER.error(e)
|
||||||
|
return 1
|
||||||
|
finally:
|
||||||
|
LOGGER.info(f"InfluxDB Connected: [{env['INFLUXDB_URL']}/{env['INFLUXDB_DATABASE']}]")
|
||||||
|
LOGGER.info(f"Mikrotik Connected: [{env['MIKROTIK_IP']}]")
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
########## MAIN LOOP #########
|
########## MAIN LOOP #########
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def bruteforceCommands(port: serial.Serial):
|
|||||||
##################
|
##################
|
||||||
###### MAIN ######
|
###### MAIN ######
|
||||||
##################
|
##################
|
||||||
def main():
|
def main() -> int:
|
||||||
INTERVAL = int(env['INTERVAL'])
|
INTERVAL = int(env['INTERVAL'])
|
||||||
UPS_COMMAND = "Q1"
|
UPS_COMMAND = "Q1"
|
||||||
try:
|
try:
|
||||||
@@ -55,7 +55,7 @@ def main():
|
|||||||
port = serial.Serial(port=env['PORT'], baudrate=int(env['BAUD']), bytesize=8, parity='N', stopbits=1)
|
port = serial.Serial(port=env['PORT'], baudrate=int(env['BAUD']), bytesize=8, parity='N', stopbits=1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGGER.error(e)
|
LOGGER.error(e)
|
||||||
return 0
|
return 1
|
||||||
finally:
|
finally:
|
||||||
LOGGER.info(f"InfluxDB Connected: [{env['INFLUXDB_URL']}/{env['INFLUXDB_DATABASE']}]")
|
LOGGER.info(f"InfluxDB Connected: [{env['INFLUXDB_URL']}/{env['INFLUXDB_DATABASE']}]")
|
||||||
LOGGER.info(f"Serial Port Open: [{env['PORT']}]")
|
LOGGER.info(f"Serial Port Open: [{env['PORT']}]")
|
||||||
@@ -82,7 +82,7 @@ def main():
|
|||||||
}
|
}
|
||||||
LOGGER.debug(f"UPS Status: \n{json.dumps(values, indent=2)}")
|
LOGGER.debug(f"UPS Status: \n{json.dumps(values, indent=2)}")
|
||||||
if values['onBatt']:
|
if values['onBatt']:
|
||||||
LOGGER.info(f"OnBattery\n{json.dumps(values,indent=2)}")
|
LOGGER.info(f"OnBattery: \n{json.dumps(values,indent=2)}")
|
||||||
write_client.write(record=dict2Point('ups', values))
|
write_client.write(record=dict2Point('ups', values))
|
||||||
time.sleep(INTERVAL)
|
time.sleep(INTERVAL)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user