Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+223
@@ -0,0 +1,223 @@
|
||||
import shutil
|
||||
from smtpd import usage
|
||||
|
||||
import psutil
|
||||
import network
|
||||
import local as localI
|
||||
import settings
|
||||
from network import is_reachable, check_proc_running, check_proc_args
|
||||
from colorama import Style, Fore
|
||||
|
||||
CHECKMARK = Fore.GREEN + "[\u2713]" + Style.RESET_ALL
|
||||
CROSS = Fore.RED + "[\u2717]" + Style.RESET_ALL
|
||||
WARN = Fore.YELLOW + "[!]" + Style.RESET_ALL
|
||||
opdom = None
|
||||
svcdom = None
|
||||
local = False # Set to true if the TDS is not reachable
|
||||
tds = settings.get_setting("tds")
|
||||
tds_user = settings.get_setting("tds_user")
|
||||
tds_pass = settings.get_setting("tds_pass")
|
||||
|
||||
dbs = settings.get_setting("dbs")
|
||||
dbs_user = settings.get_setting("dbs_user")
|
||||
dbs_pass = settings.get_setting("dbs_pass")
|
||||
|
||||
avs = settings.get_setting("avs")
|
||||
avs_user = settings.get_setting("avs_user")
|
||||
avs_pass = settings.get_setting("avs_pass")
|
||||
|
||||
|
||||
def autocheck(verbose):
|
||||
global local
|
||||
checkLocalDiskSpace()
|
||||
if tds == "localhost":
|
||||
local = True
|
||||
if is_running("OperatorApplication"):
|
||||
print(CHECKMARK + "OperatorApplication is running")
|
||||
for element in get_args("OperatorApplication"):
|
||||
if "-d" in element:
|
||||
opdom = element.split("-d")[1]
|
||||
|
||||
else:
|
||||
print(CROSS + "OperatorApplication is not running")
|
||||
|
||||
if is_running("AVS_Workstation"):
|
||||
print(CHECKMARK + "AVS_Workstation is running")
|
||||
else:
|
||||
print(CROSS + "AVS_Workstation is not running")
|
||||
|
||||
if is_running("AVS_Export"):
|
||||
print(CHECKMARK + "AVS_Export is running")
|
||||
else:
|
||||
print(CROSS + "AVS_Export is not running")
|
||||
|
||||
if not local:
|
||||
if is_reachable(tds, verbose):
|
||||
print(CHECKMARK + "TDS is reachable")
|
||||
|
||||
checkDiskUsage(network.checkDiskSpace(tds, tds_user, tds_pass), 80)
|
||||
if "localhost" == network.checkLtsccConf(tds, tds_user, tds_pass, "ServerHostname"):
|
||||
print(CROSS + "TDS is reachable but lts-cc.conf got localhost")
|
||||
checkServicesRemote(verbose)
|
||||
else:
|
||||
print(CROSS + Style.RESET_ALL + "TDS is not reachable")
|
||||
local = True
|
||||
if is_running("svcServiceManagement"):
|
||||
print(CHECKMARK + "ServiceManagement is running local")
|
||||
if "localhost" != localI.checkLocalConfig("ServerHostname"):
|
||||
print(CROSS + "ServiceManagement running locally but ServerHostname in lts-cc.conf is not set to localhost")
|
||||
#checkServicesLocal(verbose)
|
||||
else:
|
||||
print(CROSS + "ServiceManagement is not running local")
|
||||
if dbs != "localhost":
|
||||
if is_reachable(dbs, verbose):
|
||||
print(CHECKMARK + "DBS is reachable")
|
||||
if check_proc_running(dbs, dbs_user, dbs_pass, "postgres", verbose):
|
||||
print(" " + CHECKMARK + " Postgres is running")
|
||||
if local:
|
||||
if localI.checkLocalConfig("DatabaseName") not in network.checkDatabases(dbs, dbs_user, dbs_pass):
|
||||
print(" " + CROSS + " The DatabaseName in lts-cc.conf is not in psql")
|
||||
else:
|
||||
if network.checkLtsccConf(tds, tds_user, tds_pass, "DatabaseName").strip() not in network.checkDatabases(
|
||||
dbs, dbs_user, dbs_pass):
|
||||
print(" " + CROSS + " The DatabaseName in lts-cc.conf is not in psql")
|
||||
else:
|
||||
print(" " + CROSS + " Postgres is not running")
|
||||
else:
|
||||
print(CROSS + "DBS is not reachable")
|
||||
|
||||
if is_reachable(avs, verbose):
|
||||
print(CHECKMARK + "EXCAVS01 is reachable")
|
||||
else:
|
||||
print(CROSS + "EXCAVS01 is not reachable")
|
||||
|
||||
if is_reachable("EXCTDS05", verbose):
|
||||
print(CHECKMARK + "EXCTDS05 is reachable")
|
||||
else:
|
||||
print(CROSS + "EXCTDS05 is not reachable")
|
||||
|
||||
|
||||
def is_running(proc):
|
||||
for process in psutil.process_iter():
|
||||
if proc in process.name() :
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_args(proc):
|
||||
for process in psutil.process_iter(["pid", "name", "cmdline"]):
|
||||
if proc in process.name():
|
||||
return process.cmdline()[1:]
|
||||
return None
|
||||
|
||||
|
||||
def checkServicesRemote( verbose):
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcServiceManagement", verbose):
|
||||
print(" " + CHECKMARK + "svcServiceManagement is running")
|
||||
proc_args= check_proc_args(tds, tds_user, tds_pass, "svcServiceManagement", verbose)
|
||||
if proc_args is not None:
|
||||
for element in proc_args:
|
||||
if "-d" in element:
|
||||
svcdom = element.split("-d")[1]
|
||||
if svcdom is not opdom:
|
||||
print(" " + CROSS + "svcServiceManagement has different Domain Id than OperatorApplication")
|
||||
else:
|
||||
print(" " + CROSS + "svcServiceManagement is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcAreaEffectSimulation", verbose):
|
||||
print(" " + CHECKMARK + "svcAreaEffectSimulation is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcAreaEffectSimulation is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcCentralEffectSimulation", verbose):
|
||||
print(" " + CHECKMARK + "svcCentralEffectSimulation is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcCentralEffectSimulation is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcExerciseEventManagement", verbose):
|
||||
print(" " + CHECKMARK + "svcExerciseEventManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcExerciseEventManagement is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcExerciseManagement", verbose):
|
||||
print(" " + CHECKMARK + "svcExerciseManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcExerciseManagement is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcParticipantManagement", verbose):
|
||||
print(" " + CHECKMARK + "svcParticipantManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcParticipantManagement is not running")
|
||||
|
||||
if check_proc_running(tds, tds_user, tds_pass, "svcProjectDataManagement", verbose):
|
||||
print(" " + CHECKMARK + "svcProjectDataManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcProjectDataManagement is not running")
|
||||
|
||||
|
||||
def checkServicesLocal(verbose):
|
||||
svcdom2 = None
|
||||
if is_running("svcServiceManagement"):
|
||||
print(" " + CHECKMARK + "svcServiceManagement is running")
|
||||
for element in get_args("svcServiceManagement"):
|
||||
if "-d" in element:
|
||||
svcdom2 = element.split("-d")[1]
|
||||
if svcdom2 is not opdom:
|
||||
print(" " + CROSS + "svcServiceManagement has different Domain Id than OperatorApplication")
|
||||
else:
|
||||
print(" " + CROSS + "svcServiceManagement is not running")
|
||||
|
||||
if is_running("svcAreaEffectSimulation"):
|
||||
print(" " + CHECKMARK + "svcAreaEffectSimulation is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcAreaEffectSimulation is not running")
|
||||
|
||||
if is_running("svcCentralEffectSimulation"):
|
||||
print(" " + CHECKMARK + "svcCentralEffectSimulation is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcCentralEffectSimulation is not running")
|
||||
|
||||
if is_running("svcExerciseEventManagement"):
|
||||
print(" " + CHECKMARK + "svcExerciseEventManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcExerciseEventManagement is not running")
|
||||
|
||||
if is_running("svcExerciseManagement"):
|
||||
print(" " + CHECKMARK + "svcExerciseManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcExerciseManagement is not running")
|
||||
|
||||
if is_running("svcParticipantManagement"):
|
||||
print(" " + CHECKMARK + "svcParticipantManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcParticipantManagement is not running")
|
||||
|
||||
if is_running("svcProjectDataManagement"):
|
||||
print(" " + CHECKMARK + "svcProjectDataManagement is running")
|
||||
else:
|
||||
print(" " + CROSS + "svcProjectDataManagement is not running")
|
||||
|
||||
|
||||
def checkDiskUsage(disk_usage, threshold):
|
||||
for disk in disk_usage:
|
||||
percent_used = disk['percent_used']
|
||||
if percent_used > threshold:
|
||||
print(WARN + f"Disk {disk['mountpoint']} is {percent_used}% full!")
|
||||
|
||||
|
||||
def checkLocalDiskSpace():
|
||||
partitions = psutil.disk_partitions()
|
||||
|
||||
for partition in partitions:
|
||||
try:
|
||||
usage = shutil.disk_usage(partition.mountpoint)
|
||||
total = usage.total
|
||||
used = usage.used
|
||||
percent_used = (used / total) * 100
|
||||
if percent_used > 80:
|
||||
print(WARN + f"Disk {partition.mountpoint} is {percent_used}% full!")
|
||||
|
||||
except Exception as e:
|
||||
print("Fehler bei der Festplattenüberprüfung")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user