Skip to content

Commit

Permalink
4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
freedomkk-qfeng committed Sep 18, 2016
1 parent 0847f60 commit cd61c66
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 77 deletions.
15 changes: 14 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Changelog #
## 4.0.2 ##
#### 新功能 ####
1. 增加接口速率的采集
* switch.if.Speed
2. 增加接口流量百分比的采集
* switch.if.InSpeedPercent
* switch.if.OutSpeedPercent

#### 改进 ####
1. Counter 类型的数据上报逻辑大幅更改。现在 swcollector 将在本地计算出相应的数值,再以 Gauge 类型上报。如果出现异常的数据,则在本地直接抛弃。因此最终呈现的绘图至多只会出现断点,而不再会出现极端的异常图形。
2. 优化了 gosnmp 的端口采集,现在 gosnmp 端口采集的超时情况应该大幅度降低了


## 3.2.1.1 ##
1. debugmetric 现在支持配置多个 endpoint 和 metric 了
## 3.2.1 ##
Expand All @@ -21,7 +34,7 @@

6. 现在能够通过 gosnmp 的配置选项,选择采用 gosnmp 还是 snmpwalk 进行数据采集了。两者效率相仿,snmpwalk稍微多占用点系统资源

### 改进 ###
#### 改进 ####
1. 优化了 gosnmp 的端口采集,略微控制了一下并发速率,现在 gosnmp 采集端口超时的概率,应该有所降低了
2. 代码优化,删除了部分无关代码(比如 hbs 相关的部分……)
3. 部分日志的输出可读性更强了
Expand Down
60 changes: 35 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* IfOutErros
* IfInUnknownProtos
* IfOutQLen
* IfSpeed
* IfSpeedPercent
* IfOperStatus(接口状态,1 up, 2 down, 3 testing, 4 unknown, 5 dormant, 6 notPresent, 7 lowerLayerDown)


Expand Down Expand Up @@ -82,36 +84,43 @@ swcollector需要部署到有交换机SNMP访问权限的服务器上。
```
{
"debug": true,
"debugmetric":{ # 在日志中 debug 具体的指标
"endpoints":["192.168.56.101","192.168.56.102"], # 必填
"metrics":["switch.if.In","switch.if.Out"], # 必填
"tags":"ifName=Fa0/1" # 有则匹配 tag,如为 "" 则打印该 metric 的全部信息
"debugmetric":{ # 在日志中 debug 具体的指标
"endpoints":["192.168.56.101","192.168.56.102"], # 必填
"metrics":["switch.if.In","switch.if.Out"], # 必填
"tags":"ifName=Fa0/1" # 有则匹配 tag,如为 "" 则打印该 metric 的全部信息
},
"switch":{
"enabled": true, #交换机IP地址段,对该网段有效IP,先发Ping包探测,对存活IP发SNMP请求
"ipRange":[
"enabled": true,
"ipRange":[ #交换机IP地址段,对该网段有效IP,先发Ping包探测,对存活IP发SNMP请求
"192.168.56.101/32",
"192.168.56.102/32",
"172.16.114.233"
],
"gosnmp":true, #是否使用 gosnmp 采集, false 则使用 snmpwalk
"pingTimeout":300, #Ping超时时间,单位毫秒
"pingRetry":4, #Ping探测重试次数
"community":"public", #SNMP认证字符串
"snmpTimeout":1000, #SNMP超时时间,单位毫秒
"snmpRetry":5, #SNMP重试次数
"ignoreIface": ["Nu","NU","Vlan","Vl"], #忽略的接口,如Nu匹配ifName为*Nu*的接口
"ignorePkt": true, #不采集IfHCInUcastPkts和IfHCOutUcastPkts
"ignoreBroadcastPkt": true, #不采集IfHCInBroadcastPkts和IfHCOutBroadcastPkts
"ignoreMulticastPkt": true, #不采集IfHCInMulticastPkts和IfHCOutMulticastPkts
"ignoreDiscards": true, #不采集IfInDiscards和IfOutDiscardss
"ignoreErrors": true, #不采集IfInErrors和IfOutErros
"ignoreOperStatus": true, #不采集IfOperStatus
"ignoreUnknownProtos":true, #不采集IfInUnknownProtos
"ignoreOutQLen":true, #不采集IfOutQLen
"displayByBit": true, #true时,上报的流量单位为bit,为false则单位为byte。
"fastPingMode": false, #是否开启 fastPing 模式,开启 Ping 的效率更高,并能解决高并发时,会有小概率 ping 通宕机的交换机地址的情况。但 fastPing 可能被防火墙过滤。
"limitConcur": 1000 #限制并发数
"gosnmp":true, #是否使用 gosnmp 采集, false 则使用 snmpwalk
"pingTimeout":300, #Ping超时时间,单位毫秒
"pingRetry":4, #Ping探测重试次数
"community":"public", #SNMP认证字符串
"snmpTimeout":1000, #SNMP超时时间,单位毫秒
"snmpRetry":5, #SNMP重试次数
"ignoreIface": ["Nu","NU","Vlan","Vl"], #忽略的接口,如Nu匹配ifName为*Nu*的接口
"ignoreOperStatus": true, #不采集IfOperStatus
"speedlimit":0, #流量的上限,如果采集计算出的流量超过这个数值,则抛弃不上报。如果填0,则以接口的速率(ifSpeed)作为上限计算。注意 interface vlan 这样的虚接口是没有 ifSpeed 的,因此不进行最大值的比较。
"ignorePkt": true, #不采集IfHCInUcastPkts和IfHCOutUcastPkts
"pktlimit": 0, #pkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreBroadcastPkt": true, #不采集IfHCInBroadcastPkts和IfHCOutBroadcastPkts
"broadcastPktlimit": 0, #broadcastPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreMulticastPkt": true, #不采集IfHCInMulticastPkts和IfHCOutMulticastPkts
"multicastPktlimit": 0, #multicastPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreDiscards": true, #不采集IfInDiscards和IfOutDiscards
"discardsPktlimit": 0, #discardsPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreErrors": true, #不采集IfInErrors和IfOutErros
"errorsPktlimit": 0, #errorsPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreUnknownProtos":true, #不采集IfInUnknownProtos
"unknownProtosPktlimit": 0, #unknownProtosPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"ignoreOutQLen":true, #不采集IfOutQLen
"outQLenPktlimit": 0, #outQLenPkt的上限,如果采集计算出的包速率超过这个数值,则抛弃不上报。如果填0,则不进行最大值比较。
"fastPingMode": true,
"limitConcur": 1000
},
"transfer": {
"enabled": true,
Expand All @@ -124,6 +133,7 @@ swcollector需要部署到有交换机SNMP访问权限的服务器上。
"listen": ":1989"
}
}
```

