Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding of MIB information #186

Closed
brian-brazil opened this issue Jun 30, 2017 · 21 comments
Closed

Allow overriding of MIB information #186

brian-brazil opened this issue Jun 30, 2017 · 21 comments

Comments

@brian-brazil
Copy link
Contributor

Some MIBs aren't quite right, particularly around types. Figure out what's a sane config syntax to allow for per-module overrides of bits of MIBs.

Augments also need overriding, but we might hardcode those.

@andrewd-sterling
Copy link

Here's a use-case: the Dell MIB (in my case for the M1000e blade chassis) encodes various floating-point numbers as OctetStrings. I can't extract these currently with the regex_extracts functionality because OctetStrings get encoded as 0x333530362E303030 prior to the regex getting the value. If I override (manually edit snmp.yml) the type as DisplayString then the regex will work. Perhaps I'll be required to specify encoding since OctetStrings are opaque bytes... in this case I'd guess ascii or utf8.

Here's what snmpwalk outputs:

DELL-RAC-MIB::drsWattsReading.1 = STRING: "3509.000"

And the corresponding generated yaml:

  - name: drsWattsReading
    oid: 1.3.6.1.4.1.674.10892.2.4.1.1.13
    type: OctetString
    help: 0004.0001.0001.0013 This attribute defines the instantaneous chassis power
      usage (in Watts). - 1.3.6.1.4.1.674.10892.2.4.1.1.13
    indexes:
    - labelname: drsChassisIndex
      type: gauge

@znerol
Copy link

znerol commented Aug 16, 2017

Another example is prtMarkerSuppliesDescription from RFC 3805 (Printer-MIB in the Cisco collection). Those are localized strings and as a result end up as OctetString. Would be fantastic if there was a way to just override the relevant bits.

  - name: prtMarkerSuppliesDescription
    oid: 1.3.6.1.2.1.43.11.1.1.6
    type: OctetString
    help: The description of this supply container/receptacle in the localization
      specified by prtGeneralCurrentLocalization. - 1.3.6.1.2.1.43.11.1.1.6
    indexes:
    - labelname: hrDeviceIndex
      type: gauge
    - labelname: prtMarkerSuppliesIndex
      type: gauge

@brian-brazil
Copy link
Contributor Author

I suspected those existed, these will be covered.

@brian-brazil
Copy link
Contributor Author

Actually we won't support prtMarkerSuppliesDescription or anything else with localized strings where we have to look up another object to find the encoding.

@znerol
Copy link

znerol commented Aug 22, 2017

I think it would already help if it was possible to specify the encoding for metric entries in snmp.yml. If the encoding is known, then an OctetString could be safely decoded/reencoded and exposed as string (instead of the current hex-encoding).

Generator support can be added later/independently if required.

@brian-brazil
Copy link
Contributor Author

Such encodings would have to be a separate issue, this covers simpler type handling. In general we don't handle things that require parsing English, such as this.

@RichiH
Copy link
Member

RichiH commented Feb 15, 2018

Do you see these overrides in between generator and config, between config and scrapes, or after scrapes?

@brian-brazil
Copy link
Contributor Author

This is a generator thing.

@RichiH
Copy link
Member

RichiH commented Mar 27, 2018

Another instance where re-casting DisplayString into float would be useful. Storing this information in a label does not scale as a lot of those values are different after a minute and our retention is ten years.

http://www.circitor.fr/Mibs/Mib/F/FORTINET-FORTIGATE-MIB.mib

fgHwSensorEntry == 1.3.6.1.4.1.12356.101.4.3.2.1

FgHwSensorEntry ::= SEQUENCE {
    fgHwSensorEntIndex          FnIndex,
    fgHwSensorEntName           DisplayString,
    fgHwSensorEntValue          DisplayString,
    fgHwSensorEntAlarmStatus    INTEGER
}

Sample data:

