|
1 | 1 | module TerminalSystemMonitor
|
2 | 2 |
|
| 3 | +using Dates: Dates, Day, DateTime, Second |
3 | 4 | using UnicodePlots
|
4 |
| -using Term # this is required by UnicodePlots.panel |
| 5 | +import Term # this is required by UnicodePlots.panel |
5 | 6 |
|
6 | 7 | idle_time(info::Sys.CPUinfo) = Int64(info.cpu_times!idle)
|
7 | 8 |
|
@@ -72,14 +73,30 @@ function layout(x, y)
|
72 | 73 | barplot(x[c], y[c], maximum = 100, width = max(5, 15), height = length(c)),
|
73 | 74 | )
|
74 | 75 | end
|
75 |
| - memoryusage = round((Sys.total_memory() - Sys.free_memory()) / 2^20 / 1000, digits = 1) |
| 76 | + memoryusageGB = round((Sys.total_memory() - Sys.free_memory()) / 2^30, digits = 1) |
| 77 | + memorytotGB = Sys.total_memory() / 2 ^ 30 |
| 78 | + (memorytot, memoryusage, memoryunit) = if memorytotGB ≤ 1.0 |
| 79 | + 1024memorytotGB, 1024memoryusageGB, "MB" |
| 80 | + else |
| 81 | + memorytotGB, memoryusageGB, "GB" |
| 82 | + end |
76 | 83 |
|
| 84 | + seconds = Sys.uptime() |
| 85 | + datetime = DateTime(1970) + Second(seconds) |
77 | 86 | push!(
|
78 | 87 | plts,
|
79 | 88 | barplot(
|
80 | 89 | ["Mem: "],
|
81 | 90 | [memoryusage],
|
82 |
| - maximum = Sys.total_memory() / 2^20 / 1000, |
| 91 | + title= join( |
| 92 | + [ |
| 93 | + "Load average: " * join(string.(round.(Sys.loadavg(), digits=2)),' '), |
| 94 | + " Uptime: $(max(Day(0), Day(datetime)-Day(1))), $(Dates.format(datetime, "HH:MM:SS"))", |
| 95 | + ], |
| 96 | + '\n', |
| 97 | + ), |
| 98 | + name="$(memorytot) $(memoryunit)", |
| 99 | + maximum = Sys.total_memory() / 2^30, |
83 | 100 | width = max(5, 15),
|
84 | 101 | ),
|
85 | 102 | )
|
|
0 commit comments