|
|
| Author |
Message |
dan707
Joined: 16 Dec 2003 Posts: 1
|
Posted: Tue Dec 16, 2003 4:52 am Post subject: SNMP Information at graph_view.php page |
|
|
This short modification of the graph_view.php allows you to see a short SNMP Information about every system at the graph view page.
You have to paste the following code in your graph_view.php between line 256 to 276.
I have cacti 0.8.4.
| Code: |
print "<table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellspacing='2' cellpadding='3' border='0'>
<tr bgcolor='#" . $colors["header_panel"] . "'>
<td colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'>
<strong>SNMP Information</strong><br>
<span style='font-size: 10px; font-weight: normal; font-family: monospace;'>";
$host = db_fetch_row("select * from host where id=" . $_REQUEST["host_id"]);
$header_label = "[edit: " . $host["description"] . "]";
if (($host["snmp_community"] == "") && ($host["snmp_username"] == "")) {
print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
}else{
$snmp_system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.1.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
if ($snmp_system == "") {
print "<span style='color: #ff0000; font-weight: bold;'>SNMP error</span>\n";
}else{
$snmp_uptime = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.3.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_hostname = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.5.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_location = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.6.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
print "System: '$snmp_system'<br>\n";
print "Uptime: '$snmp_uptime'<br>\n";
print "Hostname: '$snmp_hostname'<br>\n";
print "Location: '$snmp_location'<br>\n";
}
}
print "</span></td></tr></table>";
print "<table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center'><tr>";
$i = 0; $k = 0;
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
print "<td align='center' width='" . (98 / read_graph_config_option("num_columns")) . "%'><br><a href='graph.php?rra_id=all&local_graph_id=" . $graph["local_graph_id"] . "'><img src='graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=" . (empty($set_rra_id) ? read_graph_config_option("default_rra_id") : $set_rra_id) . "&graph_start=-" . (empty($set_rra_id) ? read_graph_config_option("timespan") : "0") . "&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n";
$i++;
$k++;
if (($i == read_graph_config_option("num_columns")) && ($k < count($graphs))) {
$i = 0;
print "</tr><tr>";
}
}
}else{
print "<td><em>No Graphs Found.</em></td>";
}
print "</tr></table>";
print "<br><br>";
print "<table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellspacing='2' cellpadding='3' border='0'>
<tr bgcolor='#" . $colors["header_panel"] . "'>
<td colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'>
<strong>SNMP Information</strong><br>
<span style='font-size: 10px; font-weight: normal; font-family: monospace;'>";
$host = db_fetch_row("select * from host where id=" . $_REQUEST["host_id"]);
$header_label = "[edit: " . $host["description"] . "]";
if (($host["snmp_community"] == "") && ($host["snmp_username"] == "")) {
print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
}else{
$snmp_system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.1.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
if ($snmp_system == "") {
print "<span style='color: #ff0000; font-weight: bold;'>SNMP error</span>\n";
}else{
$snmp_uptime = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.3.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_hostname = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.5.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_location = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.6.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
print "System: '$snmp_system'<br>\n";
print "Uptime: '$snmp_uptime'<br>\n";
print "Hostname: '$snmp_hostname'<br>\n";
print "Location: '$snmp_location'<br>\n";
}
}
print "</span></td></tr></table>";
print "<table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center'><tr>";
$i = 0; $k = 0;
if (sizeof($graphs) > 0) {
foreach ($graphs as $graph) {
print "<td align='center' width='" . (98 / read_graph_config_option("num_columns")) . "%'><br><a href='graph.php?rra_id=all&local_graph_id=" . $graph["local_graph_id"] . "'><img src='graph_image.php?local_graph_id=" . $graph["local_graph_id"] . "&rra_id=" . (empty($set_rra_id) ? read_graph_config_option("default_rra_id") : $set_rra_id) . "&graph_start=-" . (empty($set_rra_id) ? read_graph_config_option("timespan") : "0") . "&graph_height=" . read_graph_config_option("default_height") . "&graph_width=" . read_graph_config_option("default_width") . "&graph_nolegend=true' border='0' alt='" . $graph["title_cache"] . "'></a></td>\n";
$i++;
$k++;
if (($i == read_graph_config_option("num_columns")) && ($k < count($graphs))) {
$i = 0;
print "</tr><tr>";
}
}
}else{
print "<td><em>No Graphs Found.</em></td>";
}
print "</tr></table>";
print "<br><br>";
|
Also you have to add:
| Code: | | include_once("./lib/snmp.php") |
At line 255 you have substitute:
with
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Wed Feb 18, 2004 4:35 pm Post subject: |
|
|
I added/changed the following to graph_view.php tobreakdown the uptime response into something useful to the viewers:
(I don't know php, so it's ugly but it works.)
$y = 217728000;
$m = 18144000;
$w = 604800;
$d = 86400;
$h = 3600;
$mn = 60;
$s = round($snmp_uptime/100);
$year = (floor($s/$y));
$month = (floor(($s%$y)/$m));
$week = (floor((($s%$y)%$m)/$w));
$day = (floor(((($s%$y)%$m)%$w)/$d));
$hour = (floor((((($s%$y)%$m)%$w)%$d)/$h));
$min = (floor(((((($s%$y)%$m)%$w)%$d)%$h)/$mn));
$sec = (((((($s%$y)%$m)%$w)%$d)%$h)%$mn);
print "System: '$snmp_system'<br>\n";
print "Uptime: $year yr(s) $month mo(s) $week wk(s) $day day(s) $hour hour(s) $min min(s) $sec sec(s)<br>\n";
print "Hostname: '$snmp_hostname'<br>\n";
print "Location: '$snmp_location'<br>\n";
|
|
| Back to top |
|
 |