.1.3.6.1.4.1.12356.101.4.3.2.1.1.1 = INTEGER: 1
.1.3.6.1.4.1.12356.101.4.3.2.1.1.2 = INTEGER: 2
.1.3.6.1.4.1.12356.101.4.3.2.1.1.3 = INTEGER: 3
.1.3.6.1.4.1.12356.101.4.3.2.1.1.4 = INTEGER: 4
.1.3.6.1.4.1.12356.101.4.3.2.1.1.5 = INTEGER: 5
.1.3.6.1.4.1.12356.101.4.3.2.1.1.6 = INTEGER: 6
.1.3.6.1.4.1.12356.101.4.3.2.1.1.7 = INTEGER: 7
.1.3.6.1.4.1.12356.101.4.3.2.1.1.8 = INTEGER: 8
.1.3.6.1.4.1.12356.101.4.3.2.1.1.9 = INTEGER: 9
.1.3.6.1.4.1.12356.101.4.3.2.1.1.10 = INTEGER: 10
.1.3.6.1.4.1.12356.101.4.3.2.1.1.11 = INTEGER: 11
.1.3.6.1.4.1.12356.101.4.3.2.1.1.12 = INTEGER: 12
.1.3.6.1.4.1.12356.101.4.3.2.1.1.13 = INTEGER: 13
.1.3.6.1.4.1.12356.101.4.3.2.1.1.14 = INTEGER: 14
.1.3.6.1.4.1.12356.101.4.3.2.1.1.15 = INTEGER: 15
.1.3.6.1.4.1.12356.101.4.3.2.1.1.16 = INTEGER: 16
.1.3.6.1.4.1.12356.101.4.3.2.1.1.17 = INTEGER: 17
.1.3.6.1.4.1.12356.101.4.3.2.1.1.18 = INTEGER: 18
.1.3.6.1.4.1.12356.101.4.3.2.1.1.19 = INTEGER: 19
.1.3.6.1.4.1.12356.101.4.3.2.1.1.20 = INTEGER: 20
.1.3.6.1.4.1.12356.101.4.3.2.1.1.21 = INTEGER: 21
.1.3.6.1.4.1.12356.101.4.3.2.1.1.22 = INTEGER: 22
.1.3.6.1.4.1.12356.101.4.3.2.1.1.23 = INTEGER: 23
.1.3.6.1.4.1.12356.101.4.3.2.1.1.24 = INTEGER: 24
.1.3.6.1.4.1.12356.101.4.3.2.1.1.25 = INTEGER: 25
.1.3.6.1.4.1.12356.101.4.3.2.1.1.26 = INTEGER: 26
.1.3.6.1.4.1.12356.101.4.3.2.1.1.27 = INTEGER: 27
.1.3.6.1.4.1.12356.101.4.3.2.1.1.28 = INTEGER: 28
.1.3.6.1.4.1.12356.101.4.3.2.1.1.29 = INTEGER: 29
.1.3.6.1.4.1.12356.101.4.3.2.1.1.30 = INTEGER: 30
.1.3.6.1.4.1.12356.101.4.3.2.1.2.1 = STRING: "+3.3V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.2 = STRING: "+5V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.3 = STRING: "+12V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.4 = STRING: "CPU VCCP"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.5 = STRING: "CPU VTT"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.6 = STRING: "CPU PVSA"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.7 = STRING: "P1V8"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.8 = STRING: "P1V5"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.9 = STRING: "PCH +1.05V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.10 = STRING: "VCC 2V5"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.11 = STRING: "MAIN 12V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.12 = STRING: "VCC 1V15"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.13 = STRING: "DDR3 VTT"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.14 = STRING: "RPS 12V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.15 = STRING: "NCT +3.3V"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.16 = STRING: "NCT VBAT"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.17 = STRING: "NCT +3.3VSB"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.18 = STRING: "NCT VTT"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.19 = STRING: "DTS CPU"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.20 = STRING: "CPU Core 0"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.21 = STRING: "CPU Core 1"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.22 = STRING: "TD1"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.23 = STRING: "TD2"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.24 = STRING: "FAN_TMP_3"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.25 = STRING: "LM75 U72"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.26 = STRING: "LM75 U65"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.27 = STRING: "LM75 U62"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.28 = STRING: "FAN1"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.29 = STRING: "FAN2"
.1.3.6.1.4.1.12356.101.4.3.2.1.2.30 = STRING: "FAN3"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.1 = STRING: "3.3018"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.2 = STRING: "5.048"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.3 = STRING: "12.136"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.4 = STRING: "1.0295"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.5 = STRING: "1.0589"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.6 = STRING: "0.9413"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.7 = STRING: "1.7841"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.8 = STRING: "1.4999"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.9 = STRING: "1.04"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.10 = STRING: "2.464"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.11 = STRING: "11.904"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.12 = STRING: "1.136"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.13 = STRING: "0.736"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.14 = STRING: "0"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.15 = STRING: "3.264"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.16 = STRING: "3.312"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.17 = STRING: "3.264"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.18 = STRING: "1.04"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.19 = STRING: "70"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.20 = STRING: "67"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.21 = STRING: "71"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.22 = STRING: "56"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.23 = STRING: "45"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.24 = STRING: "52"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.25 = STRING: "47"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.26 = STRING: "48"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.27 = STRING: "50"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.28 = STRING: "9600"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.29 = STRING: "9600"
.1.3.6.1.4.1.12356.101.4.3.2.1.3.30 = STRING: "9700"
.1.3.6.1.4.1.12356.101.4.3.2.1.4.1 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.2 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.3 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.4 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.5 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.6 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.7 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.8 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.9 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.10 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.11 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.12 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.13 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.14 = INTEGER: 1
.1.3.6.1.4.1.12356.101.4.3.2.1.4.15 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.16 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.17 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.18 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.19 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.20 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.21 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.22 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.23 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.24 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.25 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.26 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.27 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.28 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.29 = INTEGER: 0
.1.3.6.1.4.1.12356.101.4.3.2.1.4.30 = INTEGER: 0

We opened an issue upstream, but do not expect much willingness to introduce new OIDs.

@brian-brazil
Copy link
Contributor Author

We already support extracting floats from strings.

@RichiH
Copy link
Member

