netdata / netdata

Architected for speed. Automated for easy. Monitoring and troubleshooting, transformed!
https://www.netdata.cloud
GNU General Public License v3.0
71.57k stars 5.91k forks source link

[Bug]: node.d snmp to go.d snmp doesn't work properly #12860

Closed Famku closed 2 years ago

Famku commented 2 years ago

Bug description

Hi,

I try to change my snmp config for my Mikrotik switch to go.d.

My old config for node.d worked perfectly for years:

{
    "enable_autodetect": false,
    "update_every": 10,
    "servers": [
        {
            "hostname": "192.168.1.21",
            "community": "public",
            "update_every": 2,
            "options": { "timeout": 20000, "version": 1 },
            "charts": {
                "snmp_switch.bandwidth_port": {
                    "title": "bandwidth for port ",
                    "titleoid": ".1.3.6.1.2.1.31.1.1.1.18.",
                    "units": "kilobits/s",
                    "type": "area",
                    "priority": 1,
                    "family": "ports",
                    "multiply_range": [ 1, 24 ],
                    "dimensions": {
                        "in": {
                            "oid": "1.3.6.1.2.1.2.2.1.10.",
                            "algorithm": "incremental",
                            "multiplier": 8,
                            "divisor": 1024,
                            "offset": 0
                        },
                        "out": {
                            "oid": "1.3.6.1.2.1.2.2.1.16.",
                            "algorithm": "incremental",
                            "multiplier": -8,
                            "divisor": 1024,
                            "offset": 0
                        }
                    }
                }
            }
        }
    ]
}

For go.d my config looks like this:

jobs:
  - name: switch
    update_every: 5
    hostname: "192.168.1.21"
    community: public
    options:
      version: 2
      timeout: 20
    charts:
      - id: "bandwidth_port"
        title: "Switch Bandwidth for port"
        titleoid": "1.3.6.1.2.1.31.1.1.1.18"
        units: "kilobits/s"
        type: "area"
        family: "ports"
        multiply_range: [1, 24]
        dimensions:
          - name: "in"
            oid: "1.3.6.1.2.1.2.2.1.10"
            algorithm: "incremental"
            multiplier: 8
            divisor: 1024
            offset: 0
          - name: "out"
            oid: "1.3.6.1.2.1.2.2.1.16"
            multiplier: -8
            divisor: 1024
            offset: 0

I checked this with ./go.d.plugin -d -m snmp and I can see all ports in the dashboard.

But units shows as "ports" with values that not make sense.

Can someone give me a hint what I doing wrong?

Expected behavior

go.d snmp work the same way as node.d snmp

Steps to reproduce

sudo ./edit-config go.d/snmp.conf

enter config template from https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/snmp)

change values

Installation method

kickstart.sh

System info

Linux docker2 5.4.0-109-generic #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
/etc/lsb-release:DISTRIB_ID=Ubuntu
/etc/lsb-release:DISTRIB_RELEASE=20.04
/etc/lsb-release:DISTRIB_CODENAME=focal
/etc/lsb-release:DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"
/etc/os-release:NAME="Ubuntu"
/etc/os-release:VERSION="20.04.4 LTS (Focal Fossa)"
/etc/os-release:ID=ubuntu
/etc/os-release:ID_LIKE=debian
/etc/os-release:PRETTY_NAME="Ubuntu 20.04.4 LTS"
/etc/os-release:VERSION_ID="20.04"
/etc/os-release:VERSION_CODENAME=focal
/etc/os-release:UBUNTU_CODENAME=focal

Netdata build info

Version: netdata v1.34.0-124-nightly

Additional info

No response

ilyam8 commented 2 years ago

Hi, @Famku.

But units shows as "ports" with values that not make sense.

Famku commented 2 years ago

This is my mirror wan port:

