1 /*****************************************************************************
2 * RRDtool 1.2.23 Copyright by Tobi Oetiker, 1997-2007
3 *****************************************************************************
4 * rrd_lastupdate Get the last datum entered for each DS
5 *****************************************************************************/
8 #include "rrd_rpncalc.h"
12 rrd_lastupdate(int argc, char **argv, time_t *last_update,
13 unsigned long *ds_cnt, char ***ds_namv, char ***last_ds) {
20 rrd_set_error("please specify an rrd");
25 if(rrd_open(filename,&in_file,&rrd, RRD_READONLY)==-1){
30 *last_update=rrd.live_head->last_up;
31 *ds_cnt = rrd.stat_head->ds_cnt;
33 (char **) malloc(rrd.stat_head->ds_cnt * sizeof(char*)))==NULL){
34 rrd_set_error("malloc fetch ds_namv array");
40 (char **) malloc(rrd.stat_head->ds_cnt * sizeof(char*)))==NULL){
41 rrd_set_error("malloc fetch last_ds array");
47 for(i=0;i<rrd.stat_head->ds_cnt;i++){
48 (*ds_namv)[i] = sprintf_alloc("%s", rrd.ds_def[i].ds_nam);
49 (*last_ds)[i] = sprintf_alloc("%s", rrd.pdp_prep[i].last_ds);