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
326f4c77
Commit
326f4c77
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Patches
Plain Diff
diskdetailelper changes
32 bit compatibility added by -- RiteshP
parent
396fca27
Branches
Branches containing commit
1 merge request
!33
diskdetailelper changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
diskdetailshelper/diskdetails.go
+10
-6
diskdetailshelper/diskdetails.go
with
10 additions
and
6 deletions
diskdetailshelper/diskdetails.go
+
10
−
6
View file @
326f4c77
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
...
...
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