Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
37374f9a
Commit
37374f9a
authored
7 years ago
by
Onkar Sutar
Browse files
Options
Downloads
Patches
Plain Diff
OS info related changes
parent
c0c8894a
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diskdetailshelper/diskdetails.go
+13
-4
diskdetailshelper/diskdetails.go
diskdetailshelper/gopsutil/disk_windows.go
+5
-5
diskdetailshelper/gopsutil/disk_windows.go
with
18 additions
and
9 deletions
diskdetailshelper/diskdetails.go
+
13
−
4
View file @
37374f9a
...
...
@@ -5,6 +5,7 @@ import (
"errors"
"os/exec"
"regexp"
"runtime"
"strconv"
"strings"
"time"
...
...
@@ -78,12 +79,16 @@ type DiskStats struct {
// AnalyseDisk analyses the all disks and returns serial number of disk and path, total space, free space, used space, percentage of each drive
func
AnalyseDisk
()
(
UsageStat
,
error
)
{
UsageStatobj
:=
UsageStat
{}
os
:=
""
osInfo
,
err
:=
host
.
Info
()
if
err
!=
nil
{
logginghelper
.
LogError
(
"error occured while getting OS details"
,
err
)
return
UsageStatobj
,
err
// return UsageStatobj, err
os
=
runtime
.
GOOS
}
else
{
os
=
osInfo
.
OS
}
switch
os
Info
.
OS
{
switch
os
{
case
"windows"
:
UsageStatobj
.
SerialNumber
=
gopsutil
.
GetDiskSerialNumber
(
""
)
diskStats
,
err
:=
GetDiskDetails
()
...
...
@@ -200,12 +205,16 @@ func GetCPUUtilizationPercent(interval time.Duration, percpu bool) ([]float64, e
// GetCPUPhysicalID returns CPU Physical ID or empty string
func
GetCPUPhysicalID
()
(
string
,
error
)
{
cpuPhysicalID
:=
""
os
:=
""
osInfo
,
err
:=
host
.
Info
()
if
err
!=
nil
{
logginghelper
.
LogError
(
"error occured while getting OS details"
,
err
)
return
cpuPhysicalID
,
err
// return cpuPhysicalID, err
os
=
runtime
.
GOOS
}
else
{
os
=
osInfo
.
OS
}
switch
os
Info
.
OS
{
switch
os
{
case
"windows"
:
cmd
:=
exec
.
Command
(
"wmic"
,
"CPU"
,
"get"
,
"ProcessorId"
)
// cmd.Stdin = strings.NewReader("CPU get ProcessorId")
...
...
This diff is collapsed.
Click to expand it.
diskdetailshelper/gopsutil/disk_windows.go
+
5
−
5
View file @
37374f9a
...
...
@@ -3,8 +3,8 @@
package
gopsutil
import
(
"regexp"
"bytes"
"regexp"
"unsafe"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/coreospackage/logginghelper"
...
...
@@ -197,13 +197,13 @@ func GetDiskSerialNumber(name string) string {
info
,
err
:=
host
.
Info
()
if
err
!=
nil
{
logginghelper
.
LogError
(
"GetDiskSerialNumber Host Info() Err : "
,
err
)
return
""
//
return ""
}
cmd
:=
&
exec
.
Cmd
{}
if
strings
.
Contains
(
info
.
Platform
,
"Windows 7"
)
||
strings
.
Contains
(
info
.
Platform
,
"Windows 10"
)
{
cmd
=
exec
.
Command
(
"wmic"
,
"diskdrive"
,
"get"
,
"serialnumber"
)
if
err
==
nil
&&
(
strings
.
Contains
(
info
.
Platform
,
"Windows 7"
)
||
strings
.
Contains
(
info
.
Platform
,
"Windows 10"
)
)
{
cmd
=
exec
.
Command
(
"wmic"
,
"diskdrive"
,
"get"
,
"serialnumber"
)
}
else
{
cmd
=
exec
.
Command
(
"wmic"
,
"path"
,
"win32_physicalmedia"
,
"get"
,
"SerialNumber"
)
cmd
=
exec
.
Command
(
"wmic"
,
"path"
,
"win32_physicalmedia"
,
"get"
,
"SerialNumber"
)
}
var
out
bytes
.
Buffer
cmd
.
Stdout
=
&
out
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets