I have written a python script that collect some WMI data from machine.
I want this script to run 24*7 and get the WMI data.
How can I get this script to execute 24/7, such as turning it into agent or service in Windows. I also need a loop that never ends in the program, or can it be done by just having the code re executed multiple times?
Thanks
Here the basic script.
import os
import time
import wmi
c = wmi.WMI()
def systeminfo1():
for cpu in c.Win32_Processor():
print('cpu_useper', cpu.LoadPercentage)
def systeminfo():
for mem in c.Win32_PerfFormattedData_PerfOS_Memory():
print('Memused_perc', mem.PercentCommittedBytesInUse)
while True:
systeminfo()
time.sleep(5)
systeminfo1()
time.sleep(30)