Pumpi Cacti User
Joined: 14 Jan 2004 Posts: 256 Location: Germany
|
Posted: Thu Feb 19, 2004 5:31 am Post subject: |
|
|
has somebody tested dan707's mod on 0.8.5 ?
@ kurowsky
where should I insert these lines ?
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Thu Feb 19, 2004 8:45 am Post subject: |
|
|
I'm running 8.5 and it works.
one correction, I used the wrong values for year and month. russhing a little.
They should be:
$y = 31536000;
$m = 2592000;
I'll go ahead and attach the whole altered graph_view.php in a zip file.
| Description: |
|
 Download |
| Filename: |
graph_view.zip |
| Filesize: |
5.25 KB |
| Downloaded: |
513 Time(s) |
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Thu Feb 19, 2004 9:14 am Post subject: |
|
|
Oh, also ... I'd like to apply this same feature to the treeview but I don't know where to start.
If someone could point me in the right direction.
Is it in the same file?
|
|
| Back to top |
|
 |
Pumpi Cacti User
Joined: 14 Jan 2004 Posts: 256 Location: Germany
|
Posted: Thu Feb 19, 2004 9:49 am Post subject: Works now |
|
|
Good work - works for me also kurowsky
|
|
| Back to top |
|
 |
Morgan Cacti User
Joined: 25 Feb 2004 Posts: 187
|
Posted: Mon Mar 29, 2004 5:24 am Post subject: |
|
|
could someone post a screenshot of what information this actually adds?
thanks!
M
|
|
| Back to top |
|
 |
Pumpi Cacti User
Joined: 14 Jan 2004 Posts: 256 Location: Germany
|
Posted: Mon Mar 29, 2004 10:07 am Post subject: |
|
|
Not yet possible, still having this problem:
http://www.raxnet.net/board/viewtopic.php?t=3578
You can see in the Preview View hostname, description, uptime, location etc.
Perhaps you have an idea for my problem above ?
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Thu Nov 17, 2005 3:03 pm Post subject: |
|
|
Better late than never....
| Description: |
|
| Filesize: |
82.42 KB |
| Viewed: |
13679 Time(s) |

|
|
|
| Back to top |
|
 |
