using a script to download images of graphs

Asked by rayKwebster

I would like to have a script download the graphs nagiosgrapher produces into files. I would like to incorporate those files into an email and send it off everyday.

I am using a php script to emulate the links that are provided by nagiosgrapher for the png filetype on a graph. That link includes a number of posted variables to allow the cgi script to make the graph. I get a png file created with the following error on it;

RRD Error: start time: unparsable time:

Here is the link that I am attempting to emulate from the live webpage;

https://itinventory.alderfer.local/cgi-bin/nagios3/rrd2-system.cgi?host=temptrax;service=Quick_Chill;width=720;height=250;type=AVERAGE;title=1 Current;start=-21600;end=1327617467;imageformat=png

Here is a listing of the code I have to emulate that link:

#!/usr/bin/php
<?php
$ch = curl_init();
$right_now=time();
$fields = array(
 'host'=>urlencode('temptrax'),
 'service'=>urlencode('Main_Warehouse'),
 'width'=>urlencode('720'),
 'height'=>urlencode('250'),
 'type'=>urlencode('AVERAGE'),
 'title'=>urlencode('1 Current'),
 'start'=>urlencode(-21600),
 'end'=>urlencode($right_now),
 'imageformat'=>urlencode('png')
 );
$url="https://itinventory.alderfer.local/cgi-bin/nagios3/rrd2-system.cgi";

$fp = fopen("test.png", "w");

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,"FALSE");
curl_setopt($ch, CURLOPT_USERPWD, "guest:");
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

$results=curl_exec($ch);

fclose($fp);
?>

I have tried many different forms of start time to see if the error would at least change, but it does not. I found a few items on the web that sugest the it might be a php variable issue, specifically register_globals needs to be off. It is, but that does not seem to be my problem.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu nagiosgrapher Edit question
Assignee:
No assignee Edit question
Solved by:
rayKwebster
Solved:
Last query:
Last reply:
Revision history for this message
rayKwebster (rkwebster) said :
#1

I researched this issue some more and found I could use rrdtool directly to create graphs and not have to have nagiosgrapher's website produce them for me. rrdtool is what nagiosgrapher uses to create the graph so why souldn't I.