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 '= []'?
prom_disp_servers=prom_disp_servers+prom_header('Relative usage of whole enc AC the blade is consuming in watts',promRelAC,'gauge')
prom_disp_servers=prom_disp_servers+prom_header('Actual DC in watts what the blade uses directly',promBldDC,'gauge')
prom_disp_servers=prom_disp_servers+prom_header('Blade health 1 for ok 0 for nok NaN for err',promHealth,'gauge')
prom_disp_servers=prom_disp_servers+prom_header('Blade UID blinkyboy 1 for blinky blinky 0 for no blinky blinky NaN for err',promUID,'gauge')
prom_disp_servers=prom_disp_servers+prom_header('Blade power 1 for on and everything in between 0 for off NaN for err',promPower,'gauge')
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',[PREFIX+'errors '+str(errors)],'counter')