From bf25714e3ae3956666b34a3e0d18434165f05b3e Mon Sep 17 00:00:00 2001 From: Steve Schnepp Date: Sat, 9 Feb 2013 11:30:00 +0100 Subject: [PATCH] mnc: add config/fetch handler --- tools/munin-node-c/main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/munin-node-c/main.c b/tools/munin-node-c/main.c index e814bb49..4dbae5d2 100644 --- a/tools/munin-node-c/main.c +++ b/tools/munin-node-c/main.c @@ -3,6 +3,7 @@ #include #include #include +#include char VERSION[] = "1.0.0"; @@ -61,7 +62,7 @@ int main(int argc, char *argv[]) { line[LINE_MAX-1] = '\0'; cmd = strtok(line, " \t\n"); - arg = strtok(line, " \t\n"); + arg = strtok(NULL, " \t\n"); if (!cmd || strlen(cmd) == 0) { printf("# empty cmd\n"); @@ -74,8 +75,18 @@ int main(int argc, char *argv[]) { return(0); } else if (strcmp(cmd, "list") == 0) { printf("# not implem yet cmd: %s\n", cmd); - } else if (strcmp(cmd, "config") == 0) { - } else if (strcmp(cmd, "fetch") == 0) { + } else if ( + strcmp(cmd, "config") == 0 || + strcmp(cmd, "fetch") == 0 + ) { + char cmdline[LINE_MAX]; + if (! access(arg, X_OK)) { + printf("# unknown plugin: %s\n", arg); + continue; + } + sprintf(cmdline, "exec %s/%s %s", plugin_dir, arg, cmd); + system(cmdline); + printf(".\n"); } else if (strcmp(cmd, "cap") == 0) { printf("cap "); if (strlen(spoolfetch_dir)) {