last time I was looking for a template to graph the availability of a device (historical) but I couldn' t find. So I made one by myself. It's based on a little PHP script which queries the status of any device from mysql (via ID) and return integer 1 for status "up" and 0 else. So with a corresponding CDEF I have a graph which shows the availability (0% or 100%) and the average value. The ID of the host must be enter at the data source.
May be it could be helpfull for someone else. Don' t know whether someone else made such a thing before ...
Comments are welcome.
Code: Select all
<?php
/*
####################################################################
# FILE: /usr/local/apache2/htdocs/cacti/scripts/availability.php
# DATE: 05-04-2007
####################################################################
*/
$Variable1 = 1;
$Variable2 = 0;
$Cast1 = (integer) $Variable1;
$Cast2 = (integer) $Variable2;
$ID = $_SERVER["argv"][1];
mysql_connect( "localhost", "user", "password" );
mysql_select_db("cacti");
$print = "SELECT status from host WHERE id=$ID";
$result = mysql_query( $print);
$data = mysql_fetch_row ($result );
foreach ( $data as $value)
if ( $value > 2 )
echo $Cast1;
else echo $Cast2;
?>