summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-02-06 18:14:56 -0800
committerVito Caputo <vcaputo@pengaru.com>2022-02-06 18:19:53 -0800
commitc0cd48a1a6f5c9f4592f5ce215df9c798cb4720a (patch)
tree0b1beae4c9abe02e0ecd4e98775c676726307643 /src
parent0c9563656ce00b0ad2608ec9b81301080be163dc (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')
-rw-r--r--src/vmon.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/vmon.c b/src/vmon.c
index 7d0a5f7..59f89ad 100644
--- a/src/vmon.c
+++ b/src/vmon.c
@@ -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;
© All Rights Reserved