summaryrefslogtreecommitdiffstats
path: root/Code/Server-Code/truthtableClass.py
diff options
context:
space:
mode:
Diffstat (limited to 'Code/Server-Code/truthtableClass.py')
-rw-r--r--[-rwxr-xr-x]Code/Server-Code/truthtableClass.py80
1 files changed, 67 insertions, 13 deletions
diff --git a/Code/Server-Code/truthtableClass.py b/Code/Server-Code/truthtableClass.py
index 0d7a633..c45ab4d 100755..100644
--- a/Code/Server-Code/truthtableClass.py
+++ b/Code/Server-Code/truthtableClass.py
@@ -9,6 +9,11 @@ class trueTable:
self.incomingRZ = None
self.openBSC = None
self.nanoBTS = None
+ self.deviceStatus = list()
+ self.testMount = len(resultsList)
+ self.OK = 0
+ self.FAILED = 0
+ self.handlerError = 0
def initDB(self):
# function for connect to database
@@ -27,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 items in deviceLists:
+ device = items[0]
+ 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'])
+
+ 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[1] == 'OK':
+ self.OK = self.OK+1
+ elif status[1] == 'NOT OK':
+ self.FAILED = self.FAILED+1
+ else:
+ self.handlerError = self.handlerError+1
+
def initTrueTable(self):
global btsName
self.initDB()
@@ -39,7 +102,7 @@ class trueTable:
if device[0:5] == 'GSMEx' or device == 'landline':
externalRZList.append(device) # fetch into the list
self.db.closeDBConn()
- lists = self.resultsList
+ lists = self.resultsList
self.nanoBts = list()
gsmResultList = list()
@@ -113,25 +176,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:
- self.lookingBTSname(key)
- if self.found != True:
- self.nanoBts.append([key,result])
-
- if str(result) == '998' 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) == '999' and key == call:
- self.lookingBTSname(key)
- if self.found != True:
- self.nanoBts.append([key,result])
+
j = j+1
elif j == i:
stop = True