Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b7bdd7ba
Unverified
Commit
b7bdd7ba
authored
Dec 04, 2017
by
liz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update systemstat9 to allow compilation on OSX
The latest version of system statadds stubbed out methods for non-Linux OSes:
https://bitbucket.org/bertimus9/systemstat/pull-requests/2
parent
08ea3d2a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
82 deletions
+142
-82
Godeps.json
Godeps/Godeps.json
+1
-1
BUILD
vendor/bitbucket.org/bertimus9/systemstat/BUILD
+2
-0
systemstat_ex.go
vendor/bitbucket.org/bertimus9/systemstat/systemstat_ex.go
+49
-0
systemstat_linux.go
...or/bitbucket.org/bertimus9/systemstat/systemstat_linux.go
+0
-81
utils.go
vendor/bitbucket.org/bertimus9/systemstat/utils.go
+90
-0
No files found.
Godeps/Godeps.json
View file @
b7bdd7ba
...
...
@@ -11,7 +11,7 @@
"Deps"
:
[
{
"ImportPath"
:
"bitbucket.org/bertimus9/systemstat"
,
"Rev"
:
"
1468fd0db20598383c9393cccaa547de6ad99e5e
"
"Rev"
:
"
6edb7bbcb021f6510db33e604f7e18861293a14a
"
},
{
"ImportPath"
:
"bitbucket.org/ww/goautoneg"
,
...
...
vendor/bitbucket.org/bertimus9/systemstat/BUILD
View file @
b7bdd7ba
...
...
@@ -4,6 +4,8 @@ go_library(
name = "go_default_library",
srcs = [
"systemstat.go",
"systemstat_ex.go",
"utils.go",
] + select({
"@io_bazel_rules_go//go/platform:linux_amd64": [
"systemstat_linux.go",
...
...
vendor/bitbucket.org/bertimus9/systemstat/systemstat_ex.go
0 → 100644
View file @
b7bdd7ba
// Copyright (c) 2013 Phillip Bond
// Licensed under the MIT License
// see file LICENSE
// +build !linux
package
systemstat
import
(
"syscall"
"time"
)
func
getUptime
(
procfile
string
)
(
uptime
UptimeSample
)
{
notImplemented
(
"getUptime"
)
uptime
.
Time
=
time
.
Now
()
return
}
func
getLoadAvgSample
(
procfile
string
)
(
samp
LoadAvgSample
)
{
notImplemented
(
"getLoadAvgSample"
)
samp
.
Time
=
time
.
Now
()
return
}
func
getMemSample
(
procfile
string
)
(
samp
MemSample
)
{
notImplemented
(
"getMemSample"
)
samp
.
Time
=
time
.
Now
()
return
}
func
getProcCPUSample
()
(
s
ProcCPUSample
)
{
var
processInfo
syscall
.
Rusage
syscall
.
Getrusage
(
syscall
.
RUSAGE_SELF
,
&
processInfo
)
s
.
Time
=
time
.
Now
()
s
.
ProcMemUsedK
=
int64
(
processInfo
.
Maxrss
)
s
.
User
=
float64
(
processInfo
.
Utime
.
Usec
)
/
1000000
+
float64
(
processInfo
.
Utime
.
Sec
)
s
.
System
=
float64
(
processInfo
.
Stime
.
Usec
)
/
1000000
+
float64
(
processInfo
.
Stime
.
Sec
)
s
.
Total
=
s
.
User
+
s
.
System
return
}
func
getCPUSample
(
procfile
string
)
(
samp
CPUSample
)
{
notImplemented
(
"getCPUSample"
)
samp
.
Time
=
time
.
Now
()
return
}
vendor/bitbucket.org/bertimus9/systemstat/systemstat_linux.go
View file @
b7bdd7ba
...
...
@@ -11,8 +11,6 @@ import (
"bytes"
"io"
"io/ioutil"
"log"
"runtime"
"strconv"
"strings"
"syscall"
...
...
@@ -163,82 +161,3 @@ func getCPUSample(procfile string) (samp CPUSample) {
}
return
}
func
getSimpleCPUAverage
(
first
CPUSample
,
second
CPUSample
)
(
avg
SimpleCPUAverage
)
{
//walltimediff := second.Time.Sub(first.Time)
//dT := float64(first.Total - second.Total)
dI
:=
float64
(
second
.
Idle
-
first
.
Idle
)
dTot
:=
float64
(
second
.
Total
-
first
.
Total
)
avg
.
IdlePct
=
dI
/
dTot
*
100
avg
.
BusyPct
=
(
dTot
-
dI
)
*
100
/
dTot
//log.Printf("cpu idle ticks %f, total ticks %f, idle pct %f, busy pct %f\n", dI, dTot, avg.IdlePct, avg.BusyPct)
return
}
func
subtractAndConvertTicks
(
first
uint64
,
second
uint64
)
float64
{
return
float64
(
first
-
second
)
}
func
getCPUAverage
(
first
CPUSample
,
second
CPUSample
)
(
avg
CPUAverage
)
{
dTot
:=
float64
(
second
.
Total
-
first
.
Total
)
invQuotient
:=
100.00
/
dTot
avg
.
UserPct
=
subtractAndConvertTicks
(
second
.
User
,
first
.
User
)
*
invQuotient
avg
.
NicePct
=
subtractAndConvertTicks
(
second
.
Nice
,
first
.
Nice
)
*
invQuotient
avg
.
SystemPct
=
subtractAndConvertTicks
(
second
.
System
,
first
.
System
)
*
invQuotient
avg
.
IdlePct
=
subtractAndConvertTicks
(
second
.
Idle
,
first
.
Idle
)
*
invQuotient
avg
.
IowaitPct
=
subtractAndConvertTicks
(
second
.
Iowait
,
first
.
Iowait
)
*
invQuotient
avg
.
IrqPct
=
subtractAndConvertTicks
(
second
.
Irq
,
first
.
Irq
)
*
invQuotient
avg
.
SoftIrqPct
=
subtractAndConvertTicks
(
second
.
SoftIrq
,
first
.
SoftIrq
)
*
invQuotient
avg
.
StealPct
=
subtractAndConvertTicks
(
second
.
Steal
,
first
.
Steal
)
*
invQuotient
avg
.
GuestPct
=
subtractAndConvertTicks
(
second
.
Guest
,
first
.
Guest
)
*
invQuotient
avg
.
Time
=
second
.
Time
avg
.
Seconds
=
second
.
Time
.
Sub
(
first
.
Time
)
.
Seconds
()
return
}
func
getProcCPUAverage
(
first
ProcCPUSample
,
second
ProcCPUSample
,
procUptime
float64
)
(
avg
ProcCPUAverage
)
{
dT
:=
second
.
Time
.
Sub
(
first
.
Time
)
.
Seconds
()
avg
.
UserPct
=
100
*
(
second
.
User
-
first
.
User
)
/
dT
avg
.
SystemPct
=
100
*
(
second
.
System
-
first
.
System
)
/
dT
avg
.
TotalPct
=
100
*
(
second
.
Total
-
first
.
Total
)
/
dT
avg
.
PossiblePct
=
100.0
*
float64
(
runtime
.
NumCPU
())
avg
.
CumulativeTotalPct
=
100
*
second
.
Total
/
procUptime
avg
.
Time
=
second
.
Time
avg
.
Seconds
=
dT
return
}
func
parseCPUFields
(
fields
[]
string
,
stat
*
CPUSample
)
{
numFields
:=
len
(
fields
)
stat
.
Name
=
fields
[
0
]
for
i
:=
1
;
i
<
numFields
;
i
++
{
val
,
numerr
:=
strconv
.
ParseUint
(
fields
[
i
],
10
,
64
)
if
numerr
!=
nil
{
log
.
Println
(
"systemstat.parseCPUFields(): Error parsing (field, value): "
,
i
,
fields
[
i
])
}
stat
.
Total
+=
val
switch
i
{
case
1
:
stat
.
User
=
val
case
2
:
stat
.
Nice
=
val
case
3
:
stat
.
System
=
val
case
4
:
stat
.
Idle
=
val
case
5
:
stat
.
Iowait
=
val
case
6
:
stat
.
Irq
=
val
case
7
:
stat
.
SoftIrq
=
val
case
8
:
stat
.
Steal
=
val
case
9
:
stat
.
Guest
=
val
}
}
}
vendor/bitbucket.org/bertimus9/systemstat/utils.go
0 → 100644
View file @
b7bdd7ba
package
systemstat
import
(
"log"
"runtime"
"strconv"
)
func
notImplemented
(
fn
string
)
{
log
.
Printf
(
"systemstat/%s is not implemented for this OS: %s
\n
"
,
fn
,
runtime
.
GOOS
)
}
func
getSimpleCPUAverage
(
first
CPUSample
,
second
CPUSample
)
(
avg
SimpleCPUAverage
)
{
//walltimediff := second.Time.Sub(first.Time)
//dT := float64(first.Total - second.Total)
dI
:=
float64
(
second
.
Idle
-
first
.
Idle
)
dTot
:=
float64
(
second
.
Total
-
first
.
Total
)
avg
.
IdlePct
=
dI
/
dTot
*
100
avg
.
BusyPct
=
(
dTot
-
dI
)
*
100
/
dTot
//log.Printf("cpu idle ticks %f, total ticks %f, idle pct %f, busy pct %f\n", dI, dTot, avg.IdlePct, avg.BusyPct)
return
}
func
subtractAndConvertTicks
(
first
uint64
,
second
uint64
)
float64
{
return
float64
(
first
-
second
)
}
func
getCPUAverage
(
first
CPUSample
,
second
CPUSample
)
(
avg
CPUAverage
)
{
dTot
:=
float64
(
second
.
Total
-
first
.
Total
)
invQuotient
:=
100.00
/
dTot
avg
.
UserPct
=
subtractAndConvertTicks
(
second
.
User
,
first
.
User
)
*
invQuotient
avg
.
NicePct
=
subtractAndConvertTicks
(
second
.
Nice
,
first
.
Nice
)
*
invQuotient
avg
.
SystemPct
=
subtractAndConvertTicks
(
second
.
System
,
first
.
System
)
*
invQuotient
avg
.
IdlePct
=
subtractAndConvertTicks
(
second
.
Idle
,
first
.
Idle
)
*
invQuotient
avg
.
IowaitPct
=
subtractAndConvertTicks
(
second
.
Iowait
,
first
.
Iowait
)
*
invQuotient
avg
.
IrqPct
=
subtractAndConvertTicks
(
second
.
Irq
,
first
.
Irq
)
*
invQuotient
avg
.
SoftIrqPct
=
subtractAndConvertTicks
(
second
.
SoftIrq
,
first
.
SoftIrq
)
*
invQuotient
avg
.
StealPct
=
subtractAndConvertTicks
(
second
.
Steal
,
first
.
Steal
)
*
invQuotient
avg
.
GuestPct
=
subtractAndConvertTicks
(
second
.
Guest
,
first
.
Guest
)
*
invQuotient
avg
.
Time
=
second
.
Time
avg
.
Seconds
=
second
.
Time
.
Sub
(
first
.
Time
)
.
Seconds
()
return
}
func
getProcCPUAverage
(
first
ProcCPUSample
,
second
ProcCPUSample
,
procUptime
float64
)
(
avg
ProcCPUAverage
)
{
dT
:=
second
.
Time
.
Sub
(
first
.
Time
)
.
Seconds
()
avg
.
UserPct
=
100
*
(
second
.
User
-
first
.
User
)
/
dT
avg
.
SystemPct
=
100
*
(
second
.
System
-
first
.
System
)
/
dT
avg
.
TotalPct
=
100
*
(
second
.
Total
-
first
.
Total
)
/
dT
avg
.
PossiblePct
=
100.0
*
float64
(
runtime
.
NumCPU
())
avg
.
CumulativeTotalPct
=
100
*
second
.
Total
/
procUptime
avg
.
Time
=
second
.
Time
avg
.
Seconds
=
dT
return
}
func
parseCPUFields
(
fields
[]
string
,
stat
*
CPUSample
)
{
numFields
:=
len
(
fields
)
stat
.
Name
=
fields
[
0
]
for
i
:=
1
;
i
<
numFields
;
i
++
{
val
,
numerr
:=
strconv
.
ParseUint
(
fields
[
i
],
10
,
64
)
if
numerr
!=
nil
{
log
.
Println
(
"systemstat.parseCPUFields(): Error parsing (field, value): "
,
i
,
fields
[
i
])
}
stat
.
Total
+=
val
switch
i
{
case
1
:
stat
.
User
=
val
case
2
:
stat
.
Nice
=
val
case
3
:
stat
.
System
=
val
case
4
:
stat
.
Idle
=
val
case
5
:
stat
.
Iowait
=
val
case
6
:
stat
.
Irq
=
val
case
7
:
stat
.
SoftIrq
=
val
case
8
:
stat
.
Steal
=
val
case
9
:
stat
.
Guest
=
val
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment