raiseTypeError("promify_item: desc must be a string, '"+str(desc)+"' is not.")
ifnottype(item)islist:
raiseTypeError("promify_item: item must be a list, '"+str(item)+"' is not.")
ifnottype(promtype)isstr:
raiseTypeError("promify_item: promtype must be a string, '"+str(promtype)+"' is not.")
name=item[0].split('{')[0]# something like bladetest_blade_bladeonly_dc, could be given as an argument, but human changing this code might forget to change the argument inputs
item.insert(0,'# HELP '+name+''+desc)# insert 2 header lines (in the same order as seen here) for the item
ifpromtype=="gauge":
item.insert(1,'# TYPE '+name+' gauge')
elifpromtype=="counter":
item.insert(1,'# TYPE '+name+' counter')
else:
raiseValueError("promify_item: "+promtype+" promtype is either not implemented as a type, or invalid.")
return(item)
defprom_servers(PREFIX,baysInUseCount,servers):
# Input validation
ifnottype(baysInUseCount)isint:
raiseTypeError("parseServers: baysInUseCount must be an integer, '"+str(baysInUseCount)+"' is not.")
ifnottype(servers)islist:
raiseTypeError("parseServers: servers must be a list, '"+str(servers)+"' is not.")
promRelAC=[]# Init all, is there a way to condense this to single line, and not repeat the '= []'?
promBldDC=[]
promHealth=[]
promUID=[]
promPower=[]
errors=0
forninrange(baysInUseCount):
ifservers[n][2]=='':# If no serial
warn("no serial on blade '"+servers[n][1]+"' in enc "+servers[n][8]+" bay "+str(servers[n][0])+".")
prom_disp_servers=prom_disp_servers+prom_header('Number of errors or warnings encountered during the gathering of data see logs of promServers in blade-ssh-scraper',errors_prom,'counter')