Ad Widget

Collapse

Problem on Preprocessing steps on discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freeco
    Junior Member
    • May 2017
    • 7

    #1

    Problem on Preprocessing steps on discovery

    Hello,

    I want to use Template SNMP Printer with Preprocessing steps on discovery and regex. I'm on Zabbix 4.4.1 server.

    On this template, we have a discovery rule for supplies. The discovery scan on SNMP device and create items.

    By default, the discovery creates items with this values :

    Code:
    root@zabbix:~# snmpwalk -v 2c -c public 10.1.7.14 .1.3.6.1.2.1.43.11.1.1.6
    Printer-MIB::prtMarkerSuppliesDescription.1.1 = STRING: "Black Toner, PN 006R01509;SN421A9880E00004F4"
    Printer-MIB::prtMarkerSuppliesDescription.1.2 = STRING: "Cyan Toner, PN 006R01512;SN4322C880E00004F4"
    Printer-MIB::prtMarkerSuppliesDescription.1.3 = STRING: "Magenta Toner, PN 006R01511;SN53079F80E00004F1"
    Printer-MIB::prtMarkerSuppliesDescription.1.4 = STRING: "Yellow Toner, PN 006R01510;SN420FEB80E00004F2"
    Printer-MIB::prtMarkerSuppliesDescription.1.5 = STRING: "Drum Cartridge (R1), PN 013R00662;SN510EA080E00004F2"
    Printer-MIB::prtMarkerSuppliesDescription.1.6 = STRING: "Drum Cartridge (R2), PN 013R00662;SN511BB980E00004F2"
    Printer-MIB::prtMarkerSuppliesDescription.1.7 = STRING: "Drum Cartridge (R3), PN 013R00662;SN51242980E00004F2"
    Printer-MIB::prtMarkerSuppliesDescription.1.8 = STRING: "Drum Cartridge (R4), PN 013R00662;SN48066A80E0000413"
    Printer-MIB::prtMarkerSuppliesDescription.1.9 = STRING: "Fuser, PN unknown;SNunknown"
    Printer-MIB::prtMarkerSuppliesDescription.1.10 = STRING: "Waste Toner Container, PN 008R13061;SNunknown"
    Printer-MIB::prtMarkerSuppliesDescription.1.11 = STRING: "Transfer Belt Cleaner, PN 001R00613;SNunknown"
    Printer-MIB::prtMarkerSuppliesDescription.1.12 = STRING: "Second Bias Transfer Roll, PN 008R13064;SNunknown"
    Printer-MIB::prtMarkerSuppliesDescription.1.13 = STRING: "Fan Filter, PN 008R13248;SNunknown"
    Or I want to keep only the supplie name like Black Toner and not Black Toner, PN 006R01509;SN421A9880E00004F4

    I tried somes regex on the discovery rules but without results.
    ^.*?(?=,)
    OR
    ([^,]+)
    I have this error :
    Invalid discovery rule value: cannot parse as a valid JSON object: invalid character following JSON object at: ',{"{#SNMPINDEX}":"1.2","{#SNMPVALUE}":"Cyan Toner, PN 006R01512;SN51334480E00004F1"},{"{#SNMPINDEX}":"1. 3","{#SNMPVALUE}":"Magenta Toner, PN 006R01511;SN531E1880E00004F1"},




    I have set debug level in server without explanations on this error.

    Thanks for your answers,
    Last edited by freeco; 13-11-2019, 17:56.
  • freeco
    Junior Member
    • May 2017
    • 7

    #2
    Hello,
    Does anybody have ideas on my problem ?
    Regards

    Comment

    • valentins.grins
      Member
      • Nov 2019
      • 38

      #3
      Hello,

      You are trying to apply pre-processing for discovery rule not the item. While doing discovery you get a JSON string, not the value for certain OID. Try your regex on item prototype instead of discovery rule.

      Comment

      • freeco
        Junior Member
        • May 2017
        • 7

        #4
        Hello,
        I tried your recommandation but they are no succes. In fact, the preprocessing is applied on the value but no on the item name.

        Does it possible to applied filter (like preprocessing) on the item name and not value ?

        Comment

        • freeco
          Junior Member
          • May 2017
          • 7

          #5
          Hello,
          Does anybody have ideas on my problem ?
          Regards

          Comment

          • valentins.grins
            Member
            • Nov 2019
            • 38

            #6
            Hi,

            What do you mean with "Does it possible to applied filter (like preprocessing) on the item name and not value ?" ?

            As i mentioned earlier, you have applied pre-processing rule to your discovery rule instead of item. You shall not apply pre-processing in this case to the Discovery rule but to the Item prototype under this rule.

            What issue are you facing currently?

            Comment

            • freeco
              Junior Member
              • May 2017
              • 7

              #7
              On discovering, the item name are like this :
              • Black Toner, PN 006R01509;SN421A9880E00004F4
              • Cyan Toner, PN 006R01512;SN4322C880E00004F4

              But on next replacement of printer's toner, the discover will create another item because the serial number and product number are on item name.

              At long term, i will get multiple item name like :
              • Black Toner, PN 006R01509;SN421A9880E00004F4
              • lack Toner, PN 006R01509;SN425A9880E1204F4
              • Black Toner, PN 006R01509;SN421A9880E434304F4
              • Black Toner, PN 006R01509;SN421A9880E23004F4
              • Black Toner, PN 006R01509;SN421A9430E088004F4

              That's why, i want to filter the discoring process in order to get only the supplie name and not serial and product number.

              Comment

              • valentins.grins
                Member
                • Nov 2019
                • 38

                #8
                I got your idea. Unfortunately i don't see any other solution except the JavaScript pre-processing but it may quite complex to make a script for your needs. You require to parse the entire LLD output, adjust only particular fields and remain other as is within the json string.

                Comment

                • dribeirosilva@gmail.com
                  Junior Member
                  • Oct 2021
                  • 2

                  #9
                  Hello, i've exactly the similar situation, can any one help me to know if we have a solution for that?

                  Build Discovery
                  Execute a Preprocessing (using regex for example)
                  And with that Data build a Macro that we can use in other Items build

                  Example Template:
                  1. Discovery using SNMP Agent
                  2. Return table with WWN: 20 00 01 02 03 04 05 06 / 20 01 01 02 03 04 05 06 / 20 02 01 02 03 04 05 06 / 20 03 01 02 03 04 05 06, .... etc
                  3. Execute preprocessing (regex): For example WWN translate for something else "Port 0", "Port 1", ... etc
                  4. And with that Data Result build a Macro that can be possible create Items, Graphs,...etc

                  I'm Ok with steps 1, 2 and 3 but i'm with Discover Error "Invalid discovery rule value: cannot parse as a valid JSON object: invalid object format, expected opening character '{' or '[' at: 'Port 0'"
                  Any ideas or i'm doing something wrong?

                  Thanks

                  Comment

                  Working...