Skip to content

Commit

Permalink
Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mshahzeb committed Jul 15, 2024
1 parent 17250da commit 1e6892d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
24 changes: 12 additions & 12 deletions blockdevice/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ type BlockQueueStats struct {

type IODeviceStats struct {
IODoneCount uint64
IOErrCount uint64
IOErrCount uint64
}

// DeviceMapperInfo models the devicemapper files that are located in the sysfs tree for each block device
Expand Down Expand Up @@ -486,20 +486,20 @@ func (fs FS) SysBlockDeviceUnderlyingDevices(device string) (UnderlyingDeviceInf
// IO error count: /sys/block/<disk>/device/ioerr_cnt
func (fs FS) SysBlockDeviceIOStat(device string) (IODeviceStats, error) {
var (
ioDeviceStats IODeviceStats
err error
ioDeviceStats IODeviceStats
err error
)
for file, p := range map[string]*uint64{
"iodone_cnt": &ioDeviceStats.IODoneCount,
"ioerr_cnt": &ioDeviceStats.IOErrCount,
"iodone_cnt": &ioDeviceStats.IODoneCount,
"ioerr_cnt": &ioDeviceStats.IOErrCount,
} {
var val uint64
val, err = util.ReadHexFromFile(fs.sys.Path(sysBlockPath, device, sysDevicePath, file))
if err != nil {
return IODeviceStats{}, err
} else {
*p = val
}
var val uint64
val, err = util.ReadHexFromFile(fs.sys.Path(sysBlockPath, device, sysDevicePath, file))
if err != nil {
return IODeviceStats{}, err
} else {
*p = val
}
}
return ioDeviceStats, nil
}
38 changes: 19 additions & 19 deletions ext4/ext4.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ package ext4

import (
"fmt"
"strings"
"path/filepath"
"strings"

"github.com/prometheus/procfs/internal/fs"
"github.com/prometheus/procfs/internal/util"
)

const (
sysFSPath = "fs"
sysFSExt4Path = "ext4"
sysFSPath = "fs"
sysFSExt4Path = "ext4"
)

// Stats contains statistics for a single Btrfs filesystem.
// See Linux fs/btrfs/sysfs.c for more information.
type Stats struct {
Name string
Name string

Errors uint64
Warnings uint64
Messages uint64
Errors uint64
Warnings uint64
Messages uint64
}

// FS represents the pseudo-filesystems proc and sys, which provides an
Expand Down Expand Up @@ -74,8 +74,8 @@ func NewFS(procMountPoint string, sysMountPoint string) (FS, error) {
// ProcStat returns stats for the filesystem.
func (fs FS) ProcStat() ([]*Stats, error) {
matches, err := filepath.Glob(fs.sys.Path("fs/ext4/*"))
if (err != nil) {
return nil, err
if err != nil {
return nil, err
}

stats := make([]*Stats, 0, len(matches))
Expand All @@ -86,17 +86,17 @@ func (fs FS) ProcStat() ([]*Stats, error) {
name := filepath.Base(m)
s.Name = name
for file, p := range map[string]*uint64{
"errors_count": &s.Errors,
"warning_count": &s.Warnings,
"msg_count": &s.Messages,
"errors_count": &s.Errors,
"warning_count": &s.Warnings,
"msg_count": &s.Messages,
} {
var val uint64
val, err = util.ReadUintFromFile(fs.sys.Path(sysFSPath, sysFSExt4Path, name, file))
if err != nil {
fmt.Errorf("failed to read ext4 stats from %s: %w", file, err)
} else {
*p = val
}
var val uint64
val, err = util.ReadUintFromFile(fs.sys.Path(sysFSPath, sysFSExt4Path, name, file))
if err != nil {
fmt.Errorf("failed to read ext4 stats from %s: %w", file, err)
} else {
*p = val
}
}

stats = append(stats, s)
Expand Down
2 changes: 1 addition & 1 deletion internal/util/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func ParseBool(b string) *bool {
func ReadHexFromFile(path string) (uint64, error) {
data, err := os.ReadFile(path)
if err != nil {
return 0, err
return 0, err
}
return strconv.ParseUint(strings.TrimSpace(string(data[2:])), 16, 64)
}

0 comments on commit 1e6892d

Please sign in to comment.