Skip to content

Commit

Permalink
cmd/scollector: Add metadata for SNMP network interface stats
Browse files Browse the repository at this point in the history
Also eliminate bond specific descriptions. Would have to do the same for tunnel, virtual, etc. And what it is should be clear from the metric name.
  • Loading branch information
kylebrandt committed Aug 13, 2015
1 parent 5db76e8 commit dd5ffdf
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 60 deletions.
41 changes: 19 additions & 22 deletions cmd/scollector/collectors/collectors.go
Expand Up @@ -55,28 +55,25 @@ const (
)

const (
osCPUClockDesc = "The current speed of the processor in MHz."
osDiskFreeDesc = "The space_free property indicates in bytes how much free space is available on the disk."
osDiskPctFreeDesc = "The percent_free property indicates what percentage of the disk is available."
osDiskTotalDesc = "The space_total property indicates in bytes how much total space is on the disk."
osDiskUsedDesc = "The space_used property indicates in bytes how much space is used on the disk."
osMemFreeDesc = "Number, in bytes, of physical memory currently unused and available."
osMemPctFreeDesc = "The percent of free memory. In Linux free memory includes memory used by buffers and cache."
osMemTotalDesc = "Total amount, in bytes, of physical memory available to the operating system."
osMemUsedDesc = "The amount of used memory. In Linux this excludes memory used by buffers and cache."
osNetBondBroadcastDesc = "The rate at which broadcast packets are sent or received on the bonded network interfaces."
osNetBondBytesDesc = "The rate at which bytes are sent or received over bonded network adapters."
osNetBondDroppedDesc = "The number of packets that were chosen to be discarded even though no errors had been detected to prevent transmission."
osNetBondErrorsDesc = "The number of packets that could not be transmitted because of errors."
osNetBondMulticastDesc = "The rate at which multicast packets are sent or received on the bonded network interfaces."
osNetBondPacketsDesc = "The rate at which packets are sent or received on the bonded network interfaces."
osNetBondUnicastDesc = "The rate at which unicast packets are sent or received on the bonded network interfaces."
osNetBondifspeedDesc = "The total link speed of the bonded adapters in Megabits per second."
osNetBytesDesc = "The rate at which bytes are sent or received over each network adapter."
osNetDroppedDesc = "The number of packets that were chosen to be discarded even though no errors had been detected to prevent transmission."
osNetErrorsDesc = "The number of packets that could not be transmitted because of errors."
osNetPacketsDesc = "The rate at which packets are sent or received on the network interface."
osSystemUptimeDesc = "Seconds since last reboot."
osCPUClockDesc = "The current speed of the processor in MHz."
osDiskFreeDesc = "The space_free property indicates in bytes how much free space is available on the disk."
osDiskPctFreeDesc = "The percent_free property indicates what percentage of the disk is available."
osDiskTotalDesc = "The space_total property indicates in bytes how much total space is on the disk."
osDiskUsedDesc = "The space_used property indicates in bytes how much space is used on the disk."
osMemFreeDesc = "Number, in bytes, of physical memory currently unused and available."
osMemPctFreeDesc = "The percent of free memory. In Linux free memory includes memory used by buffers and cache."
osMemTotalDesc = "Total amount, in bytes, of physical memory available to the operating system."
osMemUsedDesc = "The amount of used memory. In Linux this excludes memory used by buffers and cache."
osNetBroadcastDesc = "The rate at which broadcast packets are sent or received on the network interface."
osNetBytesDesc = "The rate at which bytes are sent or received over the network interface."
osNetDroppedDesc = "The number of packets that were chosen to be discarded even though no errors had been detected to prevent transmission."
osNetErrorsDesc = "The number of packets that could not be transmitted because of errors."
osNetMulticastDesc = "The rate at which multicast packets are sent or received on the network interface."
osNetPacketsDesc = "The rate at which packets are sent or received on the network interface."
osNetUnicastDesc = "The rate at which unicast packets are sent or received on the network interface."
osNetIfspeedDesc = "The total link speed of the network interface in Megabits per second."
osNetPauseFrameDesc = "The rate of pause frames sent or recieved on the network interface. An overwhelmed network element can send a pause frame, which halts the transmission of the sender for a specified period of time."
osSystemUptimeDesc = "Seconds since last reboot."
)

