@ -19,6 +19,7 @@ package cmd
import (
import (
"context"
"context"
"fmt"
"net/http"
"net/http"
"os"
"os"
"sync"
"sync"
@ -41,7 +42,7 @@ func getLocalCPUInfo(ctx context.Context, r *http.Request) madmin.ServerCPUInfo
if err != nil {
if err != nil {
return madmin . ServerCPUInfo {
return madmin . ServerCPUInfo {
Addr : addr ,
Addr : addr ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "info: %v" , err ) ,
}
}
}
}
@ -49,7 +50,7 @@ func getLocalCPUInfo(ctx context.Context, r *http.Request) madmin.ServerCPUInfo
if err != nil {
if err != nil {
return madmin . ServerCPUInfo {
return madmin . ServerCPUInfo {
Addr : addr ,
Addr : addr ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "times: %v" , err ) ,
}
}
}
}
@ -72,7 +73,7 @@ func getLocalDrives(ctx context.Context, parallel bool, endpointServerPools Endp
// Since this drive is not available, add relevant details and proceed
// Since this drive is not available, add relevant details and proceed
drivesPerfInfo = append ( drivesPerfInfo , madmin . DrivePerfInfo {
drivesPerfInfo = append ( drivesPerfInfo , madmin . DrivePerfInfo {
Path : endpoint . Path ,
Path : endpoint . Path ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "stat: %v" , err ) ,
} )
} )
continue
continue
}
}
@ -84,7 +85,7 @@ func getLocalDrives(ctx context.Context, parallel bool, endpointServerPools Endp
}
}
latency , throughput , err := disk . GetHealthInfo ( ctx , path , pathJoin ( path , measurePath ) )
latency , throughput , err := disk . GetHealthInfo ( ctx , path , pathJoin ( path , measurePath ) )
if err != nil {
if err != nil {
driveInfo . Error = err . Error ( )
driveInfo . Error = fmt . Sprintf ( "health-info: %v" , err )
} else {
} else {
driveInfo . Latency = latency
driveInfo . Latency = latency
driveInfo . Throughput = throughput
driveInfo . Throughput = throughput
@ -129,7 +130,7 @@ func getLocalMemInfo(ctx context.Context, r *http.Request) madmin.ServerMemInfo
if err != nil {
if err != nil {
return madmin . ServerMemInfo {
return madmin . ServerMemInfo {
Addr : addr ,
Addr : addr ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "swap: %v" , err ) ,
}
}
}
}
@ -137,7 +138,7 @@ func getLocalMemInfo(ctx context.Context, r *http.Request) madmin.ServerMemInfo
if err != nil {
if err != nil {
return madmin . ServerMemInfo {
return madmin . ServerMemInfo {
Addr : addr ,
Addr : addr ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "virtual-mem: %v" , err ) ,
}
}
}
}
@ -154,23 +155,20 @@ func getLocalProcInfo(ctx context.Context, r *http.Request) madmin.ServerProcInf
addr = GetLocalPeer ( globalEndpoints )
addr = GetLocalPeer ( globalEndpoints )
}
}
errProcInfo := func ( err error ) madmin . ServerProcInfo {
errProcInfo := func ( tag string , err error ) madmin . ServerProcInfo {
return madmin . ServerProcInfo {
return madmin . ServerProcInfo {
Addr : addr ,
Addr : addr ,
Error : err . Error ( ) ,
Error : fmt . Sprintf ( "%s: %v" , tag , err ) ,
}
}
}
}
selfPid := int32 ( syscall . Getpid ( ) )
selfPid := int32 ( syscall . Getpid ( ) )
self , err := process . NewProcess ( selfPid )
self , err := process . NewProcess ( selfPid )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "new-process" , err )
}
}
processes := [ ] * process . Process { self }
processes := [ ] * process . Process { self }
if err != nil {
return errProcInfo ( err )
}
sysProcs := [ ] madmin . SysProcess { }
sysProcs := [ ] madmin . SysProcess { }
for _ , proc := range processes {
for _ , proc := range processes {
@ -179,13 +177,13 @@ func getLocalProcInfo(ctx context.Context, r *http.Request) madmin.ServerProcInf
bg , err := proc . BackgroundWithContext ( ctx )
bg , err := proc . BackgroundWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "background" , err )
}
}
sysProc . Background = bg
sysProc . Background = bg
cpuPercent , err := proc . CPUPercentWithContext ( ctx )
cpuPercent , err := proc . CPUPercentWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "cpu-percent" , err )
}
}
sysProc . CPUPercent = cpuPercent
sysProc . CPUPercent = cpuPercent
@ -196,109 +194,109 @@ func getLocalProcInfo(ctx context.Context, r *http.Request) madmin.ServerProcInf
}
}
cmdLine , err := proc . CmdlineWithContext ( ctx )
cmdLine , err := proc . CmdlineWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "cmdline" , err )
}
}
sysProc . CmdLine = cmdLine
sysProc . CmdLine = cmdLine
conns , err := proc . ConnectionsWithContext ( ctx )
conns , err := proc . ConnectionsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "conns" , err )
}
}
sysProc . Connections = conns
sysProc . Connections = conns
createTime , err := proc . CreateTimeWithContext ( ctx )
createTime , err := proc . CreateTimeWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "create-time" , err )
}
}
sysProc . CreateTime = createTime
sysProc . CreateTime = createTime
cwd , err := proc . CwdWithContext ( ctx )
cwd , err := proc . CwdWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "cwd" , err )
}
}
sysProc . Cwd = cwd
sysProc . Cwd = cwd
exe , err := proc . ExeWithContext ( ctx )
exe , err := proc . ExeWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "exe" , err )
}
}
sysProc . Exe = exe
sysProc . Exe = exe
gids , err := proc . GidsWithContext ( ctx )
gids , err := proc . GidsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "gids" , err )
}
}
sysProc . Gids = gids
sysProc . Gids = gids
ioCounters , err := proc . IOCountersWithContext ( ctx )
ioCounters , err := proc . IOCountersWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "iocounters" , err )
}
}
sysProc . IOCounters = ioCounters
sysProc . IOCounters = ioCounters
isRunning , err := proc . IsRunningWithContext ( ctx )
isRunning , err := proc . IsRunningWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "is-running" , err )
}
}
sysProc . IsRunning = isRunning
sysProc . IsRunning = isRunning
memInfo , err := proc . MemoryInfoWithContext ( ctx )
memInfo , err := proc . MemoryInfoWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "mem-info" , err )
}
}
sysProc . MemInfo = memInfo
sysProc . MemInfo = memInfo
memMaps , err := proc . MemoryMapsWithContext ( ctx , true )
memMaps , err := proc . MemoryMapsWithContext ( ctx , true )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "mem-maps" , err )
}
}
sysProc . MemMaps = memMaps
sysProc . MemMaps = memMaps
memPercent , err := proc . MemoryPercentWithContext ( ctx )
memPercent , err := proc . MemoryPercentWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "mem-percent" , err )
}
}
sysProc . MemPercent = memPercent
sysProc . MemPercent = memPercent
name , err := proc . NameWithContext ( ctx )
name , err := proc . NameWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "name" , err )
}
}
sysProc . Name = name
sysProc . Name = name
netIOCounters , err := proc . NetIOCountersWithContext ( ctx , false )
netIOCounters , err := proc . NetIOCountersWithContext ( ctx , false )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "netio-counters" , err )
}
}
sysProc . NetIOCounters = netIOCounters
sysProc . NetIOCounters = netIOCounters
nice , err := proc . NiceWithContext ( ctx )
nice , err := proc . NiceWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "nice" , err )
}
}
sysProc . Nice = nice
sysProc . Nice = nice
numCtxSwitches , err := proc . NumCtxSwitchesWithContext ( ctx )
numCtxSwitches , err := proc . NumCtxSwitchesWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "num-ctx-switches" , err )
}
}
sysProc . NumCtxSwitches = numCtxSwitches
sysProc . NumCtxSwitches = numCtxSwitches
numFds , err := proc . NumFDsWithContext ( ctx )
numFds , err := proc . NumFDsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "num-fds" , err )
}
}
sysProc . NumFds = numFds
sysProc . NumFds = numFds
numThreads , err := proc . NumThreadsWithContext ( ctx )
numThreads , err := proc . NumThreadsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "num-threads" , err )
}
}
sysProc . NumThreads = numThreads
sysProc . NumThreads = numThreads
pageFaults , err := proc . PageFaultsWithContext ( ctx )
pageFaults , err := proc . PageFaultsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "page-faults" , err )
}
}
sysProc . PageFaults = pageFaults
sysProc . PageFaults = pageFaults
@ -314,37 +312,37 @@ func getLocalProcInfo(ctx context.Context, r *http.Request) madmin.ServerProcInf
rlimit , err := proc . RlimitWithContext ( ctx )
rlimit , err := proc . RlimitWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "rlimit" , err )
}
}
sysProc . Rlimit = rlimit
sysProc . Rlimit = rlimit
status , err := proc . StatusWithContext ( ctx )
status , err := proc . StatusWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "status" , err )
}
}
sysProc . Status = status
sysProc . Status = status
tgid , err := proc . Tgid ( )
tgid , err := proc . Tgid ( )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "tgid" , err )
}
}
sysProc . Tgid = tgid
sysProc . Tgid = tgid
times , err := proc . TimesWithContext ( ctx )
times , err := proc . TimesWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "times" , err )
}
}
sysProc . Times = times
sysProc . Times = times
uids , err := proc . UidsWithContext ( ctx )
uids , err := proc . UidsWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "uids" , err )
}
}
sysProc . Uids = uids
sysProc . Uids = uids
username , err := proc . UsernameWithContext ( ctx )
username , err := proc . UsernameWithContext ( ctx )
if err != nil {
if err != nil {
return errProcInfo ( err )
return errProcInfo ( "username" , err )
}
}
sysProc . Username = username
sysProc . Username = username