X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_tool.c;h=6aa53cc5b78dfdbc43266e2ac918c0746401eeac;hp=2cb449499a607fb6f8c4d7ac56f1e7351d6a1202;hb=06c64aacf29db1bbf135e80aa98ec03ec8c6719c;hpb=801ce418130e78b4b6818f2c8af85c3ddae400ff diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 2cb4494..6aa53cc 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -1,5 +1,5 @@ /***************************************************************************** - * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002 + * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2004 ***************************************************************************** * rrd_tool.c Startup wrapper *****************************************************************************/ @@ -22,7 +22,7 @@ void PrintUsage(char *cmd) { char help_main[] = - "RRDtool 1.1.x Copyright 1997-2003 by Tobias Oetiker \n" + "RRDtool 1.1.x Copyright 1997-2004 by Tobias Oetiker \n" #ifndef WIN32 " Compiled " MAKE_TIMESTAMP "\n\n" #else @@ -31,7 +31,7 @@ void PrintUsage(char *cmd) "Usage: rrdtool [options] command command_options\n\n"; char help_list[] = - "Valid commands: create, update, graph, dump, restore,\n" + "Valid commands: create, update, updatev, graph, dump, restore,\n" "\t\tlast, info, fetch, tune, resize, xport\n\n"; char help_listremote[] = @@ -55,7 +55,7 @@ void PrintUsage(char *cmd) char help_restore[] = "* restore - restore an RRD file from its XML form\n\n" - "\trrdtool restore [--range-check|-r] filename.xml filename.rrd\n\n"; + "\trrdtool restore [--range-check|-r] [--force-overwrite|-f] filename.xml filename.rrd\n\n"; char help_last[] = "* last - show last update time for RRD\n\n" @@ -68,6 +68,15 @@ void PrintUsage(char *cmd) "\t\ttime|N:value[:value...]\n\n" "\t\tat-time@value[:value...]\n\n" "\t\t[ time:value[:value...] ..]\n\n"; + + char help_updatev[] = + "* updatev - a verbose version of update\n" + "\treturns information about values, RRAs, and datasources updated\n\n" + "\trrdtool updatev filename\n" + "\t\t--template|-t ds-name:ds-name:...\n" + "\t\ttime|N:value[:value...]\n\n" + "\t\tat-time@value[:value...]\n\n" + "\t\t[ time:value[:value...] ..]\n\n"; char help_fetch[] = "* fetch - fetch data out of an RRD\n\n" @@ -75,7 +84,9 @@ void PrintUsage(char *cmd) "\t\t[--resolution|-r resolution]\n" "\t\t[--start|-s start] [--end|-e end]\n\n"; - char help_graph[] = +/* break up very large strings (help_graph, help_tune) for ISO C89 compliance*/ + + char help_graph1[] = "* graph - generate a graph from one or several RRD\n\n" "\trrdtool graph filename [-s|--start seconds] [-e|--end seconds]\n" "\t\t[-x|--x-grid x-axis grid and label]\n" @@ -85,7 +96,9 @@ void PrintUsage(char *cmd) "\t\t[-h|--height pixels] [-o|--logarithmic]\n" "\t\t[-u|--upper-limit value] [-z|--lazy]\n" "\t\t[-l|--lower-limit value] [-r|--rigid]\n" - "\t\t[-g|--no-legend]\n" + "\t\t[-g|--no-legend]\n"; + char help_graph2[] = + "\t\t[-j|--only-graph]\n" "\t\t[--font FONTTAG:size:font]\n" "\t\t[--zoom factor]\n" "\t\t[--alt-autoscale]\n" @@ -94,7 +107,8 @@ void PrintUsage(char *cmd) "\t\t[--step seconds]\n" "\t\t[-f|--imginfo printfstr]\n" "\t\t[-a|--imgformat PNG]\n" - "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" + "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n"; + char help_graph3[] = "\t\t[DEF:vname=rrd:ds-name:CF]\n" "\t\t[CDEF:vname=rpn-expression]\n" "\t\t[PRINT:vname:CF:format]\n" @@ -105,7 +119,7 @@ void PrintUsage(char *cmd) "\t\t[AREA:vname[#rrggbb[aa][:legend]]]\n" "\t\t[STACK:vname[#rrggbb[aa][:legend]]]\n\n"; - char help_tune[] = + char help_tune1[] = " * tune - Modify some basic properties of an RRD\n\n" "\trrdtool tune filename\n" "\t\t[--heartbeat|-h ds-name:heartbeat]\n" @@ -115,14 +129,16 @@ void PrintUsage(char *cmd) "\t\t[--deltapos scale-value] [--deltaneg scale-value]\n" "\t\t[--failure-threshold integer]\n" "\t\t[--window-length integer]\n" - "\t\t[--alpha adaptation-parameter]\n" + "\t\t[--alpha adaptation-parameter]\n"; + char help_tune2[] = + " * tune - Modify some basic properties of an RRD\n\n" "\t\t[--beta adaptation-parameter]\n" "\t\t[--gamma adaptation-parameter]\n" "\t\t[--gamma-deviation adaptation-parameter]\n" "\t\t[--aberrant-reset ds-name]\n\n"; char help_resize[] = - " * resize - alter the lenght of one of the RRAs in an RRD\n\n" + " * resize - alter the length of one of the RRAs in an RRD\n\n" "\trrdtool resize filename rranum GROW|SHRINK rows\n\n"; char help_xport[] = @@ -135,7 +151,7 @@ void PrintUsage(char *cmd) "\t\t[XPORT:vname:legend]\n\n"; char help_quit[] = - " * quit - closeing a session in remote mode\n\n" + " * quit - closing a session in remote mode\n\n" "\trrdtool quit\n\n"; char help_ls[] = @@ -144,11 +160,11 @@ void PrintUsage(char *cmd) char help_cd[] = " * cd - changes the current directory\n\n" - "\trrdtool cd new direcotry\n\n"; + "\trrdtool cd new directory\n\n"; char help_mkdir[] = - " * mkdir - creates a new direcotry\n\n" - "\trrdtool mkdir newdirecotryname\n\n"; + " * mkdir - creates a new directory\n\n" + "\trrdtool mkdir newdirectoryname\n\n"; char help_lic[] = "RRDtool is distributed under the Terms of the GNU General\n" @@ -158,7 +174,7 @@ void PrintUsage(char *cmd) enum { C_NONE, C_CREATE, C_DUMP, C_INFO, C_RESTORE, C_LAST, C_UPDATE, C_FETCH, C_GRAPH, C_TUNE, C_RESIZE, C_XPORT, - C_QUIT, C_LS, C_CD, C_MKDIR }; + C_QUIT, C_LS, C_CD, C_MKDIR, C_UPDATEV }; int help_cmd = C_NONE; @@ -176,6 +192,8 @@ void PrintUsage(char *cmd) help_cmd = C_LAST; else if (!strcmp(cmd,"update")) help_cmd = C_UPDATE; + else if (!strcmp(cmd,"updatev")) + help_cmd = C_UPDATEV; else if (!strcmp(cmd,"fetch")) help_cmd = C_FETCH; else if (!strcmp(cmd,"graph")) @@ -222,14 +240,20 @@ void PrintUsage(char *cmd) case C_UPDATE: fputs(help_update, stdout); break; + case C_UPDATEV: + fputs(help_updatev, stdout); + break; case C_FETCH: fputs(help_fetch, stdout); break; case C_GRAPH: - fputs(help_graph, stdout); + fputs(help_graph1, stdout); + fputs(help_graph2, stdout); + fputs(help_graph3, stdout); break; case C_TUNE: - fputs(help_tune, stdout); + fputs(help_tune1, stdout); + fputs(help_tune2, stdout); break; case C_RESIZE: fputs(help_resize, stdout); @@ -305,7 +329,7 @@ int main(int argc, char *argv[]) if (strcmp(firstdir,"")){ chdir(firstdir); if (errno!=0){ - fprintf(stderr,"ERROR: %s\n",strerror(errno)); + fprintf(stderr,"ERROR: %s\n",rrd_strerror(errno)); exit(errno); } } @@ -395,14 +419,14 @@ int HandleInputLine(int argc, char **argv, FILE* out) } #if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID) if (getuid()==0 && ! ChangeRoot){ - printf("ERROR: chdir security problem - rrdtool is runnig as " + printf("ERROR: chdir security problem - rrdtool is running as " "root an no chroot!\n"); return(0); } #endif chdir(argv[2]); if (errno!=0){ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); } return(0); } @@ -413,14 +437,14 @@ int HandleInputLine(int argc, char **argv, FILE* out) } #if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID) if (getuid()==0 && ! ChangeRoot){ - printf("ERROR: mkdir security problem - rrdtool is runnig as " + printf("ERROR: mkdir security problem - rrdtool is running as " "root an no chroot!\n"); return(0); } #endif mkdir(argv[2],0777); if (errno!=0){ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); } return(0); } @@ -445,7 +469,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) } } else{ - printf("ERROR: %s\n",strerror(errno)); + printf("ERROR: %s\n",rrd_strerror(errno)); return(errno); } return(0); @@ -467,9 +491,13 @@ int HandleInputLine(int argc, char **argv, FILE* out) rrd_create(argc-1, &argv[1]); else if (strcmp("dump", argv[1]) == 0) rrd_dump(argc-1, &argv[1]); - else if (strcmp("info", argv[1]) == 0){ + else if (strcmp("info", argv[1]) == 0 + || strcmp("updatev", argv[1]) == 0){ info_t *data,*save; - data=rrd_info(argc-1, &argv[1]); + if (strcmp("info",argv[1]) == 0) + data=rrd_info(argc-1, &argv[1]); + else + data=rrd_update_v(argc-1, &argv[1]); while (data) { save=data; printf ("%s = ", data->key); @@ -485,6 +513,9 @@ int HandleInputLine(int argc, char **argv, FILE* out) case RD_I_CNT: printf ("%lu", data->value.u_cnt); break; + case RD_I_INT: + printf ("%d", data->value.u_int); + break; case RD_I_STR: printf ("\"%s\"", data->value.u_str); free(data->value.u_str); @@ -502,13 +533,13 @@ int HandleInputLine(int argc, char **argv, FILE* out) strcmp("v", argv[1]) == 0 || strcmp("-v", argv[1]) == 0 || strcmp("-version", argv[1]) == 0 ) - printf("RRDtool 1.1.x Copyright (C) 1997-2003 by Tobias Oetiker \n"); + printf("RRDtool 1.1.x Copyright (C) 1997-2004 by Tobias Oetiker \n"); else if (strcmp("restore", argv[1]) == 0) rrd_restore(argc-1, &argv[1]); else if (strcmp("resize", argv[1]) == 0) rrd_resize(argc-1, &argv[1]); else if (strcmp("last", argv[1]) == 0) - printf("%ld\n",rrd_last(argc-1, &argv[1])); + printf("%ld\n",rrd_last(argc-1, argv[1])); else if (strcmp("update", argv[1]) == 0) rrd_update(argc-1, &argv[1]); else if (strcmp("fetch", argv[1]) == 0) { @@ -520,7 +551,7 @@ int HandleInputLine(int argc, char **argv, FILE* out) datai=data; printf(" "); for (i = 0; i