mirror of https://github.com/etcd-io/dbtester.git
agent: add 'client-num-path' flag
This commit is contained in:
parent
8bf6823dca
commit
ffbb2bdf0c
|
|
@ -46,6 +46,7 @@ type flags struct {
|
|||
grpcPort string
|
||||
diskDevice string
|
||||
networkInterface string
|
||||
clientNumPath string
|
||||
}
|
||||
|
||||
var globalFlags flags
|
||||
|
|
@ -79,6 +80,7 @@ func init() {
|
|||
Command.PersistentFlags().StringVar(&globalFlags.grpcPort, "agent-port", ":3500", "Port to server agent gRPC server.")
|
||||
Command.PersistentFlags().StringVar(&globalFlags.diskDevice, "disk-device", dn, "Disk device to collect disk statistics metrics from.")
|
||||
Command.PersistentFlags().StringVar(&globalFlags.networkInterface, "network-interface", nt, "Network interface to record in/outgoing packets.")
|
||||
Command.PersistentFlags().StringVar(&globalFlags.clientNumPath, "client-num-path", filepath.Join(homeDir(), "client-num"), "File path to store client number.")
|
||||
}
|
||||
|
||||
// Command implements 'agent' command.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ type transporterServer struct {
|
|||
|
||||
databaseLogFile *os.File
|
||||
proxyDatabaseLogfile *os.File
|
||||
etcdClientNumPath string
|
||||
clientNumPath string
|
||||
|
||||
cmd *exec.Cmd
|
||||
pid int64
|
||||
|
|
@ -60,10 +59,10 @@ func NewServer() agentpb.TransporterServer {
|
|||
signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
return &transporterServer{
|
||||
etcdClientNumPath: filepath.Join(homeDir(), "etcd-client-num"),
|
||||
uploadSig: make(chan struct{}, 1),
|
||||
csvReady: make(chan struct{}),
|
||||
notifier: notifier,
|
||||
clientNumPath: globalFlags.clientNumPath,
|
||||
uploadSig: make(chan struct{}, 1),
|
||||
csvReady: make(chan struct{}),
|
||||
notifier: notifier,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +229,7 @@ func (t *transporterServer) Transfer(ctx context.Context, r *agentpb.Request) (*
|
|||
}
|
||||
|
||||
case agentpb.Request_Heartbeat:
|
||||
if err := toFile(fmt.Sprintf("%d", t.req.ClientNum), t.etcdClientNumPath); err != nil {
|
||||
if err := toFile(fmt.Sprintf("%d", t.req.ClientNum), t.clientNumPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ func startMetrics(fs *flags, t *transporterServer) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := toFile(fmt.Sprintf("%d", t.req.ClientNum), t.etcdClientNumPath); err != nil {
|
||||
if err := toFile(fmt.Sprintf("%d", t.req.ClientNum), t.clientNumPath); err != nil {
|
||||
return err
|
||||
}
|
||||
c := psn.NewCSV(fs.systemMetricsLog, t.pid, fs.diskDevice, fs.networkInterface, t.etcdClientNumPath)
|
||||
c := psn.NewCSV(fs.systemMetricsLog, t.pid, fs.diskDevice, fs.networkInterface, t.clientNumPath)
|
||||
if err := c.Add(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue