I’ve been going through and building my Grafana dashboards for all Windows checks, that’s going OK and I think I’ve got my head around how it works.
I’ve now moved to building Grafana dashboards and setting them up in Icinga for a number of network devices. First up some Fortinet devices, but I’ve quickly hit an issue with SNMP checks
It would appear my SNMP checkvar-service variable sent from Icinga does not contain the name of the mib as a result the Grafana chart isn’t pulled properly. I’ve turned debug on and copied the URL into my browser, replaced the var-service for the full correct path (mib+OID) and it works. I can’t seem to successfully replace var-service with a concatenation of the SNMP MID and OID. Hope that makes. sense.
The current request coming from Icinga is as follows, which does not work.
My Grafana query is as follows; SELECT distinct("value") FROM "snmp" WHERE ("hostname" =~ /^$hostname$/ AND "metric" =~ /^$service$/) AND $timeFilter GROUP BY time($__interval) fill(null)
I hope I am just being stupid. The Windows checks seemed more obvious.
The only way I can currently force the var-service to be configured appropriately in the icinga Grafana request URL is to change the name of the check to the same as the SNMP MIB and OID.
This works, and the graph from Grafana appears in Icinga. But that’s not a scalable solution, I’d need a check for every interface and check type along with corresponding graph. I can’t believe there is no simple solution to this.
First of all please post the versions you use of Grafana and the module. Which backend are you using? How does the output of the plugin looks like on the commandline?
Did you try to set the custom var for the dashboard configuration to $service.vars.snmp.oid and use this in your dashboard to select the metrics?
SELECT distinct("value") FROM "snmp" WHERE ("hostname" =~ /^$hostname$/ AND "service" =~ /^$service$/) AND "metric" ~= /$snmpoid*/ AND $timeFilter GROUP BY time($__interval) fill(null)
I’m using Grafana module 1.3.5 with Influxdb.
Grafana is v6.6.0
The command line looks like the following; /usr/lib/nagios/plugins/check_snmp -C community_string -H x.x.x.x -P 1 -m FORTINET-FORTIGATE-MIB -o fgSysCpuUsage.0 -t 10
The command line output is as follows;
SNMP OK - 11 | FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0=11
I’m a little confused as I’ve got the following variables in Grafana.
hostname SHOW TAG VALUES WITH KEY = "hostname" returns hostnames as expected
Service SHOW TAG VALUES FROM "snmp" WITH KEY = "metric" where hostname =~ /^$hostname$/
That returns for example FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0
It doesn’t return just the MIB name, is that correct? Should it just return the MIB name ???
I think I’ve followed your advice and improved the Grafana side,
my snmpoid variable in Grafana is now SHOW TAG VALUES FROM "snmp" WITH KEY = "metric" where hostname =~ /^$hostname$/ AND service =~ /^$service/
My request URL now looks like the following, which includes the correct service name, such as Fg Cpu Usage the snmpoid also reflects the service.
you cant do that for the OID, because its stored in metric.
The Output from your snmp plugin is SNMP OK - 11 | FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0=11
so the metric inside influxdb is FORTINET-FORTIGATE-MIB::fgSysCpuUsage.0
With the module you can set to use a custom var from your service to call the Grafana API where you can use it as a variable in your dashboard. If you use the oid from your service, the module will send the string “fgSysCpuUsage.0” to the API and you can use this variable. I dont recomend to use variables inside Grafana with queries, they slow down everything. Use only Constants for use with the module and a second dasboard with queries to fill the variables to play inside Grafana.
With the variable you can then set your queris to use values only from snmp with the hostname , servicename and the metrics that contain “fgSysCpuUsage.0”