Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Created on Sep 28, 2011
- '''
- import time,struct,socket,os
- from subprocess import Popen,call
- inf = [(36967,"cs2d_dedicated1","/home/cs2d/cs2d_dedicated1"),(36964,"cs2d_dedicated2","/home/cs2d_2/cs2d_dedicated2")]
- ip = '127.0.0.1'
- if __name__ == "__main__":
- request_info = struct.pack('<9B',1,0,3,0x8D,0xA2,0xFB,0x01,0x73,0x00) # this is for getting server information
- s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
- s.settimeout(5) # if server doesnt respond after 5 secs, timeout
- while True:
- print "checking"
- for i in inf:
- port = i[0]
- s.sendto(request_info,(ip,port))
- try:
- s.recvfrom(128)
- print str(port) + " online!"
- except socket.timeout:
- print str(port) + " not online!"
- Popen(["/usr/bin/killall",i[1]],shell = False)
- Popen(["/usr/bin/screen","-D","-m",i[2]],shell=False)
- time.sleep(60)
Add Comment
Please, Sign In to add comment