lwlcom / cisco_exporter Goto Github PK
View Code? Open in Web Editor NEWExporter for metrics from devices running Cisco (NX-OS/IOS XE/IOS) to use with https://prometheus.io/
License: MIT License
Exporter for metrics from devices running Cisco (NX-OS/IOS XE/IOS) to use with https://prometheus.io/
License: MIT License
I just using authentication via password same as junos_exporter, may i use that ?
IOS XE may return the following output for a device with missing power input.
rudo4#sh environment summary
Number of Critical alarms: 0
Number of Major alarms: 0
Number of Minor alarms: 0
Slot Sensor Current State Reading
---- ------ ------------- -------
P0 PEM Iout Normal 0 A
P0 PEM Vout Normal 0 V DC
P0 PEM Vin Normal 0 V AC
P0 Temp: PEM In Normal 37 Celsius
P0 Temp: PEM Out Normal 1 Celsius
P0 Temp: PEM Int Normal 34 Celsius
P1 PEM Iout Normal 9 A
P1 PEM Vout Normal 12 V DC
P1 PEM Vin Normal 234 V AC
P1 Temp: PEM In Normal 33 Celsius
P1 Temp: PEM Out Normal 36 Celsius
P1 Temp: PEM Int Normal 39 Celsius
This results in the following metrics:
cisco_environment_power_up{instance="localhost:9362",item="P0 Iout",job="cisco",status="Normal",target="rudo4"} 1
cisco_environment_power_up{instance="localhost:9362",item="P0 Vin",job="cisco",status="Normal",target="rudo4"} 1
cisco_environment_power_up{instance="localhost:9362",item="P0 Vout",job="cisco",status="Normal",target="rudo4"} 1
cisco_environment_power_up{instance="localhost:9362",item="P1 Iout",job="cisco",status="Normal",target="rudo4"} 1
cisco_environment_power_up{instance="localhost:9362",item="P1 Vin",job="cisco",status="Normal",target="rudo4"} 1
cisco_environment_power_up{instance="localhost:9362",item="P1 Vout",job="cisco",status="Normal",target="rudo4"} 1
Hence it reports, that everything is fine, while the environment is burning.
Quick fix: Insist on an non-zero number while parsing.
powerRegexp[rpc.IOSXE], _ = regexp.Compile(`\s*(\w\w)\s*PEM (\w+)\s+(\w+)\s+[1-9]\d*\s[\s\w]*`)
Optimal solution: Return the number as the metric gauge value (instead of 1 or 0)
hi there.
when i want to install , i've a problem.
sajad:~$ go get -u github.com/lwlcom/cisco_exporter
Cloning into '/root/go/src/gopkg.in/yaml.v2'...
fatal: unable to access 'https://gopkg.in/yaml.v2/': server certificate verification failed. CAfile: none CRLfile: none
package gopkg.in/yaml.v2: exit status 128
It’d be great if timeouts for SSH connections could be configurable isntead of being hardcoded. This shouldn’t be too hard: basically we just have to push the flag down all the way to cachedConfig
. We can keep the default of 5 seconds through the flag.
I’ll submit a PR for this; if this is of any interest, we can think about merging it—and whether anything is missing.
Cheers
Do you have a dashboard to use with this? Just wondering.
Hello,
When using "./cisco_exporter --config.file=config.yml" the following error appears:
flag provided but not defined: -config.file
Usage: cisco_exporter [ ... ]
Parameters:
-bgp.enabled
[...]
Regards,
Just noticed error in log (upd, added with debug: true) :
Oct 25 10:13:16 grafana cisco-exporter[58467]: 2021/10/25 10:13:16 Running command on 10.0.25.35:22: show version
Oct 25 10:13:18 grafana cisco-exporter[58467]: 2021/10/25 10:13:18 Host 10.0.25.35:22 identified as: NXOS
Oct 25 10:13:18 grafana cisco-exporter[58467]: 2021/10/25 10:13:18 Running command on 10.0.25.35:22: show environment
Oct 25 10:13:18 grafana cisco-exporter[58467]: 2021/10/25 10:13:18 Running command on 10.0.25.35:22: show interface
Oct 25 10:13:18 grafana cisco-exporter[58467]: 2021/10/25 10:13:18 Running command on 10.0.25.35:22: show interfaces stats | exclude disabled
Oct 25 09:09:03 grafana cisco-exporter[57520]: time="2021-10-25T09:09:03+03:00" level=error msg="error gathering metrics: 22 error(s) occurred:\n* collected metric "cisco_interface_receive_bytes" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_errors" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_drops" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_bytes" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_errors" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_drops" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_broadcast" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_multicast" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_admin_up" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:1 > } was collected before with the same name and label values\n* collected metric "cisco_interface_up" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_error_status" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:1 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_bytes" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_errors" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_drops" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_bytes" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_errors" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_transmit_drops" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_broadcast" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_receive_multicast" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_admin_up" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:1 > } was collected before with the same name and label values\n* collected metric "cisco_interface_up" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:0 > } was collected before with the same name and label values\n* collected metric "cisco_interface_error_status" { label:<name:"description" value:"" > label:<name:"mac" value:"002a.6a80.36e1" > label:<name:"name" value:"mgmt0" > label:<name:"speed" value:"" > label:<name:"target" value:"10.0.25.35" > gauge:<value:1 > } was collected before with the same name and label values\n" source="log.go:181"
Please let me know what kind of other info needed to troubleshoot.
And thanks for great exporter!
In the same spirit of #3, we should think about making the batch size for reads in readln
configurable. Currently this is set to 10000
, which is as good a default as any, but we experience this being a bottleneck when the responses get very big (in fact, we get a speedup of x2-x3 just by increasing that size with responses of a few 10k lines). It’d be great if we could fix this as in #4.
Since this is a bit deeper in the stack still, I’d like to know whether this is of general interest or whether this is a special case that only we experience. If it’s of interest, I can prepare a PR for this as well.
Cheers
hello guys how are you, i'm trying to install cisco_exporter and i'm facing a problem with the error below, and i don't know how to solve it since i still have little experience with linux,
./cisco_exporter -ssh.targets="10.10.3.254" -ssh.keyfile=cisco_exporter
INFO[0000] Loading config flags source="main.go:68"
FATA[0000] could not initialize exporter. could not initialize config for device ...: could not load ssh private key file: could not parse private key: ssh: no key found source="main.go:60"
I have three switches setup.
Somehow target/instance is mixed up/doubled between them?
cisco_up{hostname="<name1>", instance="<ip of name1>", job="cisco", target="<ip of name3>"}
cisco_up{hostname="<name1>", instance="<ip of name1>", job="cisco", target="<ip of name1>"}
cisco_up{hostname="<name1>", instance="<ip of name1>", job="cisco", target="<ip of name2>"}
cisco_up{hostname="<name2>", instance="<ip of name2>", job="cisco", target="<ip of name3>"}
cisco_up{hostname="<name2>", instance="<ip of name2>", job="cisco", target="<ip of name1>"}
cisco_up{hostname="<name2>", instance="<ip of name2>", job="cisco", target="<ip of name2>"}
cisco_up{hostname="<name3>", instance="<ip of name3>", job="cisco", target="<ip of name3>"}
cisco_up{hostname="<name3>", instance="<ip of name3>", job="cisco", target="<ip of name1>"}
cisco_up{hostname="<name3>", instance="<ip of name3>", job="cisco", target="<ip of name2>"}
Prometheus config
- file_sd_configs:
- files:
- targets/cisco.json
job_name: cisco
metrics_path: /metrics
params:
module:
- cisco
relabel_configs:
- source_labels:
- __address__
target_label: __param_target
- source_labels:
- __param_target
target_label: instance
- replacement: 127.0.0.1:9362
target_label: __address__
targets/cisco.json:
[
{
"targets": [ "<ip of name3>" ],
"labels": {
"hostname": "<name3>"
}
},
{
"targets": [ "<ip of name2>" ],
"labels": {
"hostname": "<name2>"
}
},
{
"targets": [ "<ip of name1>" ],
"labels": {
"hostname": "<name1>"
}
}
]
Hello!
Is BGP metric disabled for NX-OS, because you couldn't test it or is it for some other reason? I forked your project and started debugging it and haven't ran into problems. Just have to enable check for NX-OS.
If it's for some other reason then I could try to fix it.
Anyways thanks alot for this project and I'll continue to work on it to support NX-OS, however as I'm starting to learn GO, so it will take some time.
Been trying to get this exporter to work, but no matter what I try, I always get this result (logs from the exporter). I have disabled all features other than facts for now:
2023/06/24 14:11:46 Running command on <redacted>:22: show version
Timeout reached
time="2023-06-24T14:13:26Z" level=error msg="<redacted>: Timeout reached"
The switch in question is a WS-C3560CG-8PC-S
running 15.2(2)E10
., and I know that is old but I had hoped would still be supported.
Logging on the switch shows successful login, and then some time after a logout:
Jun 24 13:48:45.932 UTC: %SEC_LOGIN-5-LOGIN_SUCCESS: Login Success [user: prometheus] [Source: <redacted>] [localport: 22] at 13:48:45 UTC Sat Jun 24 2023
Jun 24 13:49:45.983 UTC: %SYS-6-LOGOUT: User prometheus has exited tty session 2(<redacted>)
I'm also able to login manually using the ssh credential and user name (prometheus), and then run the show version
and the other commands in the facts feature just fine, so I don't think it is a privilege level problem?
I'm at a loss, and would very much appreciate some clues or additional debugging steps I could take.
Thanks
Please see error below:
ubuntu@ubuntu:~$ go version
go version go1.17.3 linux/amd64
ubuntu@ubuntu:~$ go get -u github.com/lwlcom/cisco_exporter
go: downloading github.com/lwlcom/cisco_exporter v0.0.0-20211025082351-172adc2c872e
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/prometheus/client_golang v1.10.0
go: downloading github.com/prometheus/client_golang v1.11.0
go: downloading github.com/prometheus/common v0.20.0
go: downloading github.com/prometheus/common v0.32.1
go: downloading gopkg.in/yaml.v2 v2.3.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
go: downloading golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.1.1
go: downloading github.com/cespare/xxhash v1.1.0
go: downloading github.com/cespare/xxhash/v2 v2.1.2
go: downloading github.com/golang/protobuf v1.4.3
go: downloading github.com/golang/protobuf v1.5.2
go: downloading github.com/prometheus/client_model v0.2.0
go: downloading github.com/prometheus/procfs v0.6.0
go: downloading github.com/prometheus/procfs v0.7.3
go: downloading golang.org/x/sys v0.0.0-20210309074719-68d13333faf2
go: downloading golang.org/x/sys v0.0.0-20211110154304-99a53858aa08
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/sirupsen/logrus v1.8.1
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: downloading google.golang.org/protobuf v1.23.0
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/matttproud/golang_protobuf_extensions v1.0.1
go: downloading github.com/konsorten/go-windows-terminal-sequences v1.0.3
go: downloading github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: downloading github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
go: downloading github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a
github.com/lwlcom/cisco_exporter imports
github.com/prometheus/common/log: cannot find module providing package github.com/prometheus/common/log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.