--- checkStation/checkStation.py 2005/05/15 10:46:29 1.3
+++ checkStation/checkStation.py 2005/06/23 17:12:56 1.6
@@ -6,8 +6,11 @@ import os
import os.path
import time
-module_list=['11150','11220','11240','11340','12010','13110','13210','13310','13500','20610','21210','21600','22310','23110','24110','24212','24231','24241','24251','24321','24341','24411','24421','24431','24441','24511','24521','30511','31111','31120','31131','31142','31151','31161','31171','31211','31221','31231','31252','31305','31410','32010','33100']
-grepString="DragThing"
+module_list=['10010','11150','11220','11240','11340','12010','13110','13210','13310','13500','20610','21210','21600','22310','23110','24110','24212','24231','24241','24251','24321','24341','24411','24421','24431','24441','24511','24521','30511','31111','31120','31131','31142','31151','31161','31171','31211','31221','31231','31252','31305','31410','32010','33100']
+
+# station non checked: 31211
+
+grepString="firefox-bin"
def zptFile(self, path, orphaned=False):
"""returns a page template file from the product"""
@@ -44,6 +47,14 @@ def checkFormat(line,formats):
except:
return False
+def getIP(line):
+ """ip aus pound log line"""
+ splitted=line.split()
+ try:
+ return splitted[5]
+ except:
+ return 0
+
def cmpLine(line):
"""gibt minuten zwischen letztem Eintrag und localtime"""
@@ -82,16 +93,19 @@ class checkStation(SimpleItem):
{'label':'checkRebootDead','action':'checkRebootDead'},
{'label':'Reboot Overview','action':'rebootOverview'},
)
- def asctime(self):
- return time.asctime(tm)
-
+ def asctime(self,tm):
+ try:
+ return time.asctime(tm)
+ except:
+ return "never"
+
def __init__(self, id, path):
"""init"""
self.path=path #pfad fuer logfile
self.id=id
self.modulOverview={}
- def checkStation(self,nr,time=5,formats=["VID"]):
+ def checkStation(self,nr,time=7,formats=["VID","BRA","ZOG","TXT","IMG"]):
"""check station with nr nr"""
txt=[]
@@ -106,18 +120,19 @@ class checkStation(SimpleItem):
return True,"",0
cmpT=cmpLine(line)
-
+ ip=getIP(line)
+
if not checkFormat(line,formats):
# teste ob letzte Zeile vom format in formats
- return True,line,cmpT
+ return True,line,cmpT,ip
if cmpT > time:
- return False,line,cmpT
+ return False,line,cmpT,ip
else:
- return True,line,cmpT
+ return True,line,cmpT,ip
def getModuls(self):
"""getModuls"""
@@ -131,10 +146,10 @@ class checkStation(SimpleItem):
ips={"22222":"127.0.0.1","33335":"127.0.0.2"}
- def rebootStation(self,modul):
+ def rebootStation(self,ip):
"""neustart"""
retStr=""
- ip=self.ips[modul]
+ #ip=self.ips[modul]
str="""ssh root@%s "ps -xa | grep %s" """
rets=os.popen(str%(ip,grepString)).readlines()
@@ -144,26 +159,26 @@ class checkStation(SimpleItem):
if ret.find("grep") <= 0:
process=ret.split()[0]
str="""ssh root@%s kill -9 %s """
- #os.popen(str%(ip,process)).readlines()
- retStr+=str%(ip,process) + "/n"
+ os.popen(str%(ip,process)).readlines()
+ retStr+=str%(ip,process) + "
"
return retStr
- def checkRebootDead(self,timer=5):
+ def checkRebootDead(self,timer=7):
"""checks and reboots non responding firefox"""
self.lastCheck=time.localtime()
- ret="
" + ret="
" for modul in self.getModuls(): - checked=self.checkStation(modul,time=timer,formats=["VID"]) + checked=self.checkStation(modul,time=timer) if not checked[0]: - ret+=self.rebootStation(modul) + ret+=self.rebootStation(checked[3]) if not hasattr(self,'modulOverview'): setattr(self,'modulOverview',{}) self.modulOverview[modul]=time.localtime() - + return ret+"
" def rebootOverview(self): """give Overview"""