def showHostErrors( self ): DN = getUserDN() group = getSelectedGroup() if not "host" in request.params: return { "success" : "false" , "error" : "Name of the host is missing or not defined" } host = str( request.params[ "host" ] ) client = SystemAdministratorClient( host , None , delegatedDN=DN , delegatedGroup=group ) result = client.checkComponentLog( "*" ) gLogger.debug( result ) if not result[ "OK" ]: return { "success" : "false" , "error" : result[ "Message" ] } result = result[ "Value" ] callback = list() for key, value in result.items(): system, component = key.split( "/" ) value[ "System" ] = system value[ "Name" ] = component value[ "Host" ] = host callback.append( value ) total = len( callback ) return { "success" : "true" , "result" : callback , "total" : total }
def getErrors(self, argss): """ Get and print out errors from the logs of specified components """ component = '' if len(argss) < 1: component = '*' else: system = argss[0] if system == "*": component = '*' else: if len(argss) < 2: print print self.do_show.__doc__ return comp = argss[1] component = '/'.join([system, comp]) client = SystemAdministratorClient(self.host, self.port) result = client.checkComponentLog(component) if not result['OK']: self.__errMsg(result['Message']) else: fields = [ 'System', 'Component', 'Last hour', 'Last day', 'Last error' ] records = [] for cname in result['Value']: system, component = cname.split('/') errors_1 = result['Value'][cname]['ErrorsHour'] errors_24 = result['Value'][cname]['ErrorsDay'] lastError = result['Value'][cname]['LastError'] lastError.strip() if len(lastError) > 80: lastError = lastError[:80] + '...' records.append([ system, component, str(errors_1), str(errors_24), lastError ]) records.sort() printTable(fields, records)
def getErrors( self, argss ): """ Get and print out errors from the logs of specified components """ component = '' if len( argss ) < 1: component = '*' else: system = argss[0] if system == "*": component = '*' else: if len( argss ) < 2: print print self.do_show.__doc__ return comp = argss[1] component = '/'.join( [system, comp] ) client = SystemAdministratorClient( self.host, self.port ) result = client.checkComponentLog( component ) if not result['OK']: self.__errMsg( result['Message'] ) else: fields = ['System', 'Component', 'Last hour', 'Last day', 'Last error'] records = [] for cname in result['Value']: system, component = cname.split( '/' ) errors_1 = result['Value'][cname]['ErrorsHour'] errors_24 = result['Value'][cname]['ErrorsDay'] lastError = result['Value'][cname]['LastError'] lastError.strip() if len( lastError ) > 80: lastError = lastError[:80] + '...' records.append( [system, component, str( errors_1 ), str( errors_24 ), lastError] ) records.sort() printTable( fields, records )