RichiH commented Mar 27, 2018

My version does not (see #180 ) but in case anyone stumbles over this: It's been implemented in #212 - sorry for the noise & thanks.

@SuperQ
Copy link
Member

SuperQ commented May 17, 2018

We now have 3 types of overrides, Ignore, Regexp Extracts, and Type. Are there any more we need

@RichiH
Copy link
Member

RichiH commented May 17, 2018

I am wondering if there's any use in Regexp Ignore & Type, but else I can't think of anything.

Why not cut a release for this?

@SuperQ
Copy link
Member

SuperQ commented May 17, 2018

I'm not sure what you mean by "Regexp Ignore & Type".

We just merged the Ignore and Type overrides recently, we can cut a new release sometime soon.

@RichiH
Copy link
Member

RichiH commented May 17, 2018

"If that regex matches, do that other override"

@brian-brazil
Copy link
Contributor Author

Generator changes do not require a release.

@andrewd-sterling
Copy link

I'm trying the "type" override now. Looks good for my use-case. Here's the OID metric from my previous example as normally encoded:

# HELP drsWattsReading 0004.0001.0001.0013 This attribute defines the instantaneous chassis power usage (in Watts). - 1.3.6.1.4.1.674.10892.2.4.1.1.13
# TYPE drsWattsReading gauge
drsWattsReading{drsChassisIndex="1",drsWattsReading="0x333033382E303030"} 1

When I add an override for type: DisplayString I get

drsWattsReading{drsChassisIndex="1",drsWattsReading="3039.000"} 1

Then if I regex_extracts the value like so:

    overrides:
      drsWattsReading:
        type: DisplayString
        regex_extracts:
          Value:
            - regex: '(.*)'
              value: '$1'

I get this metric:

drsWattsReadingValue{drsChassisIndex="1"} 3056

Which is pretty much what I want.

I tried going directly to "type: Float" but I always get a value of 0. Maybe that isn't intended for my float-as-OctetString case?

drsWattsReading{drsChassisIndex="1"} 0

@brian-brazil
Copy link
Contributor Author

That's more a usage question, which is best handled on the mailing lists.

@acmodeu
Copy link

acmodeu commented May 30, 2018

Trying to override mtxrFirmwareVersion from Mikrotik.mib, using docker SNMP Exporter Config Generator. After some digging I found the same problem with resolution. But my generator fails with the following error

FATA[0000] Error parsing yml config: yaml: line 30: did not find expected key source="main.go:44"

Here is my generator.yml file:

  mikrotik_private:  # The module name. You can have as many modules as you want.
    walk:       # List of OIDs to walk. Can also be SNMP object names or specific instances.
      - mtxrFirmwareVersion
      - hrProcessorLoad # CPU Load
      - hrSystemUptime # System Uptime
      - ifInOctets # Incoming Traffic on the interface
      - ifOutOctets # Outgoing Traffic on the interface 

      - mtxrSerialNumber

      overrides:
           mtxrFirmwareVersion:
                 regex_extracts:
                 '': 
                 - regex: '(.*)'
                 value: '$1'



    version: 3  # SNMP version to use. Defaults to 2.
                # 1 will use GETNEXT, 2 and 3 use GETBULK.
    max_repetitions: 25  # How many objects to request with GET/GETBULK, defaults to 25.
                         # May need to be reduced for buggy devices.
    retries: 3   # How many times to retry a failed request, defaults to 3.
    timeout: 10s # Timeout for each walk, defaults to 10s.

    auth:
      # Community string is used with SNMP v1 and v2. Defaults to "public".
      community: snmp

      # v3 has different and more complex settings.
      # Which are required depends on the security_level.
      # The equivalent options on NetSNMP commands like snmpbulkwalk
      # and snmpget are also listed. See snmpcmd(1).
      username: snmp # Required, no default. -u option to NetSNMP.
      security_level: authNoPriv  # Defaults to noAuthNoPriv. -l option to NetSNMP.
                                    # Can be noAuthNoPriv, authNoPriv or authPriv.
      password: snmp  # Has no default. Also known as authKey, -A option to NetSNMP.
                      # Required if security_level is authNoPriv or authPriv.
      auth_protocol: MD5  # MD5 or SHA, defaults to SHA. -a option to NetSNMP.
                          # Used if security_level is authNoPriv or authPriv.
#      priv_protocol: DES  # DES or AES, defaults to DES. -x option to NetSNMP.
                          # Used if security_level is authPriv.
#      priv_password: # Has no default. Also known as privKey, -X option to NetSNMP.
                               # Required if security_level is authPriv.
#      context_name: context # Has no default. -n option to NetSNMP.
                            # Required if context is configured on the device.

@SuperQ
Copy link
Member

SuperQ commented May 30, 2018

@acmodeu : For usage questions/help, please use our community. There are many more people there that can help. GitHub issues are reserved for bug reports and feature requests.

It looks like your indentation is off.

@brian-brazil
Copy link
Contributor Author

I think we're largely done here. If there's additional stuff needed, we can file issues as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants