CMK version:2.0.0p37 (CRE)
OS version:Centos7
**Error message:percentual supply brother black cyan magenta yellow **
**Output of “cmk --debug -vvn hostname”: ** (If it is a problem with checks or plugins)
#.1.3.6.1.2.1.43.9.2.1.8.1.1 Brother
#.1.3.6.1.2.1.25.3.2.1.2.1 .1.3.6.1.2.1.25.3.1.5
#.1.3.6.1.2.1.25.3.2.1.3.1 Brother MFC-L6900DW series
#.1.3.6.1.2.1.25.3.2.1.2.1 .1.3.6.1.2.1.25.3.1.5
#.1.3.6.1.2.1.43.11.1.1.6.1.1 Black Toner Cartridge
#.1.3.6.1.2.1.43.11.1.1.6.1.2 Drum Unit
#.1.3.6.1.2.1.43.12.1.1.4.1.1 black
#.1.3.6.1.2.1.43.12.1.1.5.1.1 2
#.1.3.6.1.2.1.43.13.4.1.2.1.1 7
#.1.3.6.1.2.1.43.13.4.1.2.1.2 7
#.1.3.6.1.2.1.43.13.4.1.2.1.3 7
#.1.3.6.1.2.1.43.13.4.1.3.1.1 4
#.1.3.6.1.2.1.43.13.4.1.3.1.2 4
#.1.3.6.1.2.1.43.13.4.1.3.1.3 4
#.1.3.6.1.2.1.43.12.1.1.4.1.1 black
#.1.3.6.1.2.1.43.12.1.1.4.1.2 cyan
#.1.3.6.1.2.1.43.12.1.1.4.1.3 magenta
#.1.3.6.1.2.1.43.12.1.1.4.1.4 yellow
#.1.3.6.1.2.1.25.3.2.1.3.1 Brother HL-L9310CDW series
#.1.3.6.1.2.1.25.3.2.1.2.1 .1.3.6.1.2.1.25.3.1.5
#.1.3.6.1.2.1.43.11.1.1.6.1.2 Cyan Toner Cartridge
#.1.3.6.1.2.1.43.11.1.1.6.1.3 Magenta Toner Cartridge
#.1.3.6.1.2.1.43.11.1.1.6.1.4 Yellow Toner Cartridge
#.1.3.6.1.2.1.43.11.1.1.6.1.5 Waste Toner Box
#.1.3.6.1.2.1.43.11.1.1.6.1.6 Belt Unit
#.1.3.6.1.2.1.43.11.1.1.6.1.7 Drum Unit
# "SNMPv2-SMI::enterprises.2435.2.3.9.4.2.1.5.5.8.0 = Hex-STRING:
# 63 01 04 00 00 00 01 68 01 04 00 00 00 01 55 01
# 04 00 00 00 01 31 01 04 00 00 00 01 32 01 04 00
# 00 00 01 33 01 04 00 00 00 01 34 01 04 00 00 00
# 01 70 01 04 00 00 23 F0 71 01 04 00 00 18 38 72
# 01 04 00 00 18 38 6F 01 04 00 00 05 78 41 01 04
# 00 00 24 B8 69 01 04 00 00 25 80 11 01 04 00 00
# 06 CF 67 01 04 00 00 00 01 6B 01 04 00 00 27 10
# 54 01 04 00 00 00 01 66 01 04 00 00 00 01 35 01
# 04 00 00 00 01 36 01 04 00 00 00 01 6A 01 04 00
# 00 27 10 6C 01 04 00 00 27 10 6D 01 04 00 00 27
# 10 6E 01 04 00 00 27 10 FF"
# "Black : 6F 01 04 00 00 05 78
# Cyan : 70 01 04 00 00 23 F0
# Magenta : 71 01 04 00 00 18 38
# Yellow : 72 01 04 00 00 18 38"
# "[Format : Pointer, Fixed Value, Data length, Data, Data, Data, Data]
# Black : Pointer = 6F, Data = 00000578 = 1400 (Decimal) -> 14%
# Cyan : Pointer = 70, Data = 000023F0 = 9200 (Decimal) -> 92%
# Magenta : Pointer = 71, Data = 00001838 = 6200 (Decimal) -> 62%
# Yellow : Pointer = 72, Data = 00001838 = 6200 (Decimal) -> 62%"
from .agent_based_api.v1 import *
def parse_printer_supply_brother(string_table):
parsed = []
for tonerblack, status in string_table[0]:
my_string = status
# Extract a substring from toner black
start_position = 84
end_position = 104
# Extract a substring from covenrt hex to decimal
start_position1 = 93
end_position1 = 104
# Extract a single substring from covenrt hex to decimal
start_position2 = 93
end_position2 = 95
# Extract a single substring from covenrt hex to decimal
start_position3 = 96
end_position3 = 98
# Extract a single substring from covenrt hex to decimal
start_position4 = 99
end_position4 = 101
# Extract a single substring from covenrt hex to decimal
start_position5 = 102
end_position5 = 104
substring = my_string[start_position:end_position]
substring1 = my_string[start_position1:end_position1]
substring2 = my_string[start_position2:end_position2]
substring3 = my_string[start_position3:end_position3]
substring4 = my_string[start_position4:end_position4]
substring5 = my_string[start_position5:end_position5]
substring6 = substring2+substring3+substring4+substring5
# converting hexadecimal string to decimal
res = int(substring6, 16)
res1 =res/100
status = render.percent(res1)
data = [tonerblack, status]
parsed.append(data)
return parsed
register.snmp_section(
name="printer_supply_brother",
parse_function=parse_printer_supply_brother,
fetch=[
SNMPTree(
base=".1.3.6.1",
oids=[
'2.1.43.12.1.1.4.1.1', # Black Toner Cartridge
# '2.1.43.12.1.1.4.1.2', # cyan Toner Cartridge
# '2.1.43.12.1.1.4.1.3', # magenta Toner Cartridge
# '2.1.43.12.1.1.4.1.4', # yellow Toner Cartridge
'4.1.2435.2.3.9.4.2.1.5.5.8.0',
]
)
],
detect=startswith(".1.3.6.1.2.1.25.3.2.1.2.1", ".1.3.6.1.2.1.25.3.1.5"),
)
def discover_printer_supply_brother(section):
for tonerblack, status in section:
yield Service(item=tonerblack)
register.check_plugin(
name="printer_supply_brother",
service_name="Supply Brother",
discovery_function=discover_printer_supply_brother,
check_function=check_printer_supply_brother,
check_default_parameters={},
)
this is my first plugin and my problem is code chek_function
Thank you very mutch
…