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;
20 opterr = 0; /* initialize getopt */
25 static struct option long_options[] = {
26 {"daemon", required_argument, 0, 'd'},
30 opt = getopt_long(argc, argv, "d:", long_options, &option_index);
37 if (opt_daemon != NULL)
39 opt_daemon = strdup (optarg);
40 if (opt_daemon == NULL)
42 rrd_set_error ("strdup failed.");
48 rrd_set_error ("Usage: rrdtool %s [--daemon <addr>] <file>",
55 if ((argc - optind) != 1) {
56 rrd_set_error ("Usage: rrdtool %s [--daemon <addr>] <file>",
61 rrdc_connect (opt_daemon);
62 if (rrdc_is_connected (opt_daemon))
63 lastupdate = rrdc_last (argv[optind]);
66 lastupdate = rrd_last_r(argv[optind]);
68 if (opt_daemon) free(opt_daemon);
81 rrd_file = rrd_open(filename, &rrd, RRD_READONLY);
82 if (rrd_file != NULL) {
83 lastup = rrd.live_head->last_up;