Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/scollector: Add MTU, AdminStatus, and OperationStatus to SNMP int… #1260

Merged
merged 1 commit into from
Aug 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions cmd/scollector/collectors/collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
osNetBondPackets = "os.net.bond.packets"
osNetBondUnicast = "os.net.bond.packets_unicast"
osNetBondifspeed = "os.net.bond.ifspeed"
osNetifspeed = "os.net.ifspeed"
osNetBroadcast = "os.net.packets_broadcast"
osNetBytes = "os.net.bytes"
osNetDropped = "os.net.dropped"
Expand All @@ -52,28 +53,34 @@ const (
osNetPauseFrames = "os.net.pause_frames"
osNetUnicast = "os.net.packets_unicast"
osSystemUptime = "os.system.uptime"
osNetMTU = "os.net.mtu"
osNetAdminStatus = "os.net.admin_status"
osNetOperStatus = "os.net.oper_status"
)

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."
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."
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."
osNetMTUDesc = "The maximum transmission unit for the ethernet frame."
osNetAdminStatusDesc = "The desired state of the interface. The testing(3) state indicates that no operational packets can be passed. When a managed system initializes, all interfaces start with ifAdminStatus in the down(2) state. As a result of either explicit management action or per configuration information retained by the managed system, ifAdminStatus is then changed to either the up(1) or testing(3) states (or remains in the down(2) state)."
osNetOperStatusDesc = "The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed. If ifAdminStatus is down(2) then ifOperStatus should be down(2). If ifAdminStatus is changed to up(1) then ifOperStatus should change to up(1) if the interface is ready to transmit and receive network traffic; it should change to dormant(5) if the interface is waiting for external actions (such as a serial line waiting for an incoming connection); it should remain in the down(2) state if and only if there is a fault that prevents it from going to the up(1) state; it should remain in the notPresent(6) state if the interface has missing (typically, hardware) components."
)

var (
Expand Down
20 changes: 15 additions & 5 deletions cmd/scollector/collectors/snmp_ifaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
const (
ifAlias = ".1.3.6.1.2.1.31.1.1.1.18"
ifDescr = ".1.3.6.1.2.1.2.2.1.2"
ifType = ".1.3.6.1.2.1.2.2.1.3"
ifMTU = ".1.3.6.1.2.1.2.2.1.4"
ifHighSpeed = ".1.3.6.1.2.1.31.1.1.1.15"
ifAdminStatus = ".1.3.6.1.2.1.2.2.1.7"
ifOperStatus = ".1.3.6.1.2.1.2.2.1.8"
ifHCInBroadcastPkts = ".1.3.6.1.2.1.31.1.1.1.9"
ifHCInMulticastPkts = ".1.3.6.1.2.1.31.1.1.1.8"
ifHCInUcastPkts = ".1.3.6.1.2.1.31.1.1.1.7"
Expand All @@ -28,7 +33,6 @@ const (
ifOutDiscards = ".1.3.6.1.2.1.2.2.1.19"
ifOutErrors = ".1.3.6.1.2.1.2.2.1.20"
ifOutPauseFrames = ".1.3.6.1.2.1.10.7.10.1.4"
ifType = "1.3.6.1.2.1.2.2.1.3"
)

// SNMPIfaces registers a SNMP Interfaces collector for the given community and host.
Expand Down Expand Up @@ -109,10 +113,12 @@ func c_snmp_ifaces(community, host string) (opentsdb.MultiDataPoint, error) {
var sum int64
for k, v := range m {
tags := opentsdb.TagSet{
"host": host,
"direction": sA.dir,
"iface": fmt.Sprintf("%d", k),
"iname": ifNames[k],
"host": host,
"iface": fmt.Sprintf("%d", k),
"iname": ifNames[k],
}
if sA.dir != "" {
tags["direction"] = sA.dir
}
if iVal, ok := v.(int64); ok && ifTypes[k] == 6 {
sum += iVal
Expand Down Expand Up @@ -141,6 +147,10 @@ func c_snmp_ifaces(community, host string) (opentsdb.MultiDataPoint, error) {
{ifOutErrors, osNetErrors, "out", metadata.Counter, metadata.Error, osNetErrorsDesc},
{ifInPauseFrames, osNetPauseFrames, "in", metadata.Counter, metadata.Frame, osNetPauseFrameDesc},
{ifOutPauseFrames, osNetPauseFrames, "out", metadata.Counter, metadata.Frame, osNetPauseFrameDesc},
{ifMTU, osNetMTU, "", metadata.Gauge, metadata.Bytes, osNetMTUDesc},
{ifHighSpeed, osNetifspeed, "", metadata.Gauge, metadata.Megabit, osNetIfspeedDesc},
{ifAdminStatus, osNetAdminStatus, "", metadata.Gauge, metadata.StatusCode, osNetAdminStatusDesc},
{ifOperStatus, osNetOperStatus, "", metadata.Gauge, metadata.StatusCode, osNetOperStatusDesc},
}
for _, sA := range oids {
if err := add(sA); err != nil {
Expand Down