control: use 'linux-inspect'

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyu-Ho Lee 2017-05-09 19:08:48 -07:00
parent d8bc2ec2c2
commit 710d30d1c2
1 changed files with 13 additions and 10 deletions

View File

@ -24,8 +24,11 @@ import (
"github.com/coreos/dbtester" "github.com/coreos/dbtester"
"github.com/coreos/dbtester/dbtesterpb" "github.com/coreos/dbtester/dbtesterpb"
"github.com/coreos/dbtester/pkg/ntp" "github.com/coreos/dbtester/pkg/ntp"
"github.com/coreos/etcd/pkg/netutil" "github.com/coreos/etcd/pkg/netutil"
"github.com/gyuho/linux-inspect/psn" "github.com/gyuho/linux-inspect/df"
"github.com/gyuho/linux-inspect/inspect"
"github.com/gyuho/linux-inspect/top"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -42,7 +45,7 @@ var diskDevice string
var networkInterface string var networkInterface string
func init() { func init() {
dn, err := psn.GetDevice("/") dn, err := df.GetDevice("/")
if err != nil { if err != nil {
plog.Warningf("cannot get disk device mounted at '/' (%v)", err) plog.Warningf("cannot get disk device mounted at '/' (%v)", err)
} }
@ -92,13 +95,13 @@ func commandFunc(cmd *cobra.Command, args []string) error {
if err = os.RemoveAll(cfg.ConfigClientMachineInitial.ClientSystemMetricsPath); err != nil { if err = os.RemoveAll(cfg.ConfigClientMachineInitial.ClientSystemMetricsPath); err != nil {
return err return err
} }
tcfg := &psn.TopConfig{ tcfg := &top.Config{
Exec: psn.DefaultTopPath, Exec: top.DefaultExecPath,
IntervalSecond: 1, IntervalSecond: 1,
PID: pid, PID: pid,
} }
var metricsCSV *psn.CSV var metricsCSV *inspect.CSV
metricsCSV, err = psn.NewCSV( metricsCSV, err = inspect.NewCSV(
cfg.ConfigClientMachineInitial.ClientSystemMetricsPath, cfg.ConfigClientMachineInitial.ClientSystemMetricsPath,
pid, pid,
diskDevice, diskDevice,
@ -116,7 +119,7 @@ func commandFunc(cmd *cobra.Command, args []string) error {
select { select {
case <-time.After(time.Second): case <-time.After(time.Second):
if err := metricsCSV.Add(); err != nil { if err := metricsCSV.Add(); err != nil {
plog.Errorf("psn.CSV.Add error (%v)", err) plog.Errorf("inspect.CSV.Add error (%v)", err)
continue continue
} }
@ -124,18 +127,18 @@ func commandFunc(cmd *cobra.Command, args []string) error {
plog.Infof("finishing collecting system metrics; saving CSV at %q", cfg.ConfigClientMachineInitial.ClientSystemMetricsPath) plog.Infof("finishing collecting system metrics; saving CSV at %q", cfg.ConfigClientMachineInitial.ClientSystemMetricsPath)
if err := metricsCSV.Save(); err != nil { if err := metricsCSV.Save(); err != nil {
plog.Errorf("psn.CSV.Save(%q) error %v", metricsCSV.FilePath, err) plog.Errorf("inspect.CSV.Save(%q) error %v", metricsCSV.FilePath, err)
} else { } else {
plog.Infof("CSV saved at %q", metricsCSV.FilePath) plog.Infof("CSV saved at %q", metricsCSV.FilePath)
} }
interpolated, err := metricsCSV.Interpolate() interpolated, err := metricsCSV.Interpolate()
if err != nil { if err != nil {
plog.Fatalf("psn.CSV.Interpolate(%q) failed with %v", metricsCSV.FilePath, err) plog.Fatalf("inspect.CSV.Interpolate(%q) failed with %v", metricsCSV.FilePath, err)
} }
interpolated.FilePath = cfg.ConfigClientMachineInitial.ClientSystemMetricsInterpolatedPath interpolated.FilePath = cfg.ConfigClientMachineInitial.ClientSystemMetricsInterpolatedPath
if err := interpolated.Save(); err != nil { if err := interpolated.Save(); err != nil {
plog.Errorf("psn.CSV.Save(%q) error %v", interpolated.FilePath, err) plog.Errorf("inspect.CSV.Save(%q) error %v", interpolated.FilePath, err)
} else { } else {
plog.Infof("CSV saved at %q", interpolated.FilePath) plog.Infof("CSV saved at %q", interpolated.FilePath)
} }