ce9f3bb91432938ee2de66dbf39772ee95b8e810
1 /*****************************************************************************
2 * RRDtool 1.3.3 Copyright by Tobi Oetiker, 1997-2008
3 *****************************************************************************
4 * rrd_last.c
5 *****************************************************************************
6 * Initial version by Russ Wright, @Home Network, 9/28/98
7 *****************************************************************************/
9 #include "rrd_tool.h"
11 time_t rrd_last(
12 int argc,
13 char **argv)
14 {
15 if (argc < 2) {
16 rrd_set_error("please specify an rrd");
17 return (-1);
18 }
20 return (rrd_last_r(argv[1]));
21 }
24 time_t rrd_last_r(
25 const char *filename)
26 {
27 time_t lastup = -1;
28 rrd_file_t *rrd_file;
30 rrd_t rrd;
32 rrd_file = rrd_open(filename, &rrd, RRD_READONLY);
33 if (rrd_file != NULL) {
34 lastup = rrd.live_head->last_up;
35 rrd_close(rrd_file);
36 }
37 rrd_free(&rrd);
38 return (lastup);
39 }