image
netdata@docker2:/usr/libexec/netdata/plugins.d$ ./go.d.plugin -d -m snmp
[ DEBUG ] main[main] main.go:111 plugin: name=go.d, version=v0.32.2
[ DEBUG ] main[main] main.go:113 current user: name=netdata, uid=114
[ INFO  ] main[main] agent.go:106 instance is started
[ INFO  ] main[main] setup.go:40 loading config file
[ INFO  ] main[main] setup.go:48 looking for 'go.d.conf' in [/etc/netdata /usr/lib/netdata/conf.d]
[ INFO  ] main[main] setup.go:55 found '/etc/netdata/go.d.conf
[ INFO  ] main[main] setup.go:62 config successfully loaded
[ INFO  ] main[main] agent.go:110 using config: enabled 'true', default_run 'true', max_procs '0'
[ INFO  ] main[main] setup.go:67 loading modules
[ INFO  ] main[main] setup.go:86 enabled/registered modules: 1/64
[ INFO  ] main[main] setup.go:91 building discovery config
[ INFO  ] main[main] setup.go:121 looking for 'snmp.conf' in [/etc/netdata/go.d /usr/lib/netdata/conf.d/go.d]
[ INFO  ] main[main] setup.go:137 found '/etc/netdata/go.d/snmp.conf
[ INFO  ] main[main] setup.go:142 dummy/read/watch paths: 0/1/0
[ INFO  ] discovery[manager] manager.go:90 registered discoverers: [file discovery: [file reader]]
[ INFO  ] discovery[manager] manager.go:95 instance is started
[ INFO  ] run[manager] run.go:30 instance is started
[ INFO  ] build[manager] build.go:106 instance is started
[ INFO  ] discovery[file manager] discovery.go:71 instance is started
[ INFO  ] discovery[file reader] read.go:39 instance is started
[ INFO  ] discovery[file reader] read.go:40 instance is stopped
[ DEBUG ] build[manager] build.go:153 received config group ('/etc/netdata/go.d/snmp.conf'): 1 jobs (added: 1, removed: 0)
[ DEBUG ] build[manager] build.go:302 building snmp[switch] job, config: map[__provider__:file reader __source__:/etc/netdata/go.d/snmp.conf autodetection_retry:0 charts:[map[dimensions:[map[algorithm:incremental divisor:1024 multiplier:8 name:in offset:0 oid:1.3.6.1.2.1.2.2.1.10] map[divisor:1024 multiplier:-8 name:out offset:0 oid:1.3.6.1.2.1.2.2.1.16]] family:ports id:bandwidth_port multiply_range:[1 24] title:Switch Bandwidth for port titleoid":1.3.6.1.2.1.31.1.1.1.18 type:area units:kilobits/s]] community:public hostname:192.168.1.21 module:snmp name:switch options:map[timeout:20 version:2] priority:70000 update_every:5]
[ INFO  ] snmp[switch] snmp.go:115 hostname=192.168.1.21,port=161,snmp_version=2c,community=public
[ DEBUG ] run[manager] run.go:41 tick 0
[ INFO  ] snmp[switch] job.go:171 check success
[ INFO  ] snmp[switch] job.go:191 started, data collection interval 5s
[ DEBUG ] run[manager] run.go:41 tick 1
[ DEBUG ] run[manager] run.go:41 tick 2
[ DEBUG ] run[manager] run.go:41 tick 3
[ DEBUG ] run[manager] run.go:41 tick 4
[ DEBUG ] run[manager] run.go:41 tick 5
CHART 'netdata.execution_time_of_snmp_switch' '' 'Execution time' 'ms' 'go.d' 'netdata.go_plugin_execution_time' '' '145000' '5' '' 'go.d' 'snmp'
DIMENSION 'time' '' '' '1' '1' ''

CHART 'snmp_switch.bandwidth_port_1' '' 'Switch Bandwidth for port 1' 'ports' 'ports' 'snmp.bandwidth_port' 'area' '70000' '5' '' 'go.d' 'snmp'
DIMENSION '1.3.6.1.2.1.2.2.1.10.1' 'in' 'incremental' '8' '1024' ''
DIMENSION '1.3.6.1.2.1.2.2.1.16.1' 'out' '' '-8' '1024' ''

BEGIN 'snmp_switch.bandwidth_port_1'
SET '1.3.6.1.2.1.2.2.1.10.1' = 99192786
SET '1.3.6.1.2.1.2.2.1.16.1' = 2051325991
END

CHART 'snmp_switch.bandwidth_port_2' '' 'Switch Bandwidth for port 2' 'ports' 'ports' 'snmp.bandwidth_port' 'area' '70001' '5' '' 'go.d' 'snmp'
DIMENSION '1.3.6.1.2.1.2.2.1.10.2' 'in' 'incremental' '8' '1024' ''
DIMENSION '1.3.6.1.2.1.2.2.1.16.2' 'out' '' '-8' '1024' ''

BEGIN 'snmp_switch.bandwidth_port_2'
SET '1.3.6.1.2.1.2.2.1.10.2' = 0
SET '1.3.6.1.2.1.2.2.1.16.2' = 0
END

Thanks for looking into it

Famku commented 2 years ago

This is the dashboard from my old config

image
ilyam8 commented 2 years ago

@Famku you need to add algorithm: "incremental" to - name: "out"

ilyam8 commented 2 years ago

The units/ports problem is a bug, indeed.

https://github.com/netdata/go.d.plugin/blob/8d8bb6c053d351175fc5ca959ba21c06596afb0b/modules/snmp/charts.go#L70-L71

ilyam8 commented 2 years ago

@Famku

Famku commented 2 years ago

omg, I didn't see this, It works now.

Thank you very much!

Is it possible to change the name "ports" manually?

Famku commented 2 years ago

I will wait for the next release, thanks again

ghoekstra commented 2 years ago

@Famku , did you happen to get titleoid working with the go.d version of snmp? I see it in your config-file, but it seems to me that's no longer working since I moved from node.d to go.d. Thank you!

ilyam8 commented 2 years ago

Hi, @ghoekstra. The 'titleoid' feature didn't make it into the go version. Having instance-specific data in a chart title is a problem when aggregating on the Cloud (see relevant issue https://github.com/netdata/netdata/issues/12641). We need to think about what we can do.

netdata-community-bot commented 2 years ago

This issue has been mentioned on the Netdata Community Forums. There might be relevant details there:

https://community.netdata.cloud/t/go-d-snmp-plugin-titleoid-support/3367/2