Skip to content

Commit

Permalink
feat(agent): extends /node_info response with storage_size.
Browse files Browse the repository at this point in the history
This extends agent `/node_info` response with `stroage_size` and
`data_directory` fields.
  • Loading branch information
VAveryanov8 committed Jan 3, 2025
1 parent a62bfac commit e67f38d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/cmd/agent/nodeinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"runtime"

"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
"golang.org/x/sys/unix"
)
Expand All @@ -17,9 +18,16 @@ func (h *nodeInfoHandler) sysInfo(info *scyllaclient.NodeInfo) error {
return err
}

var statfs unix.Statfs_t
if err := unix.Statfs(info.DataDirectory, &statfs); err != nil {
return errors.Wrap(err, "statfs")
}
total := statfs.Blocks * uint64(statfs.Bsize)

info.MemoryTotal = int64(si.Totalram)
info.CPUCount = int64(runtime.NumCPU())
info.Uptime = si.Uptime
info.StorageSize = total

return nil
}
1 change: 1 addition & 0 deletions pkg/cmd/agent/nodeinfo_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ func (h *nodeInfoHandler) sysInfo(info *scyllaclient.NodeInfo) error {
info.MemoryTotal = 0
info.CPUCount = 0
info.Uptime = 0
info.StorageSize = 0
return nil
}
1 change: 1 addition & 0 deletions pkg/scyllaclient/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (c *ConfigClient) NodeInfo(ctx context.Context) (*NodeInfo, error) {
{Field: &ni.AlternatorAddress, Fetcher: c.AlternatorAddress},
{Field: &ni.AlternatorPort, Fetcher: c.AlternatorPort},
{Field: &ni.AlternatorHTTPSPort, Fetcher: c.AlternatorHTTPSPort},
{Field: &ni.DataDirectory, Fetcher: c.DataDirectory},
}

for i, ff := range ffs {
Expand Down

0 comments on commit e67f38d

Please sign in to comment.