template for availability of a device

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
tecker2010
Posts: 24
Joined: Mon Jul 24, 2006 9:11 am
Location: Germany
Contact:

template for availability of a device

Post by tecker2010 »

Hi,

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.

Image

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;
?>
Attachments
cacti_data_template_availability.xml
(3.44 KiB) Downloaded 232 times
cacti_graph_template_availability.xml
(8.73 KiB) Downloaded 261 times
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Nice template - is there a better way to obtain the device ID ?
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests