Browse Source

status check in gctools integriert

gc-server3 1 year ago
parent
commit
98832d5260
5 changed files with 33 additions and 12 deletions
  1. BIN
      dist/gctools.exe
  2. 2 0
      gctools.py
  3. 14 0
      status.py
  4. 2 1
      status_client/path_info.py
  5. 15 11
      status_client/status_client.py

BIN
dist/gctools.exe


+ 2 - 0
gctools.py

@@ -2,11 +2,13 @@ import typer
 import c11
 import db
 import xls
+import status
 
 app = typer.Typer()
 app.add_typer(c11.app, name="c11")
 app.add_typer(db.app, name="db")
 app.add_typer(xls.app, name="excel")
+app.add_typer(status.app, name="status")
 
 
 if __name__ == "__main__":

+ 14 - 0
status.py

@@ -0,0 +1,14 @@
+import typer
+from status_client.status_client import main
+
+app = typer.Typer()
+# cfg = config.Config()
+
+
+@app.command()
+def check():
+    main()
+
+
+if __name__ == "__main__":
+    app()

+ 2 - 1
status_client/path_info.py

@@ -45,7 +45,8 @@ class PathInfo:
 
         for entry in current_dir.glob("*"):
             if entry.is_dir():
-                self.check_dir(entry)
+                if entry.name.lower() not in [".git", "python", "php"]:
+                    self.check_dir(entry)
             elif not self.ignored(entry):
                 self.file_list.append(self.file_info(entry))
 

+ 15 - 11
status_client/status_client.py

@@ -17,7 +17,7 @@ def run_command(cmd, logfile):
 
 
 def task_scheduler(logfile):
-    run_command("schtasks /query /v /fo CSV", logfile)
+    run_command('schtasks /query /v /fo CSV | find ".bat"', logfile)
 
 
 def task_manager(logfile):
@@ -43,12 +43,12 @@ def datasources_all_models(cfg: config.Config):
         model_datasources(cfg, model_file, cfg.tasks_dir + "\\config\\models\\" + model_file.name + ".log")
 
 
-def database_info(cfg: config.Config):
+def database_info(cfg: config.Config, csv_file):
     dbinfo = DatabaseInfo()
     result = []
     for db in dbinfo.databases():
         result.extend(dbinfo.table_size(db[0]))
-    csv_file = cfg.tasks_dir + "\\logs\\db_info.csv"
+
     with open(csv_file, "w", encoding="latin-1", newline="") as fwh:
         wr = csv.writer(fwh, delimiter=";")
         wr.writerow(
@@ -78,29 +78,33 @@ def zip_to_file(base_dir, zip_file):
                     zip.write(e, e.relative_to(base_dir))
 
 
-if __name__ == "__main__":
+def main():
     cfg = config.Config()
 
     # Aufgabenplanung aktueller Stand
-    task_scheduler(cfg.tasks_dir + "\\logs\\schtasks.csv")
+    task_scheduler(cfg.log_dir + "\\schtasks.csv.log")
     # Laufende Prozesse
-    task_manager(cfg.tasks_dir + "\\logs\\tasklist.csv")
+    task_manager(cfg.log_dir + "\\tasklist.csv.log")
     # aktuelle Freigabe-Sessions
-    shared_files(cfg.tasks_dir + "\\logs\\openfiles.csv")
+    shared_files(cfg.log_dir + "\\openfiles.csv.log")
     # Tabellengrößen
-    database_info(cfg)
+    database_info(cfg, cfg.log_dir + "\\db_info.csv.log")
 
-    datasources_all_models(cfg)
+    # datasources_all_models(cfg)
     # Liste aller Dateien im GAPS-Verzeichnis
     # filename;size;cdate;mdate
     ti = PathInfo()
     ti.check_dir(cfg.portal_dir)
-    ti.write_logfile(cfg.tasks_dir + "\\logs\\path_info.csv")
+    ti.write_logfile(cfg.log_dir + "\\path_info.csv.log")
 
     # Logdateien aus Tasks/logs und System/prot
     timestamp = datetime.now().strftime("%Y-%m-%d_%H%M%S")
-    zip_file = f"{cfg.tasks_dir}\\logs\\{cfg.kunde_safe}_{timestamp}.zip"
+    zip_file = f"{cfg.tasks_dir}\\logs\\zip\\{cfg.kunde_safe}_{timestamp}.zip"
     zip_to_file(cfg.tasks_dir, zip_file)
 
     # Upload auf FTP
     FtpClient().upload(zip_file)
+
+
+if __name__ == "__main__":
+    main()