projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New VDEF functions for least squares slope, intercept & correlation for simple foreca...
[rrdtool.git]
/
src
/
rrd_tool.c
diff --git
a/src/rrd_tool.c
b/src/rrd_tool.c
index
e6b4c5a
..
ecd88f9
100644
(file)
--- a/
src/rrd_tool.c
+++ b/
src/rrd_tool.c
@@
-1,5
+1,5
@@
/*****************************************************************************
/*****************************************************************************
- * RRDtool 1.2.
3
Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.
11
Copyright by Tobi Oetiker, 1997-2005
*****************************************************************************
* rrd_tool.c Startup wrapper
*****************************************************************************/
*****************************************************************************
* rrd_tool.c Startup wrapper
*****************************************************************************/
@@
-22,8
+22,8
@@
void PrintUsage(char *cmd)
{
char help_main[] =
{
char help_main[] =
- "RRDtool
1.2.3
Copyright 1997-2005 by Tobias Oetiker <tobi@oetiker.ch>\n"
-#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+ "RRDtool
" PACKAGE_VERSION "
Copyright 1997-2005 by Tobias Oetiker <tobi@oetiker.ch>\n"
+#if defined(
_
WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
" Compiled " __DATE__ " " __TIME__ "\n\n"
#else
" Compiled " MAKE_TIMESTAMP "\n\n"
" Compiled " __DATE__ " " __TIME__ "\n\n"
#else
" Compiled " MAKE_TIMESTAMP "\n\n"
@@
-81,7
+81,7
@@
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";
"\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"
"\trrdtool fetch filename.rrd CF\n"
char help_fetch[] =
"* fetch - fetch data out of an RRD\n\n"
"\trrdtool fetch filename.rrd CF\n"
@@
-101,9
+101,9
@@
void PrintUsage(char *cmd)
"\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[-u|--upper-limit value] [-z|--lazy]\n"
"\t\t[-l|--lower-limit value] [-r|--rigid]\n"
"\t\t[-g|--no-legend]\n"
- "\t\t[-F|--force-rules-legend]\n";
+ "\t\t[-F|--force-rules-legend]\n"
+ "\t\t[-j|--only-graph]\n";
char help_graph2[] =
char help_graph2[] =
- "\t\t[-j|--only-graph]\n"
"\t\t[-n|--font FONTTAG:size:font]\n"
"\t\t[-m|--zoom factor]\n"
"\t\t[-A|--alt-autoscale]\n"
"\t\t[-n|--font FONTTAG:size:font]\n"
"\t\t[-m|--zoom factor]\n"
"\t\t[-A|--alt-autoscale]\n"
@@
-117,10
+117,10
@@
void PrintUsage(char *cmd)
"\t\t[-S|--step seconds]\n"
"\t\t[-f|--imginfo printfstr]\n"
"\t\t[-a|--imgformat PNG]\n"
"\t\t[-S|--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";
- char help_graph3[] =
+ "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n"
"\t\t[DEF:vname=rrd:ds-name:CF]\n"
"\t\t[DEF:vname=rrd:ds-name:CF]\n"
- "\t\t[CDEF:vname=rpn-expression]\n"
+ "\t\t[CDEF:vname=rpn-expression]\n";
+ char help_graph3[] =
"\t\t[VDEF:vdefname=rpn-expression]\n"
"\t\t[PRINT:vdefname:format]\n"
"\t\t[GPRINT:vdefname:format]\n"
"\t\t[VDEF:vdefname=rpn-expression]\n"
"\t\t[PRINT:vdefname:format]\n"
"\t\t[GPRINT:vdefname:format]\n"
@@
-370,17
+370,17
@@
int main(int argc, char *argv[])
exit(1);
}
if ((argc=CreateArgs(argv[0], aLine, argc, myargv)) < 0) {
exit(1);
}
if ((argc=CreateArgs(argv[0], aLine, argc, myargv)) < 0) {
-
fprintf(stderr,
"ERROR: creating arguments\n");
- exit(1);
- }
-
- HandleInputLine(argc, myargv, stdout);
- free(myargv);
+
printf(
"ERROR: creating arguments\n");
+ } else {
+ int ret = HandleInputLine(argc, myargv, stdout);
+ free(myargv);
+ if (ret == 0){
+
#if HAVE_GETRUSAGE
#if HAVE_GETRUSAGE
- getrusage(RUSAGE_SELF,&myusage);
- gettimeofday(¤ttime,&tz);
- printf("OK u:%1.2f s:%1.2f r:%1.2f\n",
+
getrusage(RUSAGE_SELF,&myusage);
+
gettimeofday(¤ttime,&tz);
+
printf("OK u:%1.2f s:%1.2f r:%1.2f\n",
(double)myusage.ru_utime.tv_sec+
(double)myusage.ru_utime.tv_usec/1000000.0,
(double)myusage.ru_stime.tv_sec+
(double)myusage.ru_utime.tv_sec+
(double)myusage.ru_utime.tv_usec/1000000.0,
(double)myusage.ru_stime.tv_sec+
@@
-389,8
+389,11
@@
int main(int argc, char *argv[])
+(double)(currenttime.tv_usec-starttime.tv_usec)
/1000000.0);
#else
+(double)(currenttime.tv_usec-starttime.tv_usec)
/1000000.0);
#else
- printf("OK\n");
-#endif
+ printf("OK\n");
+
+#endif
+ }
+ }
fflush(stdout); /* this is important for pipes to work */
}
}
fflush(stdout); /* this is important for pipes to work */
}
}
@@
-426,7
+429,7
@@
int HandleInputLine(int argc, char **argv, FILE* out)
if (argc>1 && strcmp("quit", argv[1]) == 0){
if (argc>2){
printf("ERROR: invalid parameter count for quit\n");
if (argc>1 && strcmp("quit", argv[1]) == 0){
if (argc>2){
printf("ERROR: invalid parameter count for quit\n");
- return(
0
);
+ return(
1
);
}
exit(0);
}
}
exit(0);
}
@@
-434,43
+437,45
@@
int HandleInputLine(int argc, char **argv, FILE* out)
if (argc>1 && strcmp("cd", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for cd\n");
if (argc>1 && strcmp("cd", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for cd\n");
- return(
0
);
+ return(
1
);
}
#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: chdir security problem - rrdtool is running as "
"root an no chroot!\n");
}
#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: chdir security problem - rrdtool is running as "
"root an no chroot!\n");
- return(
0
);
+ return(
1
);
}
#endif
chdir(argv[2]);
if (errno!=0){
printf("ERROR: %s\n",rrd_strerror(errno));
}
#endif
chdir(argv[2]);
if (errno!=0){
printf("ERROR: %s\n",rrd_strerror(errno));
+ return(1);
}
return(0);
}
if (argc>1 && strcmp("mkdir", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for mkdir\n");
}
return(0);
}
if (argc>1 && strcmp("mkdir", argv[1]) == 0){
if (argc>3){
printf("ERROR: invalid parameter count for mkdir\n");
- return(
0
);
+ return(
1
);
}
#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: mkdir security problem - rrdtool is running as "
"root an no chroot!\n");
}
#if ! defined(HAVE_CHROOT) || ! defined(HAVE_GETUID)
if (getuid()==0 && ! ChangeRoot){
printf("ERROR: mkdir security problem - rrdtool is running as "
"root an no chroot!\n");
- return(
0
);
+ return(
1
);
}
#endif
mkdir(argv[2],0777);
if (errno!=0){
printf("ERROR: %s\n",rrd_strerror(errno));
}
#endif
mkdir(argv[2],0777);
if (errno!=0){
printf("ERROR: %s\n",rrd_strerror(errno));
+ return(1);
}
return(0);
}
if (argc>1 && strcmp("ls", argv[1]) == 0){
if (argc>2){
printf("ERROR: invalid parameter count for ls\n");
}
return(0);
}
if (argc>1 && strcmp("ls", argv[1]) == 0){
if (argc>2){
printf("ERROR: invalid parameter count for ls\n");
- return(
0
);
+ return(
1
);
}
if ((curdir=opendir("."))!=NULL){
while((dent=readdir(curdir))!=NULL){
}
if ((curdir=opendir("."))!=NULL){
while((dent=readdir(curdir))!=NULL){
@@
-552,7
+557,8
@@
int HandleInputLine(int argc, char **argv, FILE* out)
strcmp("v", argv[1]) == 0 ||
strcmp("-v", argv[1]) == 0 ||
strcmp("-version", argv[1]) == 0 )
strcmp("v", argv[1]) == 0 ||
strcmp("-v", argv[1]) == 0 ||
strcmp("-version", argv[1]) == 0 )
- printf("RRDtool 1.2.3 Copyright by Tobi Oetiker, 1997-2005\n");
+ printf("RRDtool " PACKAGE_VERSION " Copyright by Tobi Oetiker, 1997-2005 (%f)\n",
+ rrd_version());
else if (strcmp("restore", argv[1]) == 0)
rrd_restore(argc-1, &argv[1]);
else if (strcmp("resize", argv[1]) == 0)
else if (strcmp("restore", argv[1]) == 0)
rrd_restore(argc-1, &argv[1]);
else if (strcmp("resize", argv[1]) == 0)
@@
-586,13
+592,13
@@
int HandleInputLine(int argc, char **argv, FILE* out)
free (data);
}
} else if (strcmp("xport", argv[1]) == 0) {
free (data);
}
} else if (strcmp("xport", argv[1]) == 0) {
- int xxsize;
+ int xxsize;
unsigned long int j = 0;
time_t start,end, ti;
unsigned long step, col_cnt,row_cnt;
rrd_value_t *data,*ptr;
char **legend_v;
unsigned long int j = 0;
time_t start,end, ti;
unsigned long step, col_cnt,row_cnt;
rrd_value_t *data,*ptr;
char **legend_v;
- if(rrd_xport(argc-1, &argv[1], &xxsize,&start,&end,&step,&col_cnt,&legend_v,&data) != -1) {
+ if(rrd_xport(argc-1, &argv[1], &xxsize,&start,&end,&step,&col_cnt,&legend_v,&data) != -1) {
row_cnt = (end-start)/step;
ptr = data;
printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n", XML_ENCODING);
row_cnt = (end-start)/step;
ptr = data;
printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n", XML_ENCODING);