Skip to content

Commit

Permalink
refactor(linux): ♻️ fix function name
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Apr 19, 2024
1 parent ceac087 commit 20b7fee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/linux/disk/diskRates.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func newDevice(dev string) *sensors {

func IOUpdater(ctx context.Context) chan sensor.Details {
sensorCh := make(chan sensor.Details)
newStats, err := diskstats.ReadDiskstats()
newStats, err := diskstats.ReadDiskStats()
if err != nil {
log.Warn().Err(err).Msg("Error reading disk stats from procfs. Will not send disk rate sensors.")
close(sensorCh)
Expand All @@ -156,18 +156,21 @@ func IOUpdater(ctx context.Context) chan sensor.Details {
devices[dev] = newDevice(dev)
}
diskIOstats := func(delta time.Duration) {
newStats, err := diskstats.ReadDiskstats()
newStats, err := diskstats.ReadDiskStats()
if err != nil {
log.Warn().Err(err).Msg("Error reading disk stats from procfs.")
}
for dev, stats := range newStats {
// add any new devices
if _, ok := devices[dev]; !ok {
devices[dev] = newDevice(dev)
}
// update the stats for this device
devices[dev].totalReads.update(stats, delta)
devices[dev].totalWrites.update(stats, delta)
devices[dev].readRate.update(stats, delta)
devices[dev].writeRate.update(stats, delta)
// send the stats to Home Assistant
go func(d string) {
sensorCh <- devices[d].totalReads
}(dev)
Expand Down

0 comments on commit 20b7fee

Please sign in to comment.