Beispiel #1
0
    def __init__(self):
        try:
            shutil.rmtree(osconfig.statisticsPath())
        except:
            pass
        os.makedirs(osconfig.statisticsPath())

        self.statsMap = {}
        self.statsLock = BoundedSemaphore(1)

        self.pptFailureCount = 0
        self.pdfFailureCount = 0
        self.retrieveFailureCount = 0
Beispiel #2
0
 def __init__(self):
     try:
         shutil.rmtree(osconfig.statisticsPath())
     except:
         pass
     os.makedirs(osconfig.statisticsPath())
     
     self.statsMap = {}
     self.statsLock = BoundedSemaphore(1)
     
     self.pptFailureCount = 0
     self.pdfFailureCount = 0
     self.retrieveFailureCount = 0
Beispiel #3
0
    def unregister(self, docID):
        
        if not self.statsMap.get(docID):
            return
        
        # remove from statsMap
        try:
            self.statsMap.pop(docID)
        except:
            pass

        filePath = os.path.join(osconfig.statisticsPath(),docID)
        fp = open(filePath, 'w')
        fp.close()
Beispiel #4
0
    def unregister(self, docID):

        if not self.statsMap.get(docID):
            return

        # remove from statsMap
        try:
            self.statsMap.pop(docID)
        except:
            pass

        filePath = os.path.join(osconfig.statisticsPath(), docID)
        fp = open(filePath, 'w')
        fp.close()
Beispiel #5
0
    def queryHealth(self):
        
        lock = scopedLock(self.statsLock)
        
        waitingCount = 0
        officeCount = 0  # Maximum 1 allowed.
        pdf2swfCount = 0
        completedCount = 0
        
        health = 'NORMAL >> '
        
        for value in self.statsMap.itervalues():
            if value == 'waiting':
                waitingCount += 1
            elif value == 'office':
                officeCount += 1
            else:
                pdf2swfCount += 1
                
        for root, dirs, files in os.walk(osconfig.statisticsPath()):
            completedCount += len(files)
            
        if officeCount == 0 and pdf2swfCount == 0 and waitingCount > 0:
            health = 'CRITICAL >> '
            
        if officeCount > 1:
            health = 'WARNING >> '
            
        if self.pdfFailureCount >= 3:
            health = 'CRITICAL >> '

        if self.pptFailureCount >= 3:
            health = 'CRITICAL >> '
            
        if self.retrieveFailureCount >= 5:
            health = 'CRITICAL >> '
            
        return health + ' Waiting = ' + str(waitingCount) + ', Office = ' + str(officeCount) + \
    ', Pdf2Swf = ' + str(pdf2swfCount) + ', Completed = ' + str(completedCount) + \
    ', Consecutive_PDF_Upload_Failures = ' + str(self.pdfFailureCount) + ', Consecutive_PPT_Upload_Failures = ' + str(self.pptFailureCount) + \
    ', Consecutive_Retrieve_Failures = ' + str(self.retrieveFailureCount)
Beispiel #6
0
    def queryHealth(self):

        lock = scopedLock(self.statsLock)

        waitingCount = 0
        officeCount = 0  # Maximum 1 allowed.
        pdf2swfCount = 0
        completedCount = 0

        health = 'NORMAL >> '

        for value in self.statsMap.itervalues():
            if value == 'waiting':
                waitingCount += 1
            elif value == 'office':
                officeCount += 1
            else:
                pdf2swfCount += 1

        for root, dirs, files in os.walk(osconfig.statisticsPath()):
            completedCount += len(files)

        if officeCount == 0 and pdf2swfCount == 0 and waitingCount > 0:
            health = 'CRITICAL >> '

        if officeCount > 1:
            health = 'WARNING >> '

        if self.pdfFailureCount >= 3:
            health = 'CRITICAL >> '

        if self.pptFailureCount >= 3:
            health = 'CRITICAL >> '

        if self.retrieveFailureCount >= 5:
            health = 'CRITICAL >> '

        return health + ' Waiting = ' + str(waitingCount) + ', Office = ' + str(officeCount) + \
    ', Pdf2Swf = ' + str(pdf2swfCount) + ', Completed = ' + str(completedCount) + \
    ', Consecutive_PDF_Upload_Failures = ' + str(self.pdfFailureCount) + ', Consecutive_PPT_Upload_Failures = ' + str(self.pptFailureCount) + \
    ', Consecutive_Retrieve_Failures = ' + str(self.retrieveFailureCount)
