Merge pull request #283 from gyuho/psn

*: update 'psn' to fix sector writes issue
This commit is contained in:
Gyu-Ho Lee 2017-02-10 10:14:32 -08:00 committed by GitHub
commit 80150f0aae
6 changed files with 43 additions and 54 deletions

16
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 35875650d8e05eff855d29a77c8ddf25cbb1be878950c57324f680ee3808401a
updated: 2017-02-04T20:30:04.541079683-08:00
hash: c72676a3f341ccf35daeb68dff29447185a314f934512d0318dde5a9b126fb82
updated: 2017-02-10T10:11:34.635182921-08:00
imports:
- name: bitbucket.org/zombiezen/gopdf
version: 1c63dc69751bc45441c2ce1f56b631c55294b4d5
@ -41,7 +41,9 @@ imports:
- name: github.com/coreos/go-systemd
version: 48702e0da86bd25e76cfef347e2adeb434a0d0a6
subpackages:
- daemon
- journal
- util
- name: github.com/coreos/pkg
version: fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8
subpackages:
@ -67,7 +69,7 @@ imports:
- jsonpb
- proto
- name: github.com/gonum/floats
version: b87c65fd450a3f7a8875a16e4b2dbf5556ede4f1
version: a2cbc5c70616cd18491ef2843231f6ce28b2cb02
- name: github.com/gonum/internal
version: aa14b654e75da6e47f3c563fbda889112fe5ac94
subpackages:
@ -98,7 +100,7 @@ imports:
- name: github.com/gyuho/dataframe
version: 73de2c550b1177c1640f3dacbbc1af00f913fedb
- name: github.com/gyuho/psn
version: 04e255d485181cbe8bc9002416a2ad3143f104ba
version: 742983dd45d4fbdd73fdde7701e00fcba9d9d499
subpackages:
- schema
- name: github.com/hashicorp/consul
@ -108,7 +110,7 @@ imports:
- name: github.com/hashicorp/go-cleanhttp
version: ad28ea4487f05916463e2423a55166280e8254b5
- name: github.com/hashicorp/serf
version: 78349c9fd938fca3f149051b8d816cc891c3851f
version: cb45b412ee4f9d6cc2eeb2b2b7dd0f6cfd7545c1
subpackages:
- coordinate
- name: github.com/inconshreveable/mousetrap
@ -157,7 +159,7 @@ imports:
subpackages:
- codec
- name: golang.org/x/image
version: 28d9a8b4a37fa0e5fe8b0cabf09c8b9a0e6ec6f1
version: 05f0a469d9f7c77399b53a6bab80983eb856b52e
subpackages:
- draw
- font
@ -199,7 +201,7 @@ imports:
- storage/v1
- transport
- name: google.golang.org/appengine
version: a2c54d2174c17540446e0ced57d9d459af61bc1c
version: 2e4a801b39fc199db615bfca7d0b9f8cd9580599
subpackages:
- internal
- internal/app_identity

View File

@ -55,7 +55,7 @@ import:
- package: github.com/gyuho/dataframe
version: 73de2c550b1177c1640f3dacbbc1af00f913fedb
- package: github.com/gyuho/psn
version: 04e255d485181cbe8bc9002416a2ad3143f104ba
version: 742983dd45d4fbdd73fdde7701e00fcba9d9d499
- package: github.com/hashicorp/consul
version: 3da73be55c82a7f88f1dfd3ec16d267970ac8ff0
subpackages:

View File

@ -131,11 +131,7 @@ func CumProd(dst, s []float64) []float64 {
if len(dst) == 0 {
return dst
}
dst[0] = s[0]
for i := 1; i < len(s); i++ {
dst[i] = dst[i-1] * s[i]
}
return dst
return f64.CumProd(dst, s)
}
// CumSum finds the cumulative sum of the first i elements in
@ -151,11 +147,7 @@ func CumSum(dst, s []float64) []float64 {
if len(dst) == 0 {
return dst
}
dst[0] = s[0]
for i := 1; i < len(s); i++ {
dst[i] = dst[i-1] + s[i]
}
return dst
return f64.CumSum(dst, s)
}
// Distance computes the L-norm of s - t. See Norm for special cases.
@ -203,9 +195,7 @@ func Div(dst, s []float64) {
if len(dst) != len(s) {
panic("floats: slice lengths do not match")
}
for i, val := range s {
dst[i] /= val
}
f64.Div(dst, s)
}
// DivTo performs element-wise division s / t
@ -215,10 +205,7 @@ func DivTo(dst, s, t []float64) []float64 {
if len(s) != len(t) || len(dst) != len(t) {
panic("floats: slice lengths do not match")
}
for i, val := range t {
dst[i] = s[i] / val
}
return dst
return f64.DivTo(dst, s, t)
}
// Dot computes the dot product of s1 and s2, i.e.

View File

