Added error handling
This commit is contained in:
parent
c69019f894
commit
d47fe3833e
@ -22,11 +22,9 @@ def prom_exporter():
|
|||||||
# Initiatise client
|
# Initiatise client
|
||||||
client = Client(connection)
|
client = Client(connection)
|
||||||
|
|
||||||
#pprint.pprint(client.device.signal()) # Can be accessed without authorization
|
pprint.pprint(client.device.signal()) # Can be accessed without authorization
|
||||||
#pprint.pprint(client.device.information()) # Needs valid authorization, will throw exception if invalid credentials are passed in URL
|
#pprint.pprint(client.device.information()) # Needs valid authorization, will throw exception if invalid credentials are passed in URL
|
||||||
|
|
||||||
dev = 'deviceName="'+ client.device.information().get('DeviceName')+'",iccid="'+client.device.information().get('Iccid')+'"'
|
|
||||||
devband = dev+',band="'+client.device.signal().get('band')+'"'
|
|
||||||
signal = { 'band' : client.device.signal().get('band'),
|
signal = { 'band' : client.device.signal().get('band'),
|
||||||
'rsrp' : client.device.signal().get('rsrp').replace("dBm", ""),
|
'rsrp' : client.device.signal().get('rsrp').replace("dBm", ""),
|
||||||
'rsrq' : client.device.signal().get('rsrq').replace("dB", ""),
|
'rsrq' : client.device.signal().get('rsrq').replace("dB", ""),
|
||||||
@ -34,31 +32,42 @@ def prom_exporter():
|
|||||||
'sinr' : client.device.signal().get('sinr').replace("dB", "")
|
'sinr' : client.device.signal().get('sinr').replace("dB", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev = 'deviceName="'+ client.device.information().get('DeviceName')+'",iccid="'+client.device.information().get('Iccid')+'"'
|
||||||
|
devband=dev
|
||||||
|
if signal.get('band') is not None:
|
||||||
|
devband = dev+',band="'+signal.get('band')+'"'
|
||||||
|
|
||||||
# HELP ifInDiscards The number of inbound packets which were chosen to be discarded even though no errors had been detected to prevent their being deliverable to a higher-layer protocol - 1.3.6.1.2.1.2.2.1.13
|
# HELP ifInDiscards The number of inbound packets which were chosen to be discarded even though no errors had been detected to prevent their being deliverable to a higher-layer protocol - 1.3.6.1.2.1.2.2.1.13
|
||||||
# TYPE ifInDiscards counter
|
# TYPE ifInDiscards counter
|
||||||
#ifInDiscards{ifAlias="",ifDescr="atm0",ifIndex="7",ifName=""} 81
|
#ifInDiscards{ifAlias="",ifDescr="atm0",ifIndex="7",ifName=""} 81
|
||||||
|
|
||||||
response=[]
|
response=[]
|
||||||
# Band
|
# Band
|
||||||
response.append('#HELP band The signal band the LTE connection is using')
|
if signal.get('band') is not None:
|
||||||
response.append('#TYPE band gauge')
|
response.append('#HELP band The signal band the LTE connection is using')
|
||||||
response.append('band{'+dev+'} '+signal.get('band'))
|
response.append('#TYPE band gauge')
|
||||||
|
response.append('band{'+dev+'} '+signal.get('band'))
|
||||||
# rsrp
|
# rsrp
|
||||||
response.append('#HELP rsrp The average power received from a single Reference signal, and Its typical range is around -44dbm (good) to -140dbm(bad)')
|
if signal.get('rsrp') is not None:
|
||||||
response.append('#TYPE rsrp gauge')
|
response.append('#HELP rsrp The average power received from a single Reference signal, and Its typical range is around -44dbm (good) to -140dbm(bad)')
|
||||||
response.append('rsrp{'+devband+'} '+signal.get('rsrp'))
|
response.append('#TYPE rsrp gauge')
|
||||||
|
response.append('rsrp{'+devband+'} '+signal.get('rsrp'))
|
||||||
# rsrq
|
# rsrq
|
||||||
response.append('#HELP rsrq Indicates quality of the received signal, and its range is typically -19.5dB(bad) to -3dB (good)')
|
if signal.get('rsrq') is not None:
|
||||||
response.append('#TYPE rsrq gauge')
|
response.append('#HELP rsrq Indicates quality of the received signal, and its range is typically -19.5dB(bad) to -3dB (good)')
|
||||||
response.append('rsrq{'+devband+'} '+signal.get('rsrq'))
|
response.append('#TYPE rsrq gauge')
|
||||||
|
response.append('rsrq{'+devband+'} '+signal.get('rsrq'))
|
||||||
# rssi
|
# rssi
|
||||||
response.append('#HELP rssi Represents the entire received power including the wanted power from the serving cell as well as all co-channel power and other sources of noise in dBm')
|
if signal.get('rssi') is not None:
|
||||||
response.append('#TYPE rssi gauge')
|
response.append('#HELP rssi Represents the entire received power including the wanted power from the serving cell as well as all co-channel power and other sources of noise in dBm')
|
||||||
response.append('rssi{'+devband+'} '+signal.get('rssi'))
|
response.append('#TYPE rssi gauge')
|
||||||
|
response.append('rssi{'+devband+'} '+signal.get('rssi'))
|
||||||
# sinr
|
# sinr
|
||||||
response.append('#HELP sinr The signal-to-noise ratio of the given signal in dB')
|
if signal.get('sinr') is not None:
|
||||||
response.append('#TYPE sinr gauge')
|
response.append('#HELP sinr The signal-to-noise ratio of the given signal in dB')
|
||||||
response.append('sinr{'+devband+'} '+signal.get('sinr'))
|
response.append('#TYPE sinr gauge')
|
||||||
|
response.append('sinr{'+devband+'} '+signal.get('sinr'))
|
||||||
|
|
||||||
s='\n'
|
s='\n'
|
||||||
return s.join(response)
|
return s.join(response)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user