Beispiel #7
0
    def queryHealthState(self, param):
        
        lock = scopedLock(self.statsLock)

        param = string.lower(param)
        
        waitingCount = 0
        officeCount = 0  # Maximum 1 allowed.
        pdf2swfCount = 0
        completedCount = 0

        health = 'NORMAL'

        for value in self.statsMap.itervalues():
            if value == 'waiting':
                waitingCount += 1
            elif value == 'office':
                officeCount += 1
            else:
                pdf2swfCount += 1

        for root, dirs, files in os.walk(osconfig.statisticsPath()):
            completedCount += len(files)

        if officeCount == 0 and pdf2swfCount == 0 and waitingCount > 0:
            health = 'CRITICAL'

        if officeCount > 1:
            health = 'WARNING'
            
        if officeCount == 0 and waitingCount == 0 and pdf2swfCount >= (2* osconfig.maxPDFAccess()):
            health = 'WARNING'
            
        if self.pdfFailureCount >= 3:
            health = 'CRITICAL'
            
        if self.pptFailureCount >= 3:
            health = 'CRITICAL'
            
        if self.retrieveFailureCount >= 5:
            health = 'CRITICAL'
            
        if param == 'waiting':
            return str(waitingCount)
        
        if param == 'office':
            return str(officeCount)
        
        if param == 'pdf':
            return str(pdf2swfCount)
        
        if param == 'completed':
            return str(completedCount)
        
        if param == 'pptfailures':
            return str(self.pptFailureCount)
        
        if param == 'pdffailures':
            return str(self.pdfFailureCount)
        
        if param == 'retrievefailures':
            return str(self.retrieveFailureCount)
        
        return health
Beispiel #8
0
    def queryHealthState(self, param):

        lock = scopedLock(self.statsLock)

        param = string.lower(param)

        waitingCount = 0
        officeCount = 0  # Maximum 1 allowed.
        pdf2swfCount = 0
        completedCount = 0

        health = 'NORMAL'

        for value in self.statsMap.itervalues():
            if value == 'waiting':
                waitingCount += 1
            elif value == 'office':
                officeCount += 1
            else:
                pdf2swfCount += 1

        for root, dirs, files in os.walk(osconfig.statisticsPath()):
            completedCount += len(files)

        if officeCount == 0 and pdf2swfCount == 0 and waitingCount > 0:
            health = 'CRITICAL'

        if officeCount > 1:
            health = 'WARNING'

        if officeCount == 0 and waitingCount == 0 and pdf2swfCount >= (
                2 * osconfig.maxPDFAccess()):
            health = 'WARNING'

        if self.pdfFailureCount >= 3:
            health = 'CRITICAL'

        if self.pptFailureCount >= 3:
            health = 'CRITICAL'

        if self.retrieveFailureCount >= 5:
            health = 'CRITICAL'

        if param == 'waiting':
            return str(waitingCount)

        if param == 'office':
            return str(officeCount)

        if param == 'pdf':
            return str(pdf2swfCount)

        if param == 'completed':
            return str(completedCount)

        if param == 'pptfailures':
            return str(self.pptFailureCount)

        if param == 'pdffailures':
            return str(self.pdfFailureCount)

        if param == 'retrievefailures':
            return str(self.retrieveFailureCount)

        return health