##部署说明
Expand All @@ -133,7 +143,7 @@ swcollector需要部署到有交换机SNMP访问权限的服务器上。
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.10.1 PingResult: true len_list: 440 UsedTime: 5
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.10.252 PingResult: true len_list: 97 UsedTime: 2
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.13.1 PingResult: true len_list: 24 UsedTime: 1
2016/08/16 21:31:24 swifstat.go:121: IP: 192.1680.14.1 PingResult: true len_list: 23 UsedTime: 1
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.14.1 PingResult: true len_list: 23 UsedTime: 1
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.23.1 PingResult: true len_list: 61 UsedTime: 2
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.12.1 PingResult: true len_list: 55 UsedTime: 1
2016/08/16 21:31:24 swifstat.go:121: IP: 192.168.12.5 PingResult: true len_list: 26 UsedTime: 2
Expand Down
30 changes: 15 additions & 15 deletions cfg.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
"snmpTimeout":1000,
"snmpRetry":5,
"ignoreIface": ["Nu","NU","Vlan","Vl"],
"ignoreOperStatus": false,
"ignoreOperStatus": true,
"speedlimit":0,
"ignorePkt": false,
"pktlimit": 100000000,
"ignoreBroadcastPkt": false,
"broadcastPktlimit": 100000000,
"ignoreMulticastPkt": false,
"multicastPktlimit": 100000000,
"ignoreDiscards": false,
"discardsPktlimit": 100000000,
"ignoreErrors": false,
"errorsPktlimit": 100000000,
"ignoreUnknownProtos":false,
"unknownProtosPktlimit": 100000000,
"ignoreOutQLen":false,
"outQLenPktlimit": 100000000,
"ignorePkt": true,
"pktlimit": 0,
"ignoreBroadcastPkt": true,
"broadcastPktlimit": 0,
"ignoreMulticastPkt": true,
"multicastPktlimit": 0,
"ignoreDiscards": true,
"discardsPktlimit": 0,
"ignoreErrors": true,
"errorsPktlimit": 0,
"ignoreUnknownProtos":true,
"unknownProtosPktlimit": 0,
"ignoreOutQLen":true,
"outQLenPktlimit": 0,
"fastPingMode": true,
"limitConcur": 1000
},
Expand Down
1 change: 1 addition & 0 deletions funcs/swconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func connMetrics(ip string, ch chan SwConn) {
ConnectionStat, err := sw.ConnectionStat(ip, g.Config().Switch.Community, g.Config().Switch.SnmpTimeout, g.Config().Switch.SnmpRetry)
if err != nil {
log.Println(err)
ch <- swConn
return
}

Expand Down
1 change: 1 addition & 0 deletions funcs/swcpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func cpuMetrics(ip string, ch chan SwCpu) {
cpuUtili, err := sw.CpuUtilization(ip, g.Config().Switch.Community, g.Config().Switch.SnmpTimeout, g.Config().Switch.SnmpRetry)
if err != nil {
log.Println(err)
ch <- swCpu
return
}

Expand Down
Loading

0 comments on commit cd61c66

Please sign in to comment.