ADD zls_check.py

This commit is contained in:
2023-09-13 16:44:00 +02:00
parent fb335df2a1
commit f60bae26bb
15 changed files with 141 additions and 111 deletions
+6 -3
View File
@@ -4,12 +4,9 @@ import requests
import time
import socket
import datetime
import create_service
import system_info
import volume
create_service.addservice("VOLUME_CHECK") ## CREATE VOLUME
def request(function,variable): ##API-SErver
url = (f"http://api.stines.de:8001/{function}")
response = requests.post(url,json = variable,headers={'access_token':'^YWUbG7yX*V!tV^KBSd*2c&vdN3wV9a2i7f3hfGFMBYFxi6#mMiJGiaA5KEHE%B*miK%qb7rQ67gmcYP@gqmux8'})
@@ -25,12 +22,18 @@ def check_volume_exist():
user = os.getlogin() ## GET CURRENT USER
database = request("info/getclient",{"name":hostname}).text.replace('"',"") ##GET DATABASE FROM SQL-SERVER
volume_get = request("info/getvolume",{"name":hostname,"database":database}) ##GET VOLUMES FROM SQL-SERVER
print(volume_get.text)
space_free = str(system_info.get_single_hdd("free")).replace("['","").replace("]","").replace("'","").replace(",",";") ## FREE SPACE OF VOLUME
space_used = str(system_info.get_single_hdd("used")).replace("['","").replace("]","").replace("'","").replace(",",";") ## USED SPACE OF VOLUME
space_total = str(system_info.get_single_hdd("total")).replace("['","").replace("]","").replace("'","").replace(",",";") ## TOTAL SPACE OF VOLUME
if volume_get.text == "false":
print(volume.get_netvolume())
if volume.get_netvolume() is None:
with open("log.txt", "a") as datei:
datei.writelines(f"Keine Netvolume vorhanden!" + "\n") ## WRITE TO ERRORLOG
pushover_send("Keine Netvolume vorhanden!", hostname) ## SEND ERROR LOG TO PUSHOVER
netvolume = volume.get_netvolume()
values = (
f"'{hostname}','{system_info.get_local_ip()}','{system_info.get_winver()}','{system_info.get_cpu_brand()}','{system_info.get_cpu_core()}','{system_info.get_ram_info()}','{space_total}','{space_free}','{space_used}'")