1 /*****************************************************************************
2 * RRDtool 1.3.2 Copyright by Tobi Oetiker, 1997-2008
3 *****************************************************************************
4 * rrd_tool.c Startup wrapper
5 *****************************************************************************/
7 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H)
8 #include "../win32/config.h"
13 #include "../rrd_config.h"
18 #include "rrd_xport.h"
43 #define MAX_LENGTH 10000
50 const char *help_main =
52 " Copyright 1997-2008 by Tobias Oetiker <tobi@oetiker.ch>\n"
54 "Usage: rrdtool [options] command command_options\n\n");
56 const char *help_list =
58 ("Valid commands: create, update, updatev, graph, graphv, dump, restore,\n"
59 "\t\tlast, lastupdate, first, info, fetch, tune,\n"
60 "\t\tresize, xport, flush\n\n");
62 const char *help_listremote =
63 N_("Valid remote commands: quit, ls, cd, mkdir, pwd\n\n");
66 const char *help_create =
67 N_("* create - create a new RRD\n\n"
68 "\trrdtool create filename [--start|-b start time]\n"
69 "\t\t[--step|-s step]\n"
70 "\t\t[DS:ds-name:DST:dst arguments]\n"
71 "\t\t[RRA:CF:cf arguments]\n\n");
73 const char *help_dump =
74 N_("* dump - dump an RRD to XML\n\n"
75 "\trrdtool dump filename.rrd >filename.xml\n\n");
77 const char *help_info =
78 N_("* info - returns the configuration and status of the RRD\n\n"
79 "\trrdtool info filename.rrd\n\n");
81 const char *help_restore =
82 N_("* restore - restore an RRD file from its XML form\n\n"
83 "\trrdtool restore [--range-check|-r] [--force-overwrite|-f] filename.xml filename.rrd\n\n");
85 const char *help_last =
86 N_("* last - show last update time for RRD\n\n"
87 "\trrdtool last filename.rrd\n\n");
89 const char *help_lastupdate =
90 N_("* lastupdate - returns the most recent datum stored for\n"
91 " each DS in an RRD\n\n" "\trrdtool lastupdate filename.rrd\n\n");
93 const char *help_first =
94 N_("* first - show first update time for RRA within an RRD\n\n"
95 "\trrdtool first filename.rrd [--rraindex number]\n\n");
97 const char *help_update =
98 N_("* update - update an RRD\n\n"
99 "\trrdtool update filename\n"
100 "\t\t[--template|-t ds-name:ds-name:...]\n"
101 "\t\t[--daemon <address>]\n"
102 "\t\ttime|N:value[:value...]\n\n"
103 "\t\tat-time@value[:value...]\n\n"
104 "\t\t[ time:value[:value...] ..]\n\n");
106 const char *help_updatev =
107 N_("* updatev - a verbose version of update\n"
108 "\treturns information about values, RRAs, and datasources updated\n\n"
109 "\trrdtool updatev filename\n"
110 "\t\t[--template|-t ds-name:ds-name:...]\n"
111 "\t\ttime|N:value[:value...]\n\n"
112 "\t\tat-time@value[:value...]\n\n"
113 "\t\t[ time:value[:value...] ..]\n\n");
115 const char *help_fetch =
116 N_("* fetch - fetch data out of an RRD\n\n"
117 "\trrdtool fetch filename.rrd CF\n"
118 "\t\t[-r|--resolution resolution]\n"
119 "\t\t[-s|--start start] [-e|--end end]\n"
120 "\t\t[--daemon <address>]\n\n");
122 const char *help_flush =
123 N_("* flush - flush cached data out to an RRD file\n\n"
124 "\trrdtool flush filename.rrd\n"
125 "\t\t[--daemon <address>]\n\n");
127 /* break up very large strings (help_graph, help_tune) for ISO C89 compliance*/
129 const char *help_graph0 =
130 N_("* graph - generate a graph from one or several RRD\n\n"
131 "\trrdtool graph filename [-s|--start seconds] [-e|--end seconds]\n");
132 const char *help_graphv0 =
133 N_("* graphv - generate a graph from one or several RRD\n"
134 " with meta data printed before the graph\n\n"
135 "\trrdtool graphv filename [-s|--start seconds] [-e|--end seconds]\n");
136 const char *help_graph1 =
137 N_("\t\t[-x|--x-grid x-axis grid and label]\n"
138 "\t\t[-Y|--alt-y-grid] [--full-size-mode]\n"
139 "\t\t[-y|--y-grid y-axis grid and label]\n"
140 "\t\t[-v|--vertical-label string] [-w|--width pixels]\n"
141 "\t\t[-h|--height pixels] [-o|--logarithmic]\n"
142 "\t\t[-u|--upper-limit value] [-z|--lazy]\n"
143 "\t\t[-l|--lower-limit value] [-r|--rigid]\n"
144 "\t\t[-g|--no-legend] [--daemon <address>]\n"
145 "\t\t[-F|--force-rules-legend]\n" "\t\t[-j|--only-graph]\n");
146 const char *help_graph2 =
147 N_("\t\t[-n|--font FONTTAG:size:font]\n"
148 "\t\t[-m|--zoom factor]\n"
149 "\t\t[-A|--alt-autoscale]\n"
150 "\t\t[-M|--alt-autoscale-max]\n"
151 "\t\t[-R|--font-render-mode {normal,light,mono}]\n"
152 "\t\t[-B|--font-smoothing-threshold size]\n"
153 "\t\t[-T|--tabwidth width]\n"
154 "\t\t[-E|--slope-mode]\n"
155 "\t\t[-N|--no-gridfit]\n"
156 "\t\t[-X|--units-exponent value]\n"
157 "\t\t[-L|--units-length value]\n"
158 "\t\t[-S|--step seconds]\n"
159 "\t\t[-f|--imginfo printfstr]\n"
160 "\t\t[-a|--imgformat PNG]\n"
161 "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n"
162 "\t\t[-W|--watermark string]\n"
163 "\t\t[DEF:vname=rrd:ds-name:CF]\n");
164 const char *help_graph3 =
165 N_("\t\t[CDEF:vname=rpn-expression]\n"
166 "\t\t[VDEF:vdefname=rpn-expression]\n"
167 "\t\t[PRINT:vdefname:format]\n"
168 "\t\t[GPRINT:vdefname:format]\n" "\t\t[COMMENT:text]\n"
169 "\t\t[SHIFT:vname:offset]\n"
170 "\t\t[TICK:vname#rrggbb[aa][:[fraction][:legend]]]\n"
171 "\t\t[HRULE:value#rrggbb[aa][:legend]]\n"
172 "\t\t[VRULE:value#rrggbb[aa][:legend]]\n"
173 "\t\t[LINE[width]:vname[#rrggbb[aa][:[legend][:STACK]]]]\n"
174 "\t\t[AREA:vname[#rrggbb[aa][:[legend][:STACK]]]]\n"
175 "\t\t[PRINT:vname:CF:format] (deprecated)\n"
176 "\t\t[GPRINT:vname:CF:format] (deprecated)\n"
177 "\t\t[STACK:vname[#rrggbb[aa][:legend]]] (deprecated)\n\n");
178 const char *help_tune1 =
179 N_(" * tune - Modify some basic properties of an RRD\n\n"
180 "\trrdtool tune filename\n"
181 "\t\t[--heartbeat|-h ds-name:heartbeat]\n"
182 "\t\t[--data-source-type|-d ds-name:DST]\n"
183 "\t\t[--data-source-rename|-r old-name:new-name]\n"
184 "\t\t[--minimum|-i ds-name:min] [--maximum|-a ds-name:max]\n"
185 "\t\t[--deltapos scale-value] [--deltaneg scale-value]\n"
186 "\t\t[--failure-threshold integer]\n"
187 "\t\t[--window-length integer]\n"
188 "\t\t[--alpha adaptation-parameter]\n");
189 const char *help_tune2 =
190 N_(" * tune - Modify some basic properties of an RRD\n\n"
191 "\t\t[--beta adaptation-parameter]\n"
192 "\t\t[--gamma adaptation-parameter]\n"
193 "\t\t[--gamma-deviation adaptation-parameter]\n"
194 "\t\t[--aberrant-reset ds-name]\n\n");
195 const char *help_resize =
197 (" * resize - alter the length of one of the RRAs in an RRD\n\n"
198 "\trrdtool resize filename rranum GROW|SHRINK rows\n\n");
199 const char *help_xport =
200 N_("* xport - generate XML dump from one or several RRD\n\n"
201 "\trrdtool xport [-s|--start seconds] [-e|--end seconds]\n"
202 "\t\t[-m|--maxrows rows]\n" "\t\t[--step seconds]\n"
203 "\t\t[--enumds]\n" "\t\t[DEF:vname=rrd:ds-name:CF]\n"
204 "\t\t[CDEF:vname=rpn-expression]\n"
205 "\t\t[XPORT:vname:legend]\n\n");
206 const char *help_quit =
207 N_(" * quit - closing a session in remote mode\n\n"
208 "\trrdtool quit\n\n");
209 const char *help_ls =
210 N_(" * ls - lists all *.rrd files in current directory\n\n"
212 const char *help_cd =
213 N_(" * cd - changes the current directory\n\n"
214 "\trrdtool cd new directory\n\n");
215 const char *help_mkdir =
216 N_(" * mkdir - creates a new directory\n\n"
217 "\trrdtool mkdir newdirectoryname\n\n");
218 const char *help_pwd =
219 N_(" * pwd - returns the current working directory\n\n"
220 "\trrdtool pwd\n\n");
221 const char *help_lic =
222 N_("RRDtool is distributed under the Terms of the GNU General\n"
223 "Public License Version 2. (www.gnu.org/copyleft/gpl.html)\n\n"
224 "For more information read the RRD manpages\n\n");
225 enum { C_NONE, C_CREATE, C_DUMP, C_INFO, C_RESTORE, C_LAST,
226 C_LASTUPDATE, C_FIRST, C_UPDATE, C_FETCH, C_GRAPH, C_GRAPHV,
228 C_RESIZE, C_XPORT, C_QUIT, C_LS, C_CD, C_MKDIR, C_PWD,
231 int help_cmd = C_NONE;
234 if (!strcmp(cmd, "create"))
236 else if (!strcmp(cmd, "dump"))
238 else if (!strcmp(cmd, "info"))
240 else if (!strcmp(cmd, "restore"))
241 help_cmd = C_RESTORE;
242 else if (!strcmp(cmd, "last"))
244 else if (!strcmp(cmd, "lastupdate"))
245 help_cmd = C_LASTUPDATE;
246 else if (!strcmp(cmd, "first"))
248 else if (!strcmp(cmd, "update"))
250 else if (!strcmp(cmd, "updatev"))
251 help_cmd = C_UPDATEV;
252 else if (!strcmp(cmd, "fetch"))
254 else if (!strcmp(cmd, "flush"))
256 else if (!strcmp(cmd, "graph"))
258 else if (!strcmp(cmd, "graphv"))
260 else if (!strcmp(cmd, "tune"))
262 else if (!strcmp(cmd, "resize"))
264 else if (!strcmp(cmd, "xport"))
266 else if (!strcmp(cmd, "quit"))
268 else if (!strcmp(cmd, "ls"))
270 else if (!strcmp(cmd, "cd"))
272 else if (!strcmp(cmd, "mkdir"))
274 else if (!strcmp(cmd, "pwd"))
277 fprintf(stdout, _(help_main), PACKAGE_VERSION, __DATE__, __TIME__);
281 fputs(_(help_list), stdout);
283 fputs(_(help_listremote), stdout);
287 fputs(_(help_create), stdout);
290 fputs(_(help_dump), stdout);
293 fputs(_(help_info), stdout);
296 fputs(_(help_restore), stdout);
299 fputs(_(help_last), stdout);
302 fputs(_(help_lastupdate), stdout);
305 fputs(_(help_first), stdout);
308 fputs(_(help_update), stdout);
311 fputs(_(help_updatev), stdout);
314 fputs(_(help_fetch), stdout);
317 fputs(_(help_flush), stdout);
320 fputs(_(help_graph0), stdout);
321 fputs(_(help_graph1), stdout);
322 fputs(_(help_graph2), stdout);
323 fputs(_(help_graph3), stdout);
326 fputs(_(help_graphv0), stdout);
327 fputs(_(help_graph1), stdout);
328 fputs(_(help_graph2), stdout);
329 fputs(_(help_graph3), stdout);
332 fputs(_(help_tune1), stdout);
333 fputs(_(help_tune2), stdout);
336 fputs(_(help_resize), stdout);
339 fputs(_(help_xport), stdout);
342 fputs(_(help_quit), stdout);
345 fputs(_(help_ls), stdout);
348 fputs(_(help_cd), stdout);
351 fputs(_(help_mkdir), stdout);
354 fputs(_(help_pwd), stdout);
357 fputs(_(help_lic), stdout);
360 static char *fgetslong(
365 size_t bufsize = MAX_LENGTH;
369 return *aLinePtr = 0;
370 if (!(linebuf = malloc(bufsize))) {
371 perror("fgetslong: malloc");
375 while (fgets(linebuf + eolpos, MAX_LENGTH, stream)) {
376 eolpos += strlen(linebuf + eolpos);
377 if (linebuf[eolpos - 1] == '\n')
378 return *aLinePtr = linebuf;
379 bufsize += MAX_LENGTH;
380 if (!(linebuf = realloc(linebuf, bufsize))) {
382 perror("fgetslong: realloc");
387 return *aLinePtr = linebuf;
390 return *aLinePtr = 0;
401 #ifdef MUST_DISABLE_SIGFPE
402 signal(SIGFPE, SIG_IGN);
404 #ifdef MUST_DISABLE_FPMASK
408 setlocale(LC_ALL, "");
411 #if defined(HAVE_LIBINTL_H) && defined(BUILD_LIBINTL)
412 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
413 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
414 textdomain(GETTEXT_PACKAGE);
421 if (((argc == 2) || (argc == 3)) && !strcmp("-", argv[1])) {
423 struct rusage myusage;
424 struct timeval starttime;
425 struct timeval currenttime;
427 gettimeofday(&starttime, NULL);
430 if ((argc == 3) && strcmp("", argv[2])) {
441 if (chroot(argv[2]) != 0){
442 fprintf(stderr, "ERROR: chroot %s: %s\n", argv[2],rrd_strerror(errno));
449 "ERROR: change root is not supported by your OS "
450 "or at least by this copy of rrdtool\n");
457 if (strcmp(firstdir, "")) {
458 if (chdir(firstdir) != 0){
459 fprintf(stderr, "ERROR: chdir %s %s\n", firstdir,rrd_strerror(errno));
464 while (fgetslong(&aLine, stdin)) {
465 if ((argc = CountArgs(aLine)) == 0) {
467 printf("ERROR: not enough arguments\n");
469 if ((myargv = (char **) malloc((argc + 1) *
470 sizeof(char *))) == NULL) {
474 if ((argc = CreateArgs(argv[0], aLine, argc, myargv)) < 0) {
477 printf("ERROR: creating arguments\n");
479 int ret = HandleInputLine(argc, myargv, stdout);
484 getrusage(RUSAGE_SELF, &myusage);
485 gettimeofday(¤ttime, NULL);
486 printf("OK u:%1.2f s:%1.2f r:%1.2f\n",
487 (double) myusage.ru_utime.tv_sec +
488 (double) myusage.ru_utime.tv_usec / 1000000.0,
489 (double) myusage.ru_stime.tv_sec +
490 (double) myusage.ru_stime.tv_usec / 1000000.0,
491 (double) (currenttime.tv_sec - starttime.tv_sec)
492 + (double) (currenttime.tv_usec -
500 fflush(stdout); /* this is important for pipes to work */
503 } else if (argc == 2) {
506 } else if (argc == 3 && !strcmp(argv[1], "help")) {
510 exit(HandleInputLine(argc, argv, stderr));
515 /* HandleInputLine is NOT thread safe - due to readdir issues,
516 resolving them portably is not really simple. */
522 #if defined(HAVE_OPENDIR) && defined (HAVE_READDIR)
523 DIR *curdir; /* to read current dir with ls */
526 #if defined(HAVE_SYS_STAT_H)
529 char *cwd; /* To hold current working dir on call to pwd */
531 /* Reset errno to 0 before we start.
534 if (argc > 1 && strcmp("quit", argv[1]) == 0) {
536 printf("ERROR: invalid parameter count for quit\n");
541 #if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR)
542 if (argc > 1 && strcmp("cd", argv[1]) == 0) {
544 printf("ERROR: invalid parameter count for cd\n");
547 #if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
548 if (getuid() == 0 && !ChangeRoot) {
550 ("ERROR: chdir security problem - rrdtool is running as "
551 "root but not chroot!\n");
555 if (chdir(argv[2]) != 0){
556 printf("ERROR: chdir %s %s\n", argv[2], rrd_strerror(errno));
561 if (argc > 1 && strcmp("pwd", argv[1]) == 0) {
563 printf("ERROR: invalid parameter count for pwd\n");
566 cwd = getcwd(NULL, MAXPATH);
568 printf("ERROR: getcwd %s\n", rrd_strerror(errno));
575 if (argc > 1 && strcmp("mkdir", argv[1]) == 0) {
577 printf("ERROR: invalid parameter count for mkdir\n");
580 #if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
581 if (getuid() == 0 && !ChangeRoot) {
583 ("ERROR: mkdir security problem - rrdtool is running as "
584 "root but not chroot!\n");
588 if(mkdir(argv[2], 0777)!=0){
589 printf("ERROR: mkdir %s: %s\n", argv[2],rrd_strerror(errno));
594 if (argc > 1 && strcmp("ls", argv[1]) == 0) {
596 printf("ERROR: invalid parameter count for ls\n");
599 if ((curdir = opendir(".")) != NULL) {
600 while ((dent = readdir(curdir)) != NULL) {
601 if (!stat(dent->d_name, &st)) {
602 if (S_ISDIR(st.st_mode)) {
603 printf("d %s\n", dent->d_name);
605 if (strlen(dent->d_name) > 4 && S_ISREG(st.st_mode)) {
607 (dent->d_name + NAMLEN(dent) - 4, ".rrd")
608 || !strcmp(dent->d_name + NAMLEN(dent) - 4,
610 printf("- %s\n", dent->d_name);
617 printf("ERROR: opendir .: %s\n", rrd_strerror(errno));
622 #endif /* opendir and readdir */
626 || strcmp("help", argv[1]) == 0
627 || strcmp("--help", argv[1]) == 0
628 || strcmp("-help", argv[1]) == 0
629 || strcmp("-?", argv[1]) == 0 || strcmp("-h", argv[1]) == 0) {
634 if (strcmp("create", argv[1]) == 0)
635 rrd_create(argc - 1, &argv[1]);
636 else if (strcmp("dump", argv[1]) == 0)
637 rrd_dump(argc - 1, &argv[1]);
638 else if (strcmp("info", argv[1]) == 0 || strcmp("updatev", argv[1]) == 0) {
641 if (strcmp("info", argv[1]) == 0)
643 data = rrd_info(argc - 1, &argv[1]);
645 data = rrd_update_v(argc - 1, &argv[1]);
646 rrd_info_print(data);
650 else if (strcmp("--version", argv[1]) == 0 ||
651 strcmp("version", argv[1]) == 0 ||
652 strcmp("v", argv[1]) == 0 ||
653 strcmp("-v", argv[1]) == 0 || strcmp("-version", argv[1]) == 0)
654 printf("RRDtool " PACKAGE_VERSION
655 " Copyright by Tobi Oetiker, 1997-2008 (%f)\n",
657 else if (strcmp("restore", argv[1]) == 0)
658 rrd_restore(argc - 1, &argv[1]);
659 else if (strcmp("resize", argv[1]) == 0)
660 rrd_resize(argc - 1, &argv[1]);
661 else if (strcmp("last", argv[1]) == 0)
662 printf("%ld\n", rrd_last(argc - 1, &argv[1]));
663 else if (strcmp("lastupdate", argv[1]) == 0) {
664 rrd_lastupdate(argc - 1, &argv[1]);
665 } else if (strcmp("first", argv[1]) == 0)
666 printf("%ld\n", rrd_first(argc - 1, &argv[1]));
667 else if (strcmp("update", argv[1]) == 0)
668 rrd_update(argc - 1, &argv[1]);
669 else if (strcmp("fetch", argv[1]) == 0) {
670 time_t start, end, ti;
671 unsigned long step, ds_cnt, i, ii;
672 rrd_value_t *data, *datai;
676 (argc - 1, &argv[1], &start, &end, &step, &ds_cnt, &ds_namv,
680 for (i = 0; i < ds_cnt; i++)
681 printf("%20s", ds_namv[i]);
683 for (ti = start + step; ti <= end; ti += step) {
684 printf("%10lu:", ti);
685 for (ii = 0; ii < ds_cnt; ii++)
686 printf(" %0.10e", *(datai++));
689 for (i = 0; i < ds_cnt; i++)
694 } else if (strcmp("xport", argv[1]) == 0) {
696 unsigned long int j = 0;
697 time_t start, end, ti;
698 unsigned long step, col_cnt, row_cnt;
699 rrd_value_t *data, *ptr;
703 size_t vtag_s = strlen(COL_DATA_TAG) + 10;
704 char *vtag = malloc(vtag_s);
706 for (i = 2; i < argc; i++) {
707 if (strcmp("--enumds", argv[i]) == 0)
712 (argc - 1, &argv[1], &xxsize, &start, &end, &step, &col_cnt,
713 &legend_v, &data) != -1) {
714 row_cnt = (end - start) / step;
716 printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n",
718 printf("<%s>\n", ROOT_TAG);
719 printf(" <%s>\n", META_TAG);
720 printf(" <%s>%lu</%s>\n", META_START_TAG,
721 (unsigned long) start + step, META_START_TAG);
722 printf(" <%s>%lu</%s>\n", META_STEP_TAG, step, META_STEP_TAG);
723 printf(" <%s>%lu</%s>\n", META_END_TAG, (unsigned long) end,
725 printf(" <%s>%lu</%s>\n", META_ROWS_TAG, row_cnt,
727 printf(" <%s>%lu</%s>\n", META_COLS_TAG, col_cnt,
729 printf(" <%s>\n", LEGEND_TAG);
730 for (j = 0; j < col_cnt; j++) {
734 printf(" <%s>%s</%s>\n", LEGEND_ENTRY_TAG, entry,
739 printf(" </%s>\n", LEGEND_TAG);
740 printf(" </%s>\n", META_TAG);
741 printf(" <%s>\n", DATA_TAG);
742 for (ti = start + step; ti <= end; ti += step) {
743 printf(" <%s>", DATA_ROW_TAG);
744 printf("<%s>%lu</%s>", COL_TIME_TAG, ti, COL_TIME_TAG);
745 for (j = 0; j < col_cnt; j++) {
746 rrd_value_t newval = DNAN;
750 snprintf(vtag, vtag_s, "%s%lu", COL_DATA_TAG, j);
752 snprintf(vtag, vtag_s, "%s", COL_DATA_TAG);
755 printf("<%s>NaN</%s>", vtag, vtag);
757 printf("<%s>%0.10e</%s>", vtag, newval, vtag);
761 printf("</%s>\n", DATA_ROW_TAG);
764 printf(" </%s>\n", DATA_TAG);
765 printf("</%s>\n", ROOT_TAG);
768 } else if (strcmp("graph", argv[1]) == 0) {
771 #ifdef notused /*XXX*/
772 const char *imgfile = argv[2]; /* rrd_graph changes argv pointer */
777 int tostdout = (strcmp(argv[2], "-") == 0);
780 for (i = 2; i < argc; i++) {
781 if (strcmp(argv[i], "--imginfo") == 0
782 || strcmp(argv[i], "-f") == 0) {
788 (argc - 1, &argv[1], &calcpr, &xsize, &ysize, NULL, &ymin,
790 if (!tostdout && !imginfo)
791 printf("%dx%d\n", xsize, ysize);
793 for (i = 0; calcpr[i]; i++) {
795 printf("%s\n", calcpr[i]);
802 } else if (strcmp("graphv", argv[1]) == 0) {
803 rrd_info_t *grinfo = NULL; /* 1 to distinguish it from the NULL that rrd_graph sends in */
805 grinfo = rrd_graph_v(argc - 1, &argv[1]);
807 rrd_info_print(grinfo);
808 rrd_info_free(grinfo);
811 } else if (strcmp("tune", argv[1]) == 0)
812 rrd_tune(argc - 1, &argv[1]);
813 else if (strcmp("flush", argv[1]) == 0)
814 rrd_cmd_flush(argc - 1, &argv[1]);
816 rrd_set_error("unknown function '%s'", argv[1]);
818 if (rrd_test_error()) {
819 fprintf(out, "ERROR: %s\n", rrd_get_error());
833 while (aLine[i] == ' ')
835 while (aLine[i] != 0) {
836 if ((aLine[i] == ' ') && inarg) {
839 if ((aLine[i] != ' ') && !inarg) {
849 * CreateArgs - take a string (aLine) and tokenize
864 /* remove trailing space and newlines */
865 while (len && aLine[len] <= ' ') {
869 /* sikp leading blanks */
870 while (*aLine && *aLine <= ' ')
896 pargv[argc++] = putP;
904 pargv[argc++] = putP;