noskill
Joined: 21 Feb 2005 Posts: 32
|
Posted: Tue Nov 22, 2005 7:33 am Post subject: |
|
|
| can you post a newer version of that for 0.8.6f ? It seems alot of the code changes make it unusuable.
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Tue Jan 17, 2006 3:39 pm Post subject: SNMP Info in Graph tree |
|
|
**** Edited - Code is correct now also took Month Variables out for correctness ****
Took me a while, but after bastardizing some of the code finally got the results I wanted. And I don't think I broke anything yet.....
Using Cacti 8.6h
You can give this a shot if you like ....
in ../lib/html_tree.php add the following:
line 457:
| Code: | | include_once($config["library_path"] . "/snmp.php"); |
line 519: .......
BETWEEN
| Code: |
/* include time span selector */
if (read_graph_config_option("timespan_sel") == "on") {
html_graph_start_box(3, false);
include("./include/html/inc_timespan_selector.php");
html_graph_end_box();
print "<br>";
}
|
and
| Code: |
/* start graph display */ |
Paste the following:
| Code: | /* start SNMP information*/
if (empty($leaf_id)) { return; }
if (!empty($leaf_id)) {
$host = db_fetch_row ("select * from (graph_tree_items,host) where graph_tree_items.host_id=host.id and graph_tree_items.id=$leaf_id");}
html_graph_start_box(3, false);
print "<table width='98%' style='background-color: #f5f5f5; border: 1px solid #bbbbbb;' align='center' cellspacing='2' cellpadding='3' border='0'>
<tr bgcolor='#" . $colors["header_panel"] . "'>
<td colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'>
<strong>SNMP Information</strong><br>
<span style='font-size: 10px; font-weight: normal; font-family: monospace;'>";
if (($host["snmp_community"] == "") && ($host["snmp_username"] == "")) {
print "<span style='color: #ab3f1e; font-weight: bold;'>SNMP not in use</span>\n";
}else{
$snmp_system = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.1.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
if ($snmp_system == "") {
print "<span style='color: #ff0000; font-weight: bold;'>SNMP error</span>\n";
}else{
$snmp_uptime = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.3.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_hostname = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.5.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$snmp_location = cacti_snmp_get($host["hostname"], $host["snmp_community"], ".1.3.6.1.2.1.1.6.0", $host["snmp_version"], $host["snmp_username"], $host["snmp_password"], $host["snmp_port"], $host["snmp_timeout"]);
$y = 31536000;
$w = 604800;
$d = 86400;
$h = 3600;
$mn = 60;
$s = round($snmp_uptime/100);
$year = (floor($s/$y));
$month = (floor($s%$y));
$week = (floor(($s%$y)/$w));
$day = (floor((($s%$y)%$w)/$d));
$hour = (floor(((($s%$y)%$w)%$d)/$h));
$min = (floor((((($s%$y)%$w)%$d)%$h)/$mn));
$sec = ((((($s%$y)%$w)%$d)%$h)%$mn);
print "System: '$snmp_system'<br>\n";
print "<span style='color: #00FF00; font-size: 12px; font-weight: bold;'>Uptime: $year yr(s) $week wk(s) $day day(s) $hour hr(s) $min min(s) $sec sec(s)</span><br>\n";
print "Hostname: '$snmp_hostname'<br>\n";
print "Location: '$snmp_location'<br>\n";
}
}
print "</span></td>";
html_graph_end_box();
print "<br>"; |
Don't forget to back up the original...
-Brian
| Description: |
|
| Filesize: |
112.15 KB |
| Viewed: |
12863 Time(s) |

|
Last edited by kurowsky on Tue Oct 31, 2006 3:29 pm; edited 2 times in total |
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Tue Jan 17, 2006 4:39 pm Post subject: |
|
|
Spoke too soon. Found one error.
If you click on the root of the tree you get an undefined variable error.
I'll see if I can get that fixed.
Other than that, I believe it's okay.
|
|
| Back to top |
|
 |
knobdy Cacti User
Joined: 28 Sep 2005 Posts: 495
|
Posted: Tue Jan 17, 2006 6:00 pm Post subject: |
|
|
Sweet! I looked at the differences in the code posted here (in the zip for graph view) and what is currently in h - wouldn't know where to start!
Be sure to let us know if you work out an h version for the list view!
|
|
| Back to top |
|
 |
kurowsky
Joined: 04 Feb 2004 Posts: 46 Location: Richmond, VA.
|
Posted: Tue Jan 17, 2006 6:45 pm Post subject: |
|
|
Okay, think I fixed the error.
Forgot one line.
Need to append this to the very beginning:
| Code: | | if (empty($leaf_id)) { return; } |
As for the the list view... Don't mind giving it a shot.
Not a coder though..
Better at reverse egineering ...
Just always thought this was nice info to have showing.
-Brian
|
|
| Back to top |
|
 |
knobdy Cacti User
Joined: 28 Sep 2005 Posts: 495
|
Posted: Tue Jan 17, 2006 7:50 pm Post subject: |
|
|
| kurowsky wrote: | | Need to append this to the very beginning: |
Does this mean where we first inserted code in the original?
| Quote: | As for the the list view... Don't mind giving it a shot.
Not a coder though.. |
Me either - I've been reversing perl scripts for the last month...it's frustrating at times, but fun.
| Quote: | | Just always thought this was nice info to have showing. |
I agree and it makes me want to develop a seperate plugin for Cacti...it would grab this information but then correlate it with info from Cisco in regards to updates, EOL, etc.. that'd be nice. A lot like the tool Cisco is selling/giving to their partners but not their customers. Hmm...is this grabbing model? Not in the office to check right now, but if not, is it hard to add?
|
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|