Ad Widget

Collapse

LLD Macro and regsub

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • filovitch
    Junior Member
    • Jul 2020
    • 1

    #1

    LLD Macro and regsub

    Hello,
    I am working on Zabbix 4.0.22
    I have a discovery rules to detect supplies of a printer. The SNMP OID discovery rules is:
    Code:
    discovery[{#SNMPVALUE},.1.3.6.1.2.1.43.11.1.1.6]
    The result of a snmpwalk on this OID is:
    Code:
    [jv@bgos-vzabbix ~]$ snmpwalk -v 2c -c public 10.0.1.220 .1.3.6.1.2.1.43.11.1.1.6
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.1 = STRING: "Black Toner, PN 006R01453;SN4a03cd80e0000499"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.2 = STRING: "Cyan Toner, PN 006R01456;SN18371d80e00004cd"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.3 = STRING: "Magenta Toner, PN 006R01455;SN4a252580e000042a"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.4 = STRING: "Yellow Toner, PN 006R01454;SN5309c180e000041b"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.5 = STRING: "Drum Cartridge (R1), PN 013R00657;SN550dc680e0000466"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.6 = STRING: "Drum Cartridge (R2), PN 013R00660;SN562ea880e000042b"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.7 = STRING: "Drum Cartridge (R3), PN 013R00659;SN4a0fd180e000042c"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.8 = STRING: "Drum Cartridge (R4), PN 013R00658;SN4436a680e0000484"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.9 = STRING: "Fuser, PN 008R13088;SNunknown"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.10 = STRING: "Waste Toner Container, PN 008R13089;SNunknown"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.11 = STRING: "Transfer Belt, PN 001R00610;SNunknown"
    SNMPv2-SMI::mib-2.43.11.1.1.6.1.12 = STRING: "Second Bias Transfer Roll, PN 008R13086;SNunknown"
    The text contain the serial number of the supply; This part change every time we change the supply thus it create new items and I do not want that.
    I was thinking to use regsub to only get the text before the ";" character but I do not how to make it work
    I have tried this SNMP OID but it is not working:
    discovery[{{#SNMPVALUE}.regsub("(.*?);",\1)},.1.3.6.1.2.1.43 .11.1.1.6]
    Any idea?
Working...