Skip to content

Commit ef5b236

Browse files
Fix: #46 Inode Usage metrics (#56)
* Fix: #46 Inode Usage metrics * fix duplicate fields and formatting --------- Co-authored-by: Mert Şişmanoğlu <[email protected]>
1 parent aadedfb commit ef5b236

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

internal/metric/disk.go

+19-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ import (
1010
func CollectDiskMetrics() (MetricsSlice, []CustomErr) {
1111
defaultDiskData := []*DiskData{
1212
{
13-
Device: "unknown",
14-
TotalBytes: nil,
15-
FreeBytes: nil,
16-
ReadBytes: nil,
17-
WriteBytes: nil,
18-
ReadTime: nil,
19-
WriteTime: nil,
20-
UsagePercent: nil,
13+
Device: "unknown",
14+
TotalBytes: nil,
15+
FreeBytes: nil,
16+
UsedBytes: nil,
17+
ReadBytes: nil,
18+
WriteBytes: nil,
19+
ReadTime: nil,
20+
WriteTime: nil,
21+
UsagePercent: nil,
22+
TotalInodes: nil,
23+
FreeInodes: nil,
24+
UsedInodes: nil,
25+
InodesUsagePercent: nil,
2126
},
2227
}
2328
var diskErrors []CustomErr
@@ -67,12 +72,18 @@ func CollectDiskMetrics() (MetricsSlice, []CustomErr) {
6772
metricsSlice = append(metricsSlice, &DiskData{
6873
Device: p.Device,
6974
TotalBytes: &diskUsage.Total,
75+
UsedBytes: &diskUsage.Used,
7076
FreeBytes: &diskUsage.Free,
7177
ReadBytes: &stats.ReadBytes,
7278
WriteBytes: &stats.WriteBytes,
7379
ReadTime: &stats.ReadTime,
7480
WriteTime: &stats.WriteTime,
7581
UsagePercent: RoundFloatPtr(diskUsage.UsedPercent/100, 4),
82+
83+
TotalInodes: &diskUsage.InodesTotal,
84+
FreeInodes: &diskUsage.InodesFree,
85+
UsedInodes: &diskUsage.InodesUsed,
86+
InodesUsagePercent: RoundFloatPtr(diskUsage.InodesUsedPercent/100, 4),
7687
})
7788
}
7889

internal/metric/metric.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,19 @@ type MemoryData struct {
6868
func (m MemoryData) isMetric() {}
6969

7070
type DiskData struct {
71-
Device string `json:"device"` // Device
72-
TotalBytes *uint64 `json:"total_bytes"` // Total space of device in bytes
73-
FreeBytes *uint64 `json:"free_bytes"` // Free space of device in bytes
74-
ReadBytes *uint64 `json:"read_bytes"` // Amount of data read from the disk in bytes
75-
WriteBytes *uint64 `json:"write_bytes"` // Amount of data written to the disk in bytes
76-
ReadTime *uint64 `json:"read_time"` // Cumulative time spent performing read operations
77-
WriteTime *uint64 `json:"write_time"` // Cumulative time spent performing write operations
78-
UsagePercent *float64 `json:"usage_percent"` // Usage Percent of device
71+
Device string `json:"device"` // Device
72+
TotalBytes *uint64 `json:"total_bytes"` // Total space of device in bytes
73+
FreeBytes *uint64 `json:"free_bytes"` // Free space of device in bytes
74+
UsedBytes *uint64 `json:"used_bytes"` // Used space of device in bytes
75+
UsagePercent *float64 `json:"usage_percent"` // Usage percent of device
76+
TotalInodes *uint64 `json:"total_inodes"` // Total space of device in inodes
77+
FreeInodes *uint64 `json:"free_inodes"` // Free space of device in inodes
78+
UsedInodes *uint64 `json:"used_inodes"` // Used space of device in inodes
79+
InodesUsagePercent *float64 `json:"inodes_usage_percent"` // Usage percent of device in inodes
80+
ReadBytes *uint64 `json:"read_bytes"` // Amount of data read from the disk in bytes
81+
WriteBytes *uint64 `json:"write_bytes"` // Amount of data written to the disk in bytes
82+
ReadTime *uint64 `json:"read_time"` // Cumulative time spent performing read operations
83+
WriteTime *uint64 `json:"write_time"` // Cumulative time spent performing write operations
7984
}
8085

8186
func (d DiskData) isMetric() {}

0 commit comments

Comments
 (0)