Skip to content

Commit a5dd6ae

Browse files
committed
feat(demo): expand the sysmon plugin with core-tool tasks
The demo leaned on sar/vmstat/iostat (the sysstat package, often absent). Add seven menu entries that work out of the box on a stock Debian box, showcasing CCFE form features with sensible defaults: * pstop.form - busiest processes; a sort-order value list (CPU/mem/etime, default -%cpu) + a count (default 15) -> ps aux --sort=... | head * df.form - free disk space; -h/-l default on, a mount-point value list from df, optional -i/-T * du.form - directory usage; path default '.', -h/-x default on, a --max-depth= numeric * ss.form - network sockets; -t/-l/-n default on, optional -u/-p * run items - free -h (memory), uptime, who -H All use coreutils/procps/iproute2 only. Verified: each new object parses (-k), and the F5 action preview resolves the defaults correctly (e.g. 'ps aux --sort=-%cpu | head -n 15', 'df -h -l'). t/07's hard-coded '6 item' count relaxed to a non-zero match so the demo can grow without breaking it (still catches an empty-menu regression). FEATURE-REQUESTS item 7. Full suite green (375). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 45f9a94 commit a5dd6ae

6 files changed

Lines changed: 215 additions & 1 deletion

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# ccfe-plugin-sysmon - free disk space (df). Uses coreutils only.
3+
#
4+
title {
5+
Report free disk space
6+
}
7+
top {
8+
Toggle options with the value list (<F2>); Enter runs the report.
9+
}
10+
field {
11+
id = HUMAN
12+
label = Human-readable sizes (-h)
13+
type = BOOLEAN
14+
default = const:YES
15+
option = -h
16+
}
17+
field {
18+
id = INODES
19+
label = Show inode usage instead of blocks (-i)
20+
type = BOOLEAN
21+
option = -i
22+
htab = 1
23+
}
24+
field {
25+
id = TYPE
26+
label = Print each filesystem's type (-T)
27+
type = BOOLEAN
28+
option = -T
29+
htab = 1
30+
}
31+
field {
32+
id = LOCAL
33+
label = Limit to local filesystems (-l)
34+
type = BOOLEAN
35+
default = const:YES
36+
option = -l
37+
htab = 1
38+
}
39+
field {
40+
id = FS
41+
label = Filesystem or mount point (blank = all)
42+
type = STRING
43+
len = 30
44+
list_cmd = command:single-val:df -P | awk 'NR>1{print $NF}'
45+
vtab = 1
46+
}
47+
action { run:
48+
df%{HUMAN}%{INODES}%{TYPE}%{LOCAL} %{FS}
49+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# ccfe-plugin-sysmon - directory space usage (du). Uses coreutils only.
3+
#
4+
title {
5+
Measure directory space usage
6+
}
7+
top {
8+
Set a directory and options, then press Enter.
9+
}
10+
field {
11+
id = PATH
12+
label = Directory to measure
13+
type = STRING
14+
len = 40
15+
default = const:.
16+
}
17+
field {
18+
id = HUMAN
19+
label = Human-readable sizes (-h)
20+
type = BOOLEAN
21+
default = const:YES
22+
option = -h
23+
vtab = 1
24+
}
25+
field {
26+
id = SUMMARY
27+
label = Show only the grand total (-s)
28+
type = BOOLEAN
29+
option = -s
30+
htab = 1
31+
}
32+
field {
33+
id = ONEFS
34+
label = Stay on one filesystem (-x)
35+
type = BOOLEAN
36+
default = const:YES
37+
option = -x
38+
htab = 1
39+
}
40+
field {
41+
id = DEPTH
42+
label = Limit directory depth (blank = unlimited)
43+
type = NUMERIC
44+
len = 2
45+
option = --max-depth=
46+
vtab = 1
47+
}
48+
action { run:
49+
du%{HUMAN}%{SUMMARY}%{ONEFS} %{DEPTH} %{PATH}
50+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# ccfe-plugin-sysmon - top processes by CPU/memory (ps). Uses procps only.
3+
#
4+
title {
5+
List the busiest processes
6+
}
7+
top {
8+
Pick a sort order (<F2> on the first field) and how many to show.
9+
}
10+
field {
11+
id = SORT
12+
label = Sort processes by
13+
type = STRING
14+
len = 6
15+
list_cmd = const:single-val:"-%cpu : CPU usage (busiest first)","-%mem : memory usage","-etime : elapsed run time"
16+
option = --sort=
17+
default = const:-%cpu
18+
}
19+
field {
20+
id = COUNT
21+
label = Number of processes to list
22+
type = NUMERIC
23+
len = 3
24+
default = const:15
25+
htab = 1
26+
}
27+
action { run:
28+
ps aux %{SORT} | head -n %{COUNT}
29+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# ccfe-plugin-sysmon - network sockets (ss). Uses iproute2 only.
3+
#
4+
title {
5+
Show network sockets
6+
}
7+
top {
8+
Choose which sockets to list, then press Enter.
9+
}
10+
field {
11+
id = TCP
12+
label = TCP sockets (-t)
13+
type = BOOLEAN
14+
default = const:YES
15+
option = -t
16+
}
17+
field {
18+
id = UDP
19+
label = UDP sockets (-u)
20+
type = BOOLEAN
21+
option = -u
22+
htab = 1
23+
}
24+
field {
25+
id = LISTEN
26+
label = Listening sockets only (-l)
27+
type = BOOLEAN
28+
default = const:YES
29+
option = -l
30+
htab = 1
31+
}
32+
field {
33+
id = NUMERIC
34+
label = Numeric output, no name resolution (-n)
35+
type = BOOLEAN
36+
default = const:YES
37+
option = -n
38+
htab = 1
39+
}
40+
field {
41+
id = PROC
42+
label = Show the owning process (-p)
43+
type = BOOLEAN
44+
option = -p
45+
htab = 1
46+
}
47+
action { run:
48+
ss%{TCP}%{UDP}%{LISTEN}%{NUMERIC}%{PROC}
49+
}

src/ccfe-plugin-sysmon/sysmon.menu

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,41 @@ item {
3535
descr = Report current processes
3636
action = run:ps axv
3737
}
38+
item {
39+
id = PSTOP
40+
descr = List the busiest processes (by CPU / memory)
41+
action = form:sysmon.d/pstop
42+
}
43+
item {
44+
id = DF
45+
descr = Report free disk space
46+
action = form:sysmon.d/df
47+
}
48+
item {
49+
id = DU
50+
descr = Measure directory space usage
51+
action = form:sysmon.d/du
52+
}
53+
item {
54+
id = MEM
55+
descr = Show memory and swap usage
56+
action = run:free -h
57+
}
58+
item {
59+
id = SOCKETS
60+
descr = Show network sockets
61+
action = form:sysmon.d/ss
62+
}
63+
item {
64+
id = UPTIME
65+
descr = Show uptime and load average
66+
action = run:uptime
67+
}
68+
item {
69+
id = WHO
70+
descr = Show who is logged in
71+
action = run:who -H
72+
}
3873
item {
3974
id = VMSTAT
4075
descr = Show virtual memory statistics

src/t/07-check-cli.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ like( $o, qr/^OK: menu "demo"/, ' reports OK with kind/name' );
3838
# valid menu (plugin)
3939
( $o, $rc ) = check('sysmon');
4040
is( $rc, 0, 'plugin menu: exit 0' );
41-
like( $o, qr/6 item/, ' reports item count' );
41+
# Non-zero count rather than a hard-coded number, so expanding the demo menu
42+
# does not break the test while still catching an empty/zero-item regression.
43+
like( $o, qr/[1-9][0-9]* item/, ' reports a non-zero item count' );
4244

4345
# valid form inside a .d directory
4446
( $o, $rc ) = check('sysmon.d/sar');

0 commit comments

Comments
 (0)