summaryrefslogtreecommitdiffstats
path: root/Under-Testing/Server-Code-New/truthtableClass.py
diff options
context:
space:
mode:
authorTriatmoko2011-11-18 01:00:28 +0100
committerTriatmoko2011-11-18 01:00:28 +0100
commit3daa733bd4575779a610edeec0b88b0cdff41198 (patch)
tree0d9e725eb1afbda47203741e0b5e8946b2c261a4 /Under-Testing/Server-Code-New/truthtableClass.py
parent.... (diff)
downloadgsm-selftest-3daa733bd4575779a610edeec0b88b0cdff41198.tar.gz
gsm-selftest-3daa733bd4575779a610edeec0b88b0cdff41198.tar.xz
gsm-selftest-3daa733bd4575779a610edeec0b88b0cdff41198.zip
edit nagios algorithm
Diffstat (limited to 'Under-Testing/Server-Code-New/truthtableClass.py')
-rw-r--r--Under-Testing/Server-Code-New/truthtableClass.py83
1 files changed, 62 insertions, 21 deletions
diff --git a/Under-Testing/Server-Code-New/truthtableClass.py b/Under-Testing/Server-Code-New/truthtableClass.py
index 253069b..cf20bc8 100644
--- a/Under-Testing/Server-Code-New/truthtableClass.py
+++ b/Under-Testing/Server-Code-New/truthtableClass.py
@@ -9,6 +9,7 @@ class trueTable:
self.incomingRZ = None
self.openBSC = None
self.nanoBTS = None
+ self.deviceStatus = list()
self.testMount = len(resultsList)
self.OK = 0
self.FAILED = 0
@@ -31,6 +32,64 @@ class trueTable:
self.found = True
return self.found
+ def findStatusInList(self,key):
+
+ if len(self.deviceStatus) == 0:
+ update = False
+ else:
+ update = False
+ for item in self.deviceStatus:
+ if key == item[0] and str(item[1]) != 'OK':
+ update = True
+ return update
+
+ def initNagiosResult(self):
+ self.initDB()
+ deviceLists = self.db.deviceList()
+ self.db.closeDBConn()
+
+ for device in deviceLists:
+ for result in self.resultsList:
+ if device == result[0] or device == result[1]:
+ if int(result[2]) == 200:
+ if self.findStatusInList(device) == True:
+ try:
+ self.deviceStatus.remove([device,'NOT OK'])
+ except:
+ try:
+ self.deviceStatus.remove([device,'UNKNOWN'])
+ except:
+ continue
+ self.deviceStatus.append([device,'OK'])
+ else:
+ self.deviceStatus.append([device,'OK'])
+ break
+
+ elif int(result[2]) == 486:
+ found = False
+ for item in self.deviceStatus:
+ if device == item[0]:
+ if str(item[1]) != 'OK' or str(item[1]) == 'OK':
+ found = True
+ if found == False:
+ self.deviceStatus.append([device,'NOT OK'])
+ else:
+ found = False
+ for item in self.deviceStatus:
+ if device == item[0]:
+ if str(item[1]) != 'OK' or str(item[1]) == 'OK':
+ found = True
+ if found == False:
+ self.deviceStatus.append([device,'UNKNOWN'])
+ for status in self.deviceStatus:
+
+ if status[2] == 'OK':
+ self.OK = self.OK+1
+ elif status[2] == 'NOT OK:
+ self.FAILED = self.FAILED+1
+ else:
+ self.handlerError = self.handlerError+1
+
def initTrueTable(self):
global btsName
self.initDB()
@@ -43,18 +102,9 @@ class trueTable:
if device[0:5] == 'GSMEx' or device == 'landline':
externalRZList.append(device) # fetch into the list
self.db.closeDBConn()
- lists = self.resultsList
self.nanoBts = list()
gsmResultList = list()
- for status in lists:
-
- if int(status[2]) == 200:
- self.OK = self.OK+1
- elif int(status[2]) == 486:
- self.FAILED = self.FAILED+1
- else:
- self.handlerError = self.handlerError+1
i= 1
for w in lists:
call=w[0]
@@ -125,25 +175,16 @@ class trueTable:
if found != True:
self.nanoBts.append([btsName,False])
- elif str(result) == '801' and key == call:
+ elif (str(result) == '801' or str(result) == '999') and key == call:
self.lookingBTSname(key)
if self.found != True:
self.nanoBts.append([key,result])
- elif str(result) == '802'and key == dest:
+ elif (str(result) == '802' or str(result) == '998') and key == dest:
self.lookingBTSname(key)
if self.found != True:
self.nanoBts.append([key,result])
-
- if str(result) == '998' and key == dest:
- self.lookingBTSname(key)
- if self.found != True:
- self.nanoBts.append([key,result])
-
- if str(result) == '999' and key == call:
- self.lookingBTSname(key)
- if self.found != True:
- self.nanoBts.append([key,result])
+
j = j+1
elif j == i:
stop = True