status_client.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import subprocess
  2. import csv
  3. def run_command(cmd, logfile):
  4. with open(logfile, 'wb') as stream:
  5. p = subprocess.Popen(cmd, stdout=stream, stderr=stream)
  6. p.wait()
  7. def task_scheduler():
  8. logfile = 'C:/projekte/python/logs/schtasks.csv'
  9. run_command('schtasks /query /v /fo CSV', logfile)
  10. with open(logfile, "r", encoding="cp850", errors="ignore", newline="") as source_file:
  11. csv_read = csv.reader(source_file, delimiter=",")
  12. header = next(csv_read)
  13. for row in csv_read:
  14. if row[0] != 'Hostname' and not row[1].startswith('\\Microsoft') and row[2] != 'Nicht zutreffend':
  15. print(";".join(row))
  16. def task_manager():
  17. logfile = 'C:/projekte/python/logs/tasklist.csv'
  18. run_command('tasklist /fo CSV', logfile)
  19. with open(logfile, "r", encoding="cp850", errors="ignore", newline="") as source_file:
  20. csv_read = csv.reader(source_file, delimiter=",")
  21. header = next(csv_read)
  22. for row in csv_read:
  23. if row[0].lower() not in ['svchost.exe', 'teams.exe', 'chrome.exe', 'conhost.exe']:
  24. print(";".join(row))
  25. if __name__ == '__main__':
  26. # Aufgabenplanung aktueller Stand
  27. # task_scheduler()
  28. # Laufende Prozesse
  29. task_manager()
  30. # aktuelle Freigabe-Sessions
  31. # Liste aller Dateien im GAPS-Verzeichnis
  32. # filename;size;cdate;mdate
  33. # Logdateien aus Tasks/logs und System/prot