var (
Expand Down
30 changes: 15 additions & 15 deletions cmd/scollector/collectors/network_windows.go
Expand Up @@ -239,21 +239,21 @@ func c_network_team_windows() (opentsdb.MultiDataPoint, error) {
Add(&md, "win.net.bond.packets_multicast", nicStats.SentMulticastPackets, tagsOut, metadata.Counter, metadata.PerSecond, descWinNetTeamSentMulticastPackets)
Add(&md, "win.net.bond.packets_broadcast", nicStats.ReceivedBroadcastPackets, tagsIn, metadata.Counter, metadata.PerSecond, descWinNetTeamReceivedBroadcastPackets)
Add(&md, "win.net.bond.packets_broadcast", nicStats.SentBroadcastPackets, tagsOut, metadata.Counter, metadata.PerSecond, descWinNetTeamSentBroadcastPackets)
Add(&md, osNetBondifspeed, linkSpeed/1000000, opentsdb.TagSet{"iface": iface}, metadata.Gauge, metadata.Megabit, osNetBondifspeedDesc)
Add(&md, osNetBondBytes, nicStats.ReceivedBytes, tagsIn, metadata.Counter, metadata.Bytes, osNetBondBytesDesc)
Add(&md, osNetBondBytes, nicStats.SentBytes, tagsOut, metadata.Counter, metadata.Bytes, osNetBondBytesDesc)
Add(&md, osNetBondUnicast, nicStats.ReceivedUnicastPackets, tagsIn, metadata.Counter, metadata.Count, osNetBondUnicastDesc)
Add(&md, osNetBondUnicast, nicStats.SentUnicastPackets, tagsOut, metadata.Counter, metadata.Count, osNetBondUnicastDesc)
Add(&md, osNetBondMulticast, nicStats.ReceivedMulticastPackets, tagsIn, metadata.Counter, metadata.Count, osNetBondMulticastDesc)
Add(&md, osNetBondMulticast, nicStats.SentMulticastPackets, tagsOut, metadata.Counter, metadata.Count, osNetBondMulticastDesc)
Add(&md, osNetBondBroadcast, nicStats.ReceivedBroadcastPackets, tagsIn, metadata.Counter, metadata.Count, osNetBondBroadcastDesc)
Add(&md, osNetBondBroadcast, nicStats.SentBroadcastPackets, tagsOut, metadata.Counter, metadata.Count, osNetBondBroadcastDesc)
Add(&md, osNetBondPackets, float64(nicStats.ReceivedUnicastPackets)+float64(nicStats.ReceivedMulticastPackets)+float64(nicStats.ReceivedBroadcastPackets), tagsIn, metadata.Counter, metadata.Count, osNetBondPacketsDesc)
Add(&md, osNetBondPackets, float64(nicStats.SentUnicastPackets)+float64(nicStats.SentMulticastPackets)+float64(nicStats.SentBroadcastPackets), tagsOut, metadata.Counter, metadata.Count, osNetBondPacketsDesc)
Add(&md, osNetBondDropped, nicStats.ReceivedDiscardedPackets, tagsIn, metadata.Counter, metadata.Count, osNetBondDroppedDesc)
Add(&md, osNetBondDropped, nicStats.OutboundDiscardedPackets, tagsOut, metadata.Counter, metadata.Count, osNetBondDroppedDesc)
Add(&md, osNetBondErrors, nicStats.ReceivedPacketErrors, tagsIn, metadata.Counter, metadata.Count, osNetBondErrorsDesc)
Add(&md, osNetBondErrors, nicStats.OutboundPacketErrors, tagsOut, metadata.Counter, metadata.Count, osNetBondErrorsDesc)
Add(&md, osNetBondIfSpeed, linkSpeed/1000000, opentsdb.TagSet{"iface": iface}, metadata.Gauge, metadata.Megabit, osNetIfSpeedDesc)
Add(&md, osNetBondBytes, nicStats.ReceivedBytes, tagsIn, metadata.Counter, metadata.Bytes, osNetBytesDesc)
Add(&md, osNetBondBytes, nicStats.SentBytes, tagsOut, metadata.Counter, metadata.Bytes, osNetBytesDesc)
Add(&md, osNetBondUnicast, nicStats.ReceivedUnicastPackets, tagsIn, metadata.Counter, metadata.Count, osNetUnicastDesc)
Add(&md, osNetBondUnicast, nicStats.SentUnicastPackets, tagsOut, metadata.Counter, metadata.Count, osNetUnicastDesc)
Add(&md, osNetBondMulticast, nicStats.ReceivedMulticastPackets, tagsIn, metadata.Counter, metadata.Count, osNetMulticastDesc)
Add(&md, osNetBondMulticast, nicStats.SentMulticastPackets, tagsOut, metadata.Counter, metadata.Count, osNetMulticastDesc)
Add(&md, osNetBondBroadcast, nicStats.ReceivedBroadcastPackets, tagsIn, metadata.Counter, metadata.Count, osNetBroadcastDesc)
Add(&md, osNetBondBroadcast, nicStats.SentBroadcastPackets, tagsOut, metadata.Counter, metadata.Count, osNetBroadcastDesc)
Add(&md, osNetBondPackets, float64(nicStats.ReceivedUnicastPackets)+float64(nicStats.ReceivedMulticastPackets)+float64(nicStats.ReceivedBroadcastPackets), tagsIn, metadata.Counter, metadata.Count, osNetPacketsDesc)
Add(&md, osNetBondPackets, float64(nicStats.SentUnicastPackets)+float64(nicStats.SentMulticastPackets)+float64(nicStats.SentBroadcastPackets), tagsOut, metadata.Counter, metadata.Count, osNetPacketsDesc)
Add(&md, osNetBondDropped, nicStats.ReceivedDiscardedPackets, tagsIn, metadata.Counter, metadata.Count, osNetDroppedDesc)
Add(&md, osNetBondDropped, nicStats.OutboundDiscardedPackets, tagsOut, metadata.Counter, metadata.Count, osNetDroppedDesc)
Add(&md, osNetBondErrors, nicStats.ReceivedPacketErrors, tagsIn, metadata.Counter, metadata.Count, osNetErrorsDesc)
Add(&md, osNetBondErrors, nicStats.OutboundPacketErrors, tagsOut, metadata.Counter, metadata.Count, osNetErrorsDesc)
}
return md, nil
}
Expand Down
49 changes: 26 additions & 23 deletions cmd/scollector/collectors/snmp_ifaces.go
Expand Up @@ -101,49 +101,49 @@ func c_snmp_ifaces(community, host string) (opentsdb.MultiDataPoint, error) {
}
}
var md opentsdb.MultiDataPoint
add := func(oid, metric, dir string) error {
m, err := snmp_subtree(host, community, oid)
add := func(sA snmpAdd) error {
m, err := snmp_subtree(host, community, sA.oid)
if err != nil {
return err
}
var sum int64
for k, v := range m {
tags := opentsdb.TagSet{
"host": host,
"direction": dir,
"direction": sA.dir,
"iface": fmt.Sprintf("%d", k),
"iname": ifNames[k],
}
if iVal, ok := v.(int64); ok && ifTypes[k] == 6 {
sum += iVal
}
Add(&md, switchInterfaceMetric(metric, ifNames[k], ifTypes[k]), v, tags, metadata.Unknown, metadata.None, "")
Add(&md, switchInterfaceMetric(sA.metric, ifNames[k], ifTypes[k]), v, tags, sA.rate, sA.unit, sA.desc)
metadata.AddMeta("", tags, "alias", ifAliases[k], false)
}
if metric == osNetBytes {
tags := opentsdb.TagSet{"host": host, "direction": dir}
Add(&md, osNetBytes+".total", sum, tags, metadata.Counter, metadata.Bytes, "")
if sA.metric == osNetBytes {
tags := opentsdb.TagSet{"host": host, "direction": sA.dir}
Add(&md, osNetBytes+".total", sum, tags, metadata.Counter, metadata.Bytes, "The total number of bytes transfered through the network device.")
}
return nil
}
oids := []snmpAdd{
{ifHCInBroadcastPkts, osNetBroadcast, "in"},
{ifHCInMulticastPkts, osNetMulticast, "in"},
{ifHCInUcastPkts, osNetUnicast, "in"},
{ifHCOutBroadcastPkts, osNetBroadcast, "out"},
{ifHCOutMulticastPkts, osNetMulticast, "out"},
{ifHCOutOctets, osNetBytes, "out"},
{ifHCOutUcastPkts, osNetUnicast, "out"},
{ifHCinOctets, osNetBytes, "in"},
{ifInDiscards, osNetDropped, "in"},
{ifInErrors, osNetErrors, "in"},
{ifOutDiscards, osNetDropped, "out"},
{ifOutErrors, osNetErrors, "out"},
{ifInPauseFrames, osNetPauseFrames, "in"},
{ifOutPauseFrames, osNetPauseFrames, "out"},
{ifHCInBroadcastPkts, osNetBroadcast, "in", metadata.Counter, metadata.Packet, osNetBroadcastDesc},
{ifHCInMulticastPkts, osNetMulticast, "in", metadata.Counter, metadata.Packet, osNetMulticastDesc},
{ifHCInUcastPkts, osNetUnicast, "in", metadata.Counter, metadata.Packet, osNetUnicastDesc},
{ifHCOutBroadcastPkts, osNetBroadcast, "out", metadata.Counter, metadata.Packet, osNetBroadcastDesc},
{ifHCOutMulticastPkts, osNetMulticast, "out", metadata.Counter, metadata.Packet, osNetMulticastDesc},
{ifHCOutOctets, osNetBytes, "out", metadata.Counter, metadata.Bytes, osNetBytesDesc},
{ifHCOutUcastPkts, osNetUnicast, "out", metadata.Counter, metadata.Packet, osNetUnicastDesc},
{ifHCinOctets, osNetBytes, "in", metadata.Counter, metadata.Bytes, osNetBytesDesc},
{ifInDiscards, osNetDropped, "in", metadata.Counter, metadata.Packet, osNetDroppedDesc},
{ifInErrors, osNetErrors, "in", metadata.Counter, metadata.Error, osNetErrorsDesc},
{ifOutDiscards, osNetDropped, "out", metadata.Counter, metadata.Packet, osNetDroppedDesc},
{ifOutErrors, osNetErrors, "out", metadata.Counter, metadata.Error, osNetErrorsDesc},
{ifInPauseFrames, osNetPauseFrames, "in", metadata.Counter, metadata.Frame, osNetPauseFrameDesc},
{ifOutPauseFrames, osNetPauseFrames, "out", metadata.Counter, metadata.Frame, osNetPauseFrameDesc},
}
for _, o := range oids {
if err := add(o.oid, o.metric, o.dir); err != nil {
for _, sA := range oids {
if err := add(sA); err != nil {
return nil, err
}
}
Expand All @@ -154,4 +154,7 @@ type snmpAdd struct {
oid string
metric string
dir string
rate metadata.RateType
unit metadata.Unit
desc string
}
2 changes: 2 additions & 0 deletions metadata/metadata.go
Expand Up @@ -57,6 +57,7 @@ const (
Fault = "faults"
Flush = "flushes"
Files = "files"
Frame = "frames"
Get = "gets"
GetExists = "get exists"
Interupt = "interupts"
Expand All @@ -71,6 +72,7 @@ const (
MilliSecond = "milliseconds"
Ok = "ok" // "OK" or not status, 0 = ok, 1 = not ok
Operation = "Operations"
Packet = "packets"
Page = "pages"
Pct = "percent" // Range of 0-100.
PerSecond = "per second"
Expand Down

0 comments on commit dd5ffdf

Please sign in to comment.