Commit 326f4c77 authored by Sandeep S. Shewalkar's avatar Sandeep S. Shewalkar
Browse files

diskdetailelper changes

32 bit compatibility added by -- RiteshP
parent 396fca27
Branches
1 merge request!33diskdetailelper changes
Showing with 10 additions and 6 deletions
package diskdetailshelper
import (
"regexp"
"bytes"
"errors"
"os/exec"
"regexp"
"strconv"
"strings"
"time"
......@@ -132,7 +132,7 @@ func GetDiskDetails() ([]DiskStats, error) {
logginghelper.LogError("error occured while running wmic command", commandError)
return diskStats, commandError
}
re := regexp.MustCompile("[A-Z]{1}:[\\s]+[0-9][\\s]+[0-9]+[\\s]+[0-9]+")
diskDetailList := re.FindAllString(out.String(), -1)
......@@ -145,15 +145,19 @@ func GetDiskDetails() ([]DiskStats, error) {
if len(diskDetail) == 4 && diskDetail[1] == "3" {
stat := DiskStats{}
stat.Path = diskDetail[0]
freeSpace, err := strconv.Atoi(diskDetail[2])
freeSpace, err := strconv.ParseInt(diskDetail[2], 10, 64)
if err == nil {
stat.Free = uint64(freeSpace) / 1073741824
} else {
logginghelper.LogError("GetDiskDetails() Error occured while Free space conversion: ", err)
}
totalSpace, err := strconv.Atoi(diskDetail[3])
totalSpace, err := strconv.ParseInt(diskDetail[3], 10, 64)
if err == nil {
stat.Total = uint64(totalSpace) / 1073741824
} else {
logginghelper.LogError("GetDiskDetails() Error occured while Total space conversion: ", err)
}
stat.Used = uint64(totalSpace-freeSpace) / 1073741824
if stat.Used > 0 && stat.Total > 0 {
stat.UsedPercent = float64(stat.Used) / float64(stat.Total) * 100
......@@ -203,7 +207,7 @@ func GetCPUPhysicalID() (string, error) {
}
switch osInfo.OS {
case "windows":
cmd := exec.Command("wmic","CPU","get","ProcessorId")
cmd := exec.Command("wmic", "CPU", "get", "ProcessorId")
// cmd.Stdin = strings.NewReader("CPU get ProcessorId")
var out bytes.Buffer
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment