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

Add fieldserver MIB #1392

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

lukeyeager
Copy link

No description provided.

@lukeyeager
Copy link
Author

For posterity, if anyone would like to test this, here is a minimal gateway configuration to expose data over SNMP:

Connections
Adapter,Protocol,Public_Community,SNMP_Protocol_Version
N1,SNMP-STD,public,v2c

// declare data
Data_Arrays
Data_Array_Name,Data_Format,Data_Array_Length
SNMP_BI,BI,1
SNMP_BO,BO,1
SNMP_BV,BV,1
SNMP_AI,AI,1
SNMP_AO,AO,2
SNMP_AV,AV,1

// set descriptions
// NOTE: this doesn't work because they are sent as 'OCTET STRING'
Preloads
Data_Array_Name,Data_Array_Offset,Preload_Data_Format,Preload_Obj_Name
SNMP_BI,0,String,BI desc
SNMP_BO,0,String,BI desc
SNMP_BV,0,String,BV desc
SNMP_AI,0,String,AI desc
SNMP_AO,0,String,AI[0] desc
SNMP_AO,1,String,AI[1] desc
SNMP_AV,0,String,AV desc

// set values
Preloads
Preloads
Data_Array_Name,Data_Array_Offset,Preload_Value
SNMP_BI,0,1
SNMP_BO,0,0
SNMP_BV,0,1
SNMP_AI,0,1
SNMP_AO,0,2
SNMP_AO,1,3
SNMP_AV,0,4

As is commented in generator.yml, snmptable is willing to parse the descriptions, but snmp-exporter isn't. So I simply ignore the descriptions.

$ snmptable -Ci -r0 -v2c "${mygateway}" analogOutputsTable
SNMP table: FIELDSERVER-STD-MIB-v1-00aF::analogOutputsTable

 index aoValue aoDescription
     0       2  "AI[0] desc"
     1       3  "AI[1] desc"

$ curl -fsS 'localhost:8080/snmp?target=mygateway&module=fieldserver' | grep aoValue
# HELP aoValue Value - 1.3.6.1.4.1.6347.2.3.1.1
# TYPE aoValue gauge
aoValue{aoDescription="",aoValue="0"} 2
aoValue{aoDescription="",aoValue="1"} 3

Signed-off-by: Luke Yeager <lyeager@nvidia.com>
overrides:
# NOTE: snmp-exporter cannot parse these OCTET STRINGs
# See https://github.com/prometheus/snmp_exporter/issues/264
aiDescription: { ignore: true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this work?

Suggested change
aiDescription: { ignore: true }
aiDescription:
type: DisplayString

Copy link
Author

@lukeyeager lukeyeager Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd think so, but no. It leads to this:

$ curl -fsS 'localhost:8080/snmp?target=mygateway&module=fieldserver' | grep aoValue
aoDescription{aoDescription="",aoValue="0"} 1
aoDescription{aoDescription="",aoValue="1"} 1
# HELP aoValue Value - 1.3.6.1.4.1.6347.2.3.1.1
# TYPE aoValue gauge
aoValue{aoDescription="",aoValue="0"} 2
aoValue{aoDescription="",aoValue="1"} 3

No errors in the exporter output, even with --log.level=debug

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, what does snmpwalk return?

Also maybe try with --snmp.debug-packets. That will provide the raw packet responses from the device.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ snmpwalk -v2c mygateway analogOutputsTable
FIELDSERVER-STD-MIB-v1-00aF::aoValue.0 = INTEGER: 2
FIELDSERVER-STD-MIB-v1-00aF::aoValue.1 = INTEGER: 3
FIELDSERVER-STD-MIB-v1-00aF::aoDescription.0 = STRING: "AI[0] desc"
FIELDSERVER-STD-MIB-v1-00aF::aoDescription.1 = STRING: "AI[1] desc"

With --snmp.debug-packets: snmp-exporter_log.txt

Copy link
Member

@SuperQ SuperQ Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see the issue. The MIB does not match the data returned.

analogOutputsTable OBJECT-TYPE 
    SYNTAX   SEQUENCE OF AnalogOutputsEntry
    MAX-ACCESS not-accessible
    STATUS   current
    DESCRIPTION
       "Table of Analog Outputs"
    ::= { standard 3 }
        
analogOutputsEntry OBJECT-TYPE
    SYNTAX   AnalogOutputsEntry
    MAX-ACCESS not-accessible   
    STATUS   current
    DESCRIPTION          
       "Analog Output."  
    INDEX {              
        aoValue,    
        aoDescription
        }
    ::= { analogOutputsTable 1 }

AnalogOutputsEntry ::=
    SEQUENCE {
        aoValue 
            INTEGER,
        aoDescription
            OCTET STRING        
             }

This claims a 2-dimension index, but the snmpwalk clearly shows only the single integer index. This also matches what I see in the snmp_exporter debug packets log you provided.

aoDescription is not part of the INDEX returned by the device.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find, thanks for the careful look! I believe I fixed it with a sed command in the makefile. With the current code, it produces the following output (looks great to me now!):

$ curl -fsS 'localhost:8080/snmp?target=mygateway&module=fieldserver' | grep -E '[ab][iov]'
# HELP aiValue Value - 1.3.6.1.4.1.6347.2.2.1.1
# TYPE aiValue gauge
aiValue{aiDescription="AI desc",aiValue="0"} 1
# HELP aoValue Value - 1.3.6.1.4.1.6347.2.3.1.1
# TYPE aoValue gauge
aoValue{aoDescription="AI[0] desc",aoValue="0"} 2
aoValue{aoDescription="AI[1] desc",aoValue="1"} 3
# HELP avValue Value - 1.3.6.1.4.1.6347.2.4.1.1
# TYPE avValue gauge
avValue{avDescription="AV desc",avValue="0"} 4
# HELP biValue Value - 1.3.6.1.4.1.6347.2.5.1.1
# TYPE biValue gauge
biValue{biDescription="BI desc",biValue="0"} 1
# HELP boValue Value - 1.3.6.1.4.1.6347.2.6.1.1
# TYPE boValue gauge
boValue{boDescription="BI desc",boValue="0"} 0
# HELP bvValue Value - 1.3.6.1.4.1.6347.2.7.1.1
# TYPE bvValue gauge
bvValue{bvDescription="BV desc",bvValue="0"} 1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, any chance you can get the vendor to fix this?

Signed-off-by: Luke Yeager <lyeager@nvidia.com>
@lukeyeager lukeyeager force-pushed the fieldserver branch 2 times, most recently from 3886f8d to d18e94a Compare March 18, 2025 18:30
Signed-off-by: Luke Yeager <lyeager@nvidia.com>
- "FIELDSERVER-STD-MIB-v1-00aF::binaryOutputsTable"
- "FIELDSERVER-STD-MIB-v1-00aF::binaryValuesTable"
overrides:
aiDescription: { type: DisplayString, ignore: true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't mix yaml syntax.

Suggested change
aiDescription: { type: DisplayString, ignore: true }
aiDescription:
type: DisplayString
ignore: true

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

Successfully merging this pull request may close these issues.

2 participants