diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2022-02-06 18:14:56 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2022-02-06 18:19:53 -0800 |
commit | c0cd48a1a6f5c9f4592f5ce215df9c798cb4720a (patch) | |
tree | 0b1beae4c9abe02e0ecd4e98775c676726307643 /src/vmon.c | |
parent | 0c9563656ce00b0ad2608ec9b81301080be163dc (diff) |
vmon: add %P fmt specifier for getpid()
vmon already handles SIGUSR1 for producing png snapshots on
demand, adding a fmt specifier for substituting the vmon PID
makes for convenient scripting of triggering such snapshots.
i.e:
$ vmon -- /bin/bash -c 'for((i = 0; i < 10; i++)); do kill -USR1 %P; sleep 1s; done'
Would produce ten png snapshots of the charts on 1-second
intervals.
Diffstat (limited to 'src/vmon.c')
-rw-r--r-- | src/vmon.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -345,6 +345,11 @@ static char * arg_interpolate(const vmon_t *vmon, const char *arg) fprintf(memfp, "%s", vmon->output_dir); break; + case 'P': /* getpid() of vmon, convenient for triggering png snapshots on SIGUSR1 */ + /* XXX: note this assumes arg_interpolate() occurs pre-fork, true ATM */ + fprintf(memfp, "%li", (long)getpid()); + break; + case '%': /* literal % */ fputc(c, memfp); break; |