From 454fe8ae0337ba7d79ad9039c29998104a1833fa Mon Sep 17 00:00:00 2001 From: Feng_Qi Date: Wed, 24 May 2023 13:05:09 +0800 Subject: [PATCH] Merge branch 'pr/13' --- cpustat.go | 3 +++ descrstat.go | 4 ++++ memstat.go | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/cpustat.go b/cpustat.go index ceafb18..1054a13 100644 --- a/cpustat.go +++ b/cpustat.go @@ -27,6 +27,9 @@ func CpuUtilization(ip, community string, timeout, retry int) (int, error) { oid = "1.3.6.1.4.1.9.9.305.1.1.1.0" case "Cisco", "Cisco_IOS_7200", "Cisco_old": oid = "1.3.6.1.4.1.9.9.109.1.1.1.1.7.1" + case "Hillstone": + oid = ".1.3.6.1.4.1.28557.2.2.1.3" + method = "getnext" case "Cisco_IOS_XE", "Cisco_IOS_XR": oid = "1.3.6.1.4.1.9.9.109.1.1.1.1.7" method = "getnext" diff --git a/descrstat.go b/descrstat.go index 14ee75e..c77853a 100644 --- a/descrstat.go +++ b/descrstat.go @@ -128,6 +128,10 @@ func SysVendor(ip, community string, retry int, timeout int) (string, error) { return "Aruba", err } + if strings.Contains(sysDescrLower, "hillstone") { + return "Hillstone", err + } + return "", err } diff --git a/memstat.go b/memstat.go index 8a04b78..261be2c 100644 --- a/memstat.go +++ b/memstat.go @@ -80,6 +80,8 @@ func MemUtilization(ip, community string, timeout, retry int) (int, error) { return GetArubaMem(ip, community, timeout, retry) case "Cisco_Controller": return GetCiscoControllerMem(ip, community, timeout, retry) + case "Hillstone": + return GetHillSoneMem(ip, community, timeout, retry) default: err = errors.New(ip + " Switch Vendor is not defined") return 0, err @@ -289,3 +291,20 @@ func GetCiscoControllerMem(ip, community string, timeout, retry int) (int, error } return 0, err } + +func GetHillSoneMem(ip, community string, timeout, retry int) (int, error) { + + method := "getnext" + memTotalOid := ".1.3.6.1.4.1.28557.2.2.1.4" + memTotal, err := RunSnmp(ip, community, memTotalOid, method, timeout) + memFreeOid := ".1.3.6.1.4.1.28557.2.2.1.5" + memFree, err := RunSnmp(ip, community, memFreeOid, method, timeout) + if &memTotal[0] != nil && &memFree[0] != nil { + memfree := memFree[0].Value.(int) + memtotal := memTotal[0].Value.(int) + memUtili := float64(memtotal-memfree) / float64(memtotal) + return int(memUtili * 100), nil + } + return 0, err + +}