2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/tools/munin-node-c/main.c
2013-02-09 13:16:41 +01:00

59 lines
1.1 KiB
C

#include <libgen.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
char VERSION[] = "1.0.0";
int verbose;
char* host = "";
char* plugin_dir = "plugins";
char* spoolfetch_dir = "";
int main(int argc, char *argv[]) {
int optch;
extern int opterr;
int optarg_len;
char format[] = "vd:h:s:";
opterr = 1;
while ((optch = getopt(argc, argv, format)) != -1)
switch (optch) {
case 'v':
verbose ++;
break;
case 'd':
optarg_len = strlen(optarg);
plugin_dir = (char *) malloc(optarg_len + 1);
strcpy(plugin_dir, optarg);
break;
case 'h':
optarg_len = strlen(optarg);
host = (char *) malloc(optarg_len + 1);
strcpy(host, optarg);
break;
case 's':
optarg_len = strlen(optarg);
spoolfetch_dir = (char *) malloc(optarg_len + 1);
strcpy(spoolfetch_dir, optarg);
break;
}
/* get default hostname if not precised */
if (! strlen(host)) {
host = (char *) malloc(HOST_NAME_MAX + 1);
gethostname(host, HOST_NAME_MAX);
}
printf("verbose: %d, host: %s, plugin_dir: %s, spoolfetch_dir: %s\n", verbose, host, plugin_dir, spoolfetch_dir);
return 0;
}