1 /*****************************************************************************
2 * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010
3 *****************************************************************************
5 *****************************************************************************
6 * Initial version by Russ Wright, @Home Network, 9/28/98
7 *****************************************************************************/
10 #include "rrd_client.h"
16 char *opt_daemon = NULL;
22 opterr = 0; /* initialize getopt */
27 static struct option long_options[] = {
28 {"daemon", required_argument, 0, 'd'},
29 {"noflush", no_argument, 0, 'F'},
33 opt = getopt_long(argc, argv, "d:F", long_options, &option_index);
40 if (opt_daemon != NULL)
42 opt_daemon = strdup (optarg);
43 if (opt_daemon == NULL)
45 rrd_set_error ("strdup failed.");
55 rrd_set_error ("Usage: rrdtool %s [--daemon <addr> [--noflush]] <file>",
62 if ((argc - optind) != 1) {
63 rrd_set_error ("Usage: rrdtool %s [--daemon <addr> [--noflush]] <file>",
69 status = rrdc_flush_if_daemon(opt_daemon, argv[optind]);
70 if (status) return (-1);
73 rrdc_connect (opt_daemon);
74 if (rrdc_is_connected (opt_daemon))
75 lastupdate = rrdc_last (argv[optind]);
78 lastupdate = rrd_last_r(argv[optind]);
92 rrd_file = rrd_open(filename, &rrd, RRD_READONLY);
93 if (rrd_file != NULL) {
94 lastup = rrd.live_head->last_up;