diff --git a/cmd/scollector/collectors/snmp.go b/cmd/scollector/collectors/snmp.go index 1585dff362..ca5b3fc1eb 100644 --- a/cmd/scollector/collectors/snmp.go +++ b/cmd/scollector/collectors/snmp.go @@ -117,6 +117,12 @@ func snmp_oid(host, community, oid string) (*big.Int, error) { return v, err } +func snmpOidString(host, community, oid string) (string, error) { + var v []byte + err := snmp.Get(host, community, oid, &v) + return string(v), err +} + func snmp_convertToFloat(v interface{}) (float64, error) { switch val := v.(type) { case int: diff --git a/cmd/scollector/collectors/snmp_cisco.go b/cmd/scollector/collectors/snmp_cisco.go index 57909d29eb..10c185e2ce 100644 --- a/cmd/scollector/collectors/snmp_cisco.go +++ b/cmd/scollector/collectors/snmp_cisco.go @@ -26,6 +26,13 @@ func SNMPCiscoASA(cfg conf.SNMP) { Interval: time.Second * 30, name: fmt.Sprintf("snmp-cisco-asa-%s", cfg.Host), }, + &IntervalCollector{ + F: func() (opentsdb.MultiDataPoint, error) { + return c_cisco_desc(cfg.Host, cfg.Community) + }, + Interval: time.Minute * 5, + name: fmt.Sprintf("snmp-cisco-desc-%s", cfg.Host), + }, ) } @@ -40,6 +47,13 @@ func SNMPCiscoIOS(cfg conf.SNMP) { Interval: time.Second * 30, name: fmt.Sprintf("snmp-cisco-ios-%s", cfg.Host), }, + &IntervalCollector{ + F: func() (opentsdb.MultiDataPoint, error) { + return c_cisco_desc(cfg.Host, cfg.Community) + }, + Interval: time.Minute * 5, + name: fmt.Sprintf("snmp-cisco-desc-%s", cfg.Host), + }, ) } @@ -54,6 +68,13 @@ func SNMPCiscoNXOS(cfg conf.SNMP) { Interval: time.Second * 30, name: fmt.Sprintf("snmp-cisco-nxos-%s", cfg.Host), }, + &IntervalCollector{ + F: func() (opentsdb.MultiDataPoint, error) { + return c_cisco_desc(cfg.Host, cfg.Community) + }, + Interval: time.Minute * 5, + name: fmt.Sprintf("snmp-cisco-desc-%s", cfg.Host), + }, ) } @@ -218,3 +239,16 @@ func c_cisco_nxos(host, community string, cpuIntegrator tsIntegrator) (opentsdb. } return md, nil } + +func c_cisco_desc(host, community string) (opentsdb.MultiDataPoint, error) { + var md opentsdb.MultiDataPoint + desc, err := getSNMPDesc(host, community) + if err != nil { + return md, err + } + if desc == "" { + return md, fmt.Errorf("empty description string (used to get OS version) for cisco host %v", host) + } + metadata.AddMeta("", opentsdb.TagSet{"host": host}, "versionCaption", desc, false) + return md, nil +} diff --git a/cmd/scollector/collectors/snmp_sys.go b/cmd/scollector/collectors/snmp_sys.go index fa93a9fe6a..1055ae760e 100644 --- a/cmd/scollector/collectors/snmp_sys.go +++ b/cmd/scollector/collectors/snmp_sys.go @@ -10,7 +10,10 @@ import ( "bosun.org/opentsdb" ) -const sysUpTime = ".1.3.6.1.2.1.1.3.0" // "The time (in hundredths of a second) since the network management portion of the system was last re-initialized." +const ( + sysUpTime = ".1.3.6.1.2.1.1.3.0" // "The time (in hundredths of a second) since the network management portion of the system was last re-initialized." + sysDescr = ".1.3.6.1.2.1.1.1.0" +) // SNMPSys registers a SNMP system data collector for the given community and host. func SNMPSys(cfg conf.SNMP) { @@ -32,3 +35,13 @@ func c_snmp_sys(host, community string) (opentsdb.MultiDataPoint, error) { Add(&md, osSystemUptime, uptime.Int64()/big.NewInt(100).Int64(), opentsdb.TagSet{"host": host}, metadata.Gauge, metadata.Second, osSystemUptimeDesc) return md, nil } + +// Description may mean different things so it isn't called in sys, for example +// with cisco it is the os version +func getSNMPDesc(host, community string) (description string, err error) { + description, err = snmpOidString(host, community, sysDescr) + if err != nil { + return description, fmt.Errorf("failed to fetch description for host %v: %v", host, err) + } + return +}