Skip to content

Commit 5941441

Browse files
committed
Restructure for dir for kbskit
1 parent 0bd09be commit 5941441

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

demo/linuxload.tcl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# display load avg on Linux
2+
3+
package require ukaz
4+
package require fileutil
5+
6+
pack [ukaz::graph .l] -expand yes -fill both
7+
8+
set lastload {0 0}
9+
set time 0
10+
11+
proc newload {} {
12+
variable lastload
13+
variable time
14+
variable graphid
15+
16+
# read current loadavg last 1, 5 and 15 minutes
17+
lassign [fileutil::read /proc/loadavg] l1 l5 l15
18+
19+
incr time
20+
lappend lastload $time $l1
21+
22+
if {[llength $lastload]>1000} {
23+
# for more than 1000 entries, cut it down
24+
set lastload [lrange $lastload end-999 end]
25+
}
26+
.l update $graphid data $lastload
27+
after 500 newload
28+
}
29+
30+
set graphid [.l plot $lastload with lines color red title "CPU load"]
31+
.l set xlabel "Time"
32+
.l set ylabel "Load"
33+
34+
newload
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)