File indexing completed on 2024-04-28 15:14:08
0001 #!/usr/bin/python 0002 0003 from socket import * 0004 import psutil 0005 0006 HOST = 'localhost' 0007 PORT = 1027 0008 ADDR = (HOST,PORT) 0009 0010 serv = socket(AF_INET, SOCK_DGRAM) 0011 serv.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) 0012 while True: 0013 cpu_percent = str(psutil.cpu_percent(interval=0.5)) 0014 serv.sendto(cpu_percent, ADDR) 0015 print 'written ' + cpu_percent, ADDR