@ -1,6 +1,6 @@
package psn
// updated at 2017-02-03 12:33:47.711425238 -0800 PST
// updated at 2017-02-10 10:04:53.292742581 -0800 PST
// NetDev is '/proc/net/dev' in Linux.
// The dev pseudo-file contains network device status information.
@ -217,14 +217,14 @@ type DiskStat struct {
// TimeSpentOnWritingMs is total number of milliseconds spent by all writes.
TimeSpentOnWritingMs uint64 `column:"time_spent_on_writing_ms"`
TimeSpentOnWritingMsParsedTime string `column:"time_spent_on_writing_ms_parsed_time"`
// IOInProgress is only field that should go to zero (incremented as requests are on request_queue).
IOInProgress uint64 `column:"io_in_progress"`
// TimeSpentOnIOMs is milliseconds spent doing I/Os.
TimeSpentOnIOMs uint64 `column:"time_spent_on_io_ms"`
TimeSpentOnIOMsParsedTime string `column:"time_spent_on_io_ms_parsed_time"`
// WeightedTimeSpentOnIOMs is weighted milliseconds spent doing I/Os (incremented at each I/O start, I/O completion, I/O merge).
WeightedTimeSpentOnIOMs uint64 `column:"weighted_time_spent_on_io_ms"`
WeightedTimeSpentOnIOMsParsedTime string `column:"weighted_time_spent_on_io_ms_parsed_time"`
// IOsInProgress is only field that should go to zero (incremented as requests are on request_queue).
IOsInProgress uint64 `column:"ios_in_progress"`
// TimeSpentOnIOsMs is milliseconds spent doing I/Os.
TimeSpentOnIOsMs uint64 `column:"time_spent_on_ios_ms"`
TimeSpentOnIOsMsParsedTime string `column:"time_spent_on_ios_ms_parsed_time"`
// WeightedTimeSpentOnIOsMs is weighted milliseconds spent doing I/Os (incremented at each I/O start, I/O completion, I/O merge).
WeightedTimeSpentOnIOsMs uint64 `column:"weighted_time_spent_on_ios_ms"`
WeightedTimeSpentOnIOsMsParsedTime string `column:"weighted_time_spent_on_ios_ms_parsed_time"`
}
// IO is '/proc/$PID/io' in Linux.

View File

@ -21,12 +21,12 @@ const (
proc_diskstats_idx_writes_completed
proc_diskstats_idx_writes_merged
proc_diskstats_idx_time_spent_on_writing_ms
proc_diskstats_idx_sectors_written
proc_diskstats_idx_time_spent_on_writing_ms
proc_diskstats_idx_io_in_progress
proc_diskstats_idx_time_spent_on_io_ms
proc_diskstats_idx_weighted_time_spent_on_io_ms
proc_diskstats_idx_ios_in_progress
proc_diskstats_idx_time_spent_on_ios_ms
proc_diskstats_idx_weighted_time_spent_on_ios_ms
)
// GetProcDiskstats reads '/proc/diskstats'.
@ -45,7 +45,7 @@ func GetProcDiskstats() ([]DiskStat, error) {
continue
}
ds := strings.Fields(strings.TrimSpace(txt))
if len(ds) < int(proc_diskstats_idx_weighted_time_spent_on_io_ms+1) {
if len(ds) < int(proc_diskstats_idx_weighted_time_spent_on_ios_ms+1) {
return nil, fmt.Errorf("not enough columns at %v", ds)
}
d := DiskStat{}
@ -114,25 +114,25 @@ func GetProcDiskstats() ([]DiskStat, error) {
d.TimeSpentOnWritingMs = mn
d.TimeSpentOnWritingMsParsedTime = humanizeDurationMs(mn)
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_io_in_progress], 10, 64)
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_ios_in_progress], 10, 64)
if err != nil {
return nil, err
}
d.IOInProgress = mn
d.IOsInProgress = mn
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_time_spent_on_io_ms], 10, 64)
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_time_spent_on_ios_ms], 10, 64)
if err != nil {
return nil, err
}
d.TimeSpentOnIOMs = mn
d.TimeSpentOnIOMsParsedTime = humanizeDurationMs(mn)
d.TimeSpentOnIOsMs = mn
d.TimeSpentOnIOsMsParsedTime = humanizeDurationMs(mn)
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_weighted_time_spent_on_io_ms], 10, 64)
mn, err = strconv.ParseUint(ds[proc_diskstats_idx_weighted_time_spent_on_ios_ms], 10, 64)
if err != nil {
return nil, err
}
d.WeightedTimeSpentOnIOMs = mn
d.WeightedTimeSpentOnIOMsParsedTime = humanizeDurationMs(mn)
d.WeightedTimeSpentOnIOsMs = mn
d.WeightedTimeSpentOnIOsMsParsedTime = humanizeDurationMs(mn)
dss = append(dss, d)
}

View File

@ -211,15 +211,15 @@ var DiskStat = RawData{
{"sectors-written", "total number of sectors written successfully", reflect.Uint64},
{"time-spent-on-writing-ms", "total number of milliseconds spent by all writes", reflect.Uint64},
{"I/O-in-progress", "only field that should go to zero (incremented as requests are on request_queue)", reflect.Uint64},
{"time-spent-on-I/O-ms", "milliseconds spent doing I/Os", reflect.Uint64},
{"weighted-time-spent-on-I/O-ms", "weighted milliseconds spent doing I/Os (incremented at each I/O start, I/O completion, I/O merge)", reflect.Uint64},
{"I/Os-in-progress", "only field that should go to zero (incremented as requests are on request_queue)", reflect.Uint64},
{"time-spent-on-I/Os-ms", "milliseconds spent doing I/Os", reflect.Uint64},
{"weighted-time-spent-on-I/Os-ms", "weighted milliseconds spent doing I/Os (incremented at each I/O start, I/O completion, I/O merge)", reflect.Uint64},
},
ColumnsToParse: map[string]RawDataType{
"time-spent-on-reading-ms": TypeTimeMicroseconds,
"time-spent-on-writing-ms": TypeTimeMicroseconds,
"time-spent-on-I/O-ms": TypeTimeMicroseconds,
"weighted-time-spent-on-I/O-ms": TypeTimeMicroseconds,
"time-spent-on-reading-ms": TypeTimeMicroseconds,
"time-spent-on-writing-ms": TypeTimeMicroseconds,
"time-spent-on-I/Os-ms": TypeTimeMicroseconds,
"weighted-time-spent-on-I/Os-ms": TypeTimeMicroseconds,
},
}