RRD.php help

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

Moderators: Developers, Moderators

Post Reply
jfuchtm
Posts: 6
Joined: Mon Mar 24, 2008 6:51 pm

RRD.php help

Post by jfuchtm »

I am trying to update an old script for system uptime that displayed as a comment line. Here is what it was in version 8.5 and prior?

Code: Select all

		/* System uptime */
 			if (strstr($current_field, "|sys_uptime|")) {
 
 				$hostdata = db_fetch_row("select host.hostname, host.snmp_community
 					from host, graph_local, graph_templates_graph
 					where graph_local.host_id=host.id
 					and graph_local.id=graph_templates_graph.local_graph_id
 					and graph_templates_graph.local_graph_id=$local_graph_id");
 
 				@$uptime = exec("/var/www/htdocs/cacti/scripts/snmp_cisco_uptime.sh " . $hostdata["snmp_community"] . " " . $hostdata["hostname"]);
 
 				$current_field = str_replace("|sys_uptime|", $uptime, $current_field);
 
 			}

Here is what I have so far but I am sure the database call is not correct anymore.

Code: Select all

				/* System uptime */
				if (strstr($graph_variables[$field_name][$graph_item_id], "|sys_uptime|")) {
 
 				$hostdata = db_fetch_row("select host.hostname, host.snmp_community
 					from host, graph_local, graph_templates_graph
 					where graph_local.host_id=host.id
 					and graph_local.id=graph_templates_graph.local_graph_id
 					and graph_templates_graph.local_graph_id=$local_graph_id");
 
 				@$uptime = exec("/var/www/htdocs/cacti/scripts/snmp_cisco_uptime.sh " . $hostdata["snmp_community"] . " " . $hostdata["hostname"]);
 
 				$graph_variables[$field_name][$graph_item_id] = str_replace("|sys_uptime|", $uptime, $graph_variables[$field_name][$graph_item_id]);
 
 				}
I think the only part I need some expert assistance with is:

Code: Select all

 				$hostdata = db_fetch_row("select host.hostname, host.snmp_community
 					from host, graph_local, graph_templates_graph
 					where graph_local.host_id=host.id
 					and graph_local.id=graph_templates_graph.local_graph_id
 					and graph_templates_graph.local_graph_id=$local_graph_id");
 
but I could be wrong. Any help would be appreaceated!

Thanks
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please tell us first, what you're aiming at
Reinhard
jfuchtm
Posts: 6
Joined: Mon Mar 24, 2008 6:51 pm

Post by jfuchtm »

I am trying to get the smnp uptime to display on the graph much like data_time does. I found some old coding on in the scripts forum that worked on version 8.5 and prior. I have seen the plug in's for uptime, I would just like a simple uptime on the graph, much like MRTG does. The orginal post I found here was here: http://forums.cacti.net/viewtopic.php?t=2546 I stared wiht the code named rrd_php_show_uptime.zip.

Thank for any help you can provide.

Jeff
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

The sysUpTime is not stored in the host table. That's bad. So the code you've posted queries for the current sysUptime. That's bad as well.
I was think of using the last_recovery_timestamp of the host table; but that seems not to fit.
It would be able to supply the missing feature by coding a plugin (which would almost be the tiniest plugin ever seen); IMHO not recommended as well.
The "proper" solution would include
- changing the host table
- changing both cmd.php and spine
- changing /lib/variables.php, function substitute_host_data
That sums up to be a _real_ feature request.
Reinhard
jfuchtm
Posts: 6
Joined: Mon Mar 24, 2008 6:51 pm

Post by jfuchtm »

Agreed, it seems to have been a feature request for quite some time.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests