@@ -18,13 +18,13 @@ var memoryCmd = &cobra.Command{
18
18
Use : "memory" ,
19
19
Short : "Submodule to check the current system memory and swap usage" ,
20
20
Example : `check_system_basics memory --memory-available-warning 10:20 --memory-free-critical-percentage 50:80 --memory-used-warning @10 --percentage-in-perfdata --swap-free-warning-percentage @30:31
21
- [WARNING ] - states: warning =1 ok=1
22
- \_ [WARNING]
23
- \_ [WARNING] Available Memory (25 GiB, 78.97 %)
24
- \_ [OK ] Free Memory (20 GiB, 64.22 %)
25
- \_ [OK] Used Memory (4.3 GiB, 13.73 %)
21
+ [CRITICAL ] - states: critical =1 ok=1
22
+ \_ [CRITICAL] RAM
23
+ \_ [WARNING] Available Memory (23 GiB/31 GiB, 74.36 %)
24
+ \_ [CRITICAL ] Free Memory (16 GiB/31 GiB, 49.95 %)
25
+ \_ [OK] Used Memory (6.1 GiB/31 GiB, 19.57 %)
26
26
\_ [OK] Swap Usage 0.00% (0 B / 36 GiB)
27
- |available_memory_percentage=78.975 %;15:100;5:100 available_memory=26401148928B ;10:20;;0;33429860352 free_memory=21468332032B ;;;0;33429860352 free_memory_percentage=64.219 %;;50:80 used_memory=4588732416B ;@10;;0;33429860352 free_memory_percentage=13.726 % swap_usage_percent=0%;20;85 swap_used=0B;;;0;38654701568
27
+ |available_memory_percentage=74.36 %;15:100;5:100 available_memory=24856633344B ;10:20;;0;33427595264 free_memory=16696102912B ;;;0;33427595264 free_memory_percentage=49.947 %;;50:80 used_memory=6542696448B ;@10;;0;33427595264 free_memory_percentage=19.573 % swap_usage_percent=0%;20;85 swap_used=0B;;;0;38654701568
28
28
` ,
29
29
Run : func (cmd * cobra.Command , args []string ) {
30
30
@@ -52,14 +52,19 @@ var memoryCmd = &cobra.Command{
52
52
}
53
53
54
54
func computeMemResults (config * memory.MemConfig , memStats * memory.Mem ) result.PartialResult {
55
- var partialMem result.PartialResult
55
+ partialMem := result.PartialResult {
56
+ Output : "RAM" ,
57
+ }
56
58
_ = partialMem .SetDefaultState (check .OK )
57
59
58
60
// # Available
59
61
var partialMemAvailable result.PartialResult
60
62
_ = partialMemAvailable .SetDefaultState (check .OK )
61
63
62
- partialMemAvailable .Output = fmt .Sprintf ("Available Memory (%s, %.2f%%)" , humanize .IBytes (memStats .VirtMem .Available ), memStats .MemAvailablePercentage )
64
+ partialMemAvailable .Output = fmt .Sprintf ("Available Memory (%s/%s, %.2f%%)" ,
65
+ humanize .IBytes (memStats .VirtMem .Available ),
66
+ humanize .IBytes (memStats .VirtMem .Total ),
67
+ memStats .MemAvailablePercentage )
63
68
64
69
// perfdata
65
70
pdMemAvailable := perfdata.Perfdata {
@@ -140,7 +145,10 @@ func computeMemResults(config *memory.MemConfig, memStats *memory.Mem) result.Pa
140
145
Uom : "%" ,
141
146
}
142
147
143
- partialMemFree .Output = fmt .Sprintf ("Free Memory (%s, %.2f%%)" , humanize .IBytes (memStats .VirtMem .Free ), MemFreePercentage )
148
+ partialMemFree .Output = fmt .Sprintf ("Free Memory (%s/%s, %.2f%%)" ,
149
+ humanize .IBytes (memStats .VirtMem .Free ),
150
+ humanize .IBytes (memStats .VirtMem .Total ),
151
+ MemFreePercentage )
144
152
145
153
if config .MemFree .Warn .IsSet {
146
154
pdMemFree .Warn = & config .MemFree .Warn .Th
@@ -191,7 +199,10 @@ func computeMemResults(config *memory.MemConfig, memStats *memory.Mem) result.Pa
191
199
var partialMemUsed result.PartialResult
192
200
_ = partialMemUsed .SetDefaultState (check .OK )
193
201
194
- partialMemUsed .Output = fmt .Sprintf ("Used Memory (%s, %.2f%%)" , humanize .IBytes (memStats .VirtMem .Used ), memStats .VirtMem .UsedPercent )
202
+ partialMemUsed .Output = fmt .Sprintf ("Used Memory (%s/%s, %.2f%%)" ,
203
+ humanize .IBytes (memStats .VirtMem .Used ),
204
+ humanize .IBytes (memStats .VirtMem .Total ),
205
+ memStats .VirtMem .UsedPercent )
195
206
196
207
pdMemUsed := perfdata.Perfdata {
197
208
Label : "used_memory" ,
0 commit comments