forked from gaochao1/sw
-
Notifications
You must be signed in to change notification settings - Fork 1
/
temperature.go
42 lines (39 loc) · 1 KB
/
temperature.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sw
import (
"errors"
"log"
)
func Temperature(ip, community string, timeout, retry int) (uint64, error) {
defer func() {
if r := recover(); r != nil {
log.Println(ip+" Recovered in Temperature", r)
}
}()
var vendor string
var err error
if v, ok := VendorMap.Load(ip); !ok {
vendor, _, err = SysVendor(ip, community, retry, timeout)
if err != nil {
return 0, err
}
VendorMap.Store(ip, vendor)
} else {
vendor = v.(string)
}
var oid string
switch vendor {
case Huawei_V5, Huawei_V5_70, Huawei_V5_130, Huawei_V5_150, Huawei_V5_170:
oid = "1.3.6.1.4.1.2011.5.25.31.1.1.1.1.11"
case FutureMatrix:
oid = "1.3.6.1.4.1.56813.5.25.31.1.1.1.1.11"
case Ruijie:
oid = "1.3.6.1.4.1.4881.1.1.10.2.1.1.16.0"
case H3C_V5, H3C_V7:
oid = "1.3.6.1.4.1.25506.2.6.1.1.1.1.12"
case H3C_S5500, H3C_V3_1:
oid = "1.3.6.1.4.1.2011.10.2.6.1.1.1.1.12"
default:
return 0, errors.New(ip + " Switch Temperature Vendor is not defined")
}
return getCpuMemTemp(ip, community, oid, timeout, retry)
}