root / tools / munin-node-c / main.c @ acea10b2
Historique | Voir | Annoter | Télécharger (1,71 ko)
| 1 | 52369dbe | Steve Schnepp | #include <libgen.h> |
|---|---|---|---|
| 2 | #include <string.h> |
||
| 3 | #include <stdio.h> |
||
| 4 | #include <unistd.h> |
||
| 5 | #include <limits.h> |
||
| 6 | |||
| 7 | |||
| 8 | char VERSION[] = "1.0.0"; |
||
| 9 | |||
| 10 | int verbose;
|
||
| 11 | |||
| 12 | char* host = ""; |
||
| 13 | char* plugin_dir = "plugins"; |
||
| 14 | char* spoolfetch_dir = ""; |
||
| 15 | |||
| 16 | int main(int argc, char *argv[]) { |
||
| 17 | |||
| 18 | int optch;
|
||
| 19 | extern int opterr; |
||
| 20 | int optarg_len;
|
||
| 21 | |||
| 22 | char format[] = "vd:h:s:"; |
||
| 23 | |||
| 24 | acea10b2 | Steve Schnepp | char line[LINE_MAX];
|
| 25 | |||
| 26 | 52369dbe | Steve Schnepp | opterr = 1;
|
| 27 | |||
| 28 | while ((optch = getopt(argc, argv, format)) != -1) |
||
| 29 | switch (optch) {
|
||
| 30 | case 'v': |
||
| 31 | verbose ++; |
||
| 32 | break;
|
||
| 33 | case 'd': |
||
| 34 | optarg_len = strlen(optarg); |
||
| 35 | plugin_dir = (char *) malloc(optarg_len + 1); |
||
| 36 | strcpy(plugin_dir, optarg); |
||
| 37 | break;
|
||
| 38 | case 'h': |
||
| 39 | optarg_len = strlen(optarg); |
||
| 40 | host = (char *) malloc(optarg_len + 1); |
||
| 41 | strcpy(host, optarg); |
||
| 42 | break;
|
||
| 43 | case 's': |
||
| 44 | optarg_len = strlen(optarg); |
||
| 45 | spoolfetch_dir = (char *) malloc(optarg_len + 1); |
||
| 46 | strcpy(spoolfetch_dir, optarg); |
||
| 47 | break;
|
||
| 48 | } |
||
| 49 | |||
| 50 | /* get default hostname if not precised */
|
||
| 51 | if (! strlen(host)) {
|
||
| 52 | host = (char *) malloc(HOST_NAME_MAX + 1); |
||
| 53 | gethostname(host, HOST_NAME_MAX); |
||
| 54 | } |
||
| 55 | |||
| 56 | acea10b2 | Steve Schnepp | fprintf(stderr, "verbose: %d, host: %s, plugin_dir: %s, spoolfetch_dir: %s\n", verbose, host, plugin_dir, spoolfetch_dir);
|
| 57 | |||
| 58 | printf("# munin node at %s\n", host);
|
||
| 59 | while (fgets(line, LINE_MAX, stdin) != NULL) { |
||
| 60 | char* cmd;
|
||
| 61 | char* arg;
|
||
| 62 | |||
| 63 | line[LINE_MAX-1] = '\0'; |
||
| 64 | 52369dbe | Steve Schnepp | |
| 65 | acea10b2 | Steve Schnepp | cmd = strtok(line, " \t\n");
|
| 66 | arg = strtok(line, " \t\n");
|
||
| 67 | |||
| 68 | if (strlen(cmd) == 0) continue; |
||
| 69 | |||
| 70 | if (strcmp(cmd, "version") == 0) { |
||
| 71 | } else if (strcmp(cmd, "nodes") == 0) { |
||
| 72 | } else if (strcmp(cmd, "quit") == 0) { |
||
| 73 | } else if (strcmp(cmd, "list") == 0) { |
||
| 74 | } else if (strcmp(cmd, "config") == 0) { |
||
| 75 | } else if (strcmp(cmd, "fetch") == 0) { |
||
| 76 | } else if (strcmp(cmd, "cap") == 0) { |
||
| 77 | } else if (strcmp(cmd, "spoolfetch") == 0) { |
||
| 78 | } |
||
| 79 | } |
||
| 80 | 52369dbe | Steve Schnepp | |
| 81 | return 0; |
||
| 82 | } |
