diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-11-18 18:54:10 +0100 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-11-18 18:54:10 +0100 |
commit | c38af8933072bb2b9606cd6490e1a802ab4c4187 (patch) | |
tree | adf4e5cb65ed1dc5852c7c29e77eb6b1e09e12e3 /collectors/snmpfetchng.pl | |
parent | 06591202ce5549a949343f0f5f8959771a1b5657 (diff) |
Tweak various graphite/grafana integrations
s3 is currently disabled as it's bugged.
Diffstat (limited to 'collectors/snmpfetchng.pl')
-rwxr-xr-x | collectors/snmpfetchng.pl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/collectors/snmpfetchng.pl b/collectors/snmpfetchng.pl index 7c62ed3..b961cac 100755 --- a/collectors/snmpfetchng.pl +++ b/collectors/snmpfetchng.pl @@ -142,7 +142,9 @@ sub callback{ for my $nic (@nicids) { $tree2{'ports'}{$tree{$nic}{'ifName'}} = $tree{$nic}; for my $tmp_key (keys $tree{$nic}) { - my $path = "snmp.$switch{'sysname'}.ports.$tree{$nic}{'ifName'}.$tmp_key"; + my $field = $tree{$nic}{'ifName'}; + $field =~ s/[^a-z0-9]/_/gi; + my $path = "snmp.$switch{'sysname'}.ports.$field.$tmp_key"; my $value = $tree{$nic}{$tmp_key}; if ($value =~ m/^\d+$/) { print $sock "$path $value $now_graphite\n"; @@ -155,10 +157,11 @@ sub callback{ for my $key (keys %{$tree{$iid}}) { $tree2{'misc'}{$key}{$iid} = $tree{$iid}{$key}; my $localiid = $iid; - if ($iid ne "") { - $localiid = ".$iid"; + if ($localiid eq "") { + $localiid = "_"; } - my $path = "snmp.$switch{'sysname'}.misc.$key$localiid"; + $localiid =~ s/[^a-z0-9]/_/gi; + my $path = "snmp.$switch{'sysname'}.misc.$key.$localiid"; my $value = $tree{$iid}{$key}; if ($value =~ m/^\d+$/) { print $sock "$path $value $now_graphite\n"; |