Skip to content

Commit

Permalink
Merge branch 'pr/13'
Browse files Browse the repository at this point in the history
  • Loading branch information
freedomkk-qfeng committed May 24, 2023
1 parent b0dc867 commit 454fe8a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpustat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions descrstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
19 changes: 19 additions & 0 deletions memstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

}

0 comments on commit 454fe8a

Please sign in to comment.