SNMP Information at graph_view.php page

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

NivenHuH
Posts: 4
Joined: Wed Nov 28, 2007 2:07 pm
Location: SF, CA

Post by NivenHuH »

I made a few mods and got it working on 0.8.7a... didn't put in the variables for SNMPv3 (what the NULLs are):

Code: Select all

$ diff graph_view.php.original graph_view.php

29a30
> include("./lib/snmp.php");
265a267,316
> /*start SNMP Information*/ 
>         html_graph_start_box(1, true); 
>         $host = db_fetch_row("select * from host where id=" . $_REQUEST["host_id"]); 
>          print "<table width='98%' style='background-color: #6d88ad; border: 1px solid #bbbbbb;' align='center' cellspacing='2' cellpadding='3' border='0'> 
>          <td colspan='" . read_graph_config_option("num_columns") . "' class='textHeaderDark'> 
> 	    <strong>" . $host["description"] . " (" . $host["hostname"] .")" . "</strong><br />";
>             if ($host["notes"]) { print "Description: " . $host["notes"] . "<br />"; }
>             print "<br />
>             <strong>SNMP Information</strong><br> 
>             <span style='font-size: 10px; font-weight: normal; font-family: monospace;'>"; 
>                $header_label = "[edit: " . $host["description"] . "]"; 
> 
>                   if ((($host["snmp_community"] == "") && ($host["snmp_username"] == "")) || ($host["snmp_version"] == 0)) { 
>                   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"],NULL,NULL,NULL,NULL, $host["snmp_port"], $host["snmp_timeout"],NULL,NULL); 
> 
>                   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"],NULL,NULL,NULL,NULL, $host["snmp_port"], $host["snmp_timeout"],NULL,NULL); 
>                      $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"],NULL,NULL,NULL,NULL, $host["snmp_port"], $host["snmp_timeout"],NULL,NULL); 
>                      $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"],NULL,NULL,NULL,NULL, $host["snmp_port"], $host["snmp_timeout"],NULL,NULL); 
> 
>                   $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>";

Last edited by NivenHuH on Wed Dec 05, 2007 1:04 pm, edited 1 time in total.
NivenHuH
Posts: 4
Joined: Wed Nov 28, 2007 2:07 pm
Location: SF, CA

Post by NivenHuH »

nduda78 wrote:Maybe I am missing something here, but I dont see the SNMP stuff in Tree mode, only in Preview mode. ALl i did was use the diff patch against my graph-view.php

Ideas?
Same here.. I think a different section needs to be modified to accommodate tree mode.

This works good enough for me (since the monitor plugin drops you into preview mode)
prof
Posts: 7
Joined: Fri Jul 11, 2008 6:08 am

Post by prof »

I have rewritten 4 Files, just check if this is somethin for you.

Just replace them. They were written for cacti 0.8.7b.

I have used the SNMP Information Code from NivenHuH.

html*.php goes into /cacti/site/lib
graph*.php goes into /cati/site

The files give you extra information in Preview, Tree mode and in Zoom.
Attachments
graph.php.txt
Rename to graph.php
(11.46 KiB) Downloaded 3245 times
graph_view.php.txt
Rename to graph_view.php
(28.4 KiB) Downloaded 3249 times
html.php.txt
Rename to html.php
(30.61 KiB) Downloaded 3249 times
html_tree.php.txt
Rename to html_tree.php
(41.06 KiB) Downloaded 3266 times
User avatar
streaker69
Cacti Pro User
Posts: 712
Joined: Mon Mar 27, 2006 10:35 am
Location: Psychic Amish Network Administrator

Post by streaker69 »

Very cool, I just added these to mine, works well.

Question: Is there a reason you didn't include the Contact information, Just location and Hostname?
[b]Cacti Version[/b] - 0.8.7d
[b]Plugin Architecture[/b] - 2.4
[b]Poller Type[/b] - Cactid v
[b]Server Info[/b] - Linux 2.6.18-128.1.6.el5
[b]Web Server[/b] - Apache/2.2.3 (CentOS)
[b]PHP[/b] - 5.2.9
[b]MySQL[/b] - 5.0.45-log
[b]RRDTool[/b] - 1.3.0
[b]SNMP[/b] - 5.3.2.2
[b]Plugins[/b]PHP Network Managing v0.6.1, Global Plugin Settings v0.6,thold v0.4.1,XMLPort v0.3.5,CactiCam v0.1.5,NetTools v0.1.5,pollperf v0.32,RRD Cleaner v1.1,sqlqueries v0.2,superlinks v0.8,syslog v0.5.2,update v0.4,discovery v0.9,zond v0.34a,hostinfo v0.2,Bloom v0.6.5,mactrack v1.1,weathermap v0.96a,mobile v0.1
prof
Posts: 7
Joined: Fri Jul 11, 2008 6:08 am

Post by prof »

Hi,

you are right, in the code samples in this thread, there is not the contact info. I have added it in the html.php. Just copy it to the lib directory.
Attachments
html.php.txt
Updated Version with Contact Information.
(30.9 KiB) Downloaded 3220 times
User avatar
chrisgapske
Cacti User
Posts: 278
Joined: Tue May 22, 2007 7:56 am
Location: Pensacola, Fl - Padacuh, Ky-Alpena, MI-Gulf Shores,AL

Post by chrisgapske »

The only thing I find it to be very slow .. When pulling up graphs ?
gifty
Posts: 21
Joined: Thu Jul 17, 2008 1:47 pm

Post by gifty »

Hey .. Thanks a lot for scripts ..
I have 1 question.

What it does is, it print "snmp information" with every thumbnail showing on 1 page, although its all same.

Is it possible to remove information from each and every thumbnail and show it just once and have information when we see graph.

Please help me out here.

Thanks a lot.

-Vineet Singh
gifty
Posts: 21
Joined: Thu Jul 17, 2008 1:47 pm

Post by gifty »

Problem solved ..
just removed 1 line ...
from html.php

205c146
<? add_snmp_to_graph($graph["local_graph_id"]); ?>
..

And it worked ..

If anyone need to remove excess of information which is same, he can do this .

Thanks :-)

-Vineet Singh
mgb
Cacti User
Posts: 124
Joined: Mon Jun 21, 2004 4:06 am
Location: North of the Netherlands

Post by mgb »

If I implement this on 0.8.7b with SPINE running and weathermap I recieve Script server errors and weathermap does not work anymore.
SPINE: Poller[0] ERROR: SS[999] Script Server did not start properly return message was: ''
any idea?

Michael
gifty
Posts: 21
Joined: Thu Jul 17, 2008 1:47 pm

Post by gifty »

It is working perfectly for me, but i have not installed spine with it.

-Vineet Singh
r_chetanjain
Cacti User
Posts: 83
Joined: Fri Aug 22, 2003 4:33 am

patch for 0.8.7d with PA 2.4

Post by r_chetanjain »

Hi Any patch for Cacti 0.8.7d wtih PA 2.4.... I stopped working after upgrade

Chetan
jb_008
Posts: 8
Joined: Sun Mar 14, 2010 5:00 am

Post by jb_008 »

I am running Version 0.8.7d and this does not seem to be working. Anyone able to get this working as this would be a very useful mod for me.

Thanks
tonyperez
Posts: 34
Joined: Sat Nov 05, 2005 12:43 am
Location: Guadalajara, Jalisco, Mexico

Post by tonyperez »

Hi ..

I have SNMP Information working on version 0.8.7d with PA 2.4 and the security patches installed.

I have used the SNMP information code from nivenHuH and PROF.

This files shows SNMP Information on tree graph, graph view and zoom action.

Just replace the files -- don't forget to backup first!!! --. I hope this help to u guys.

Cheers !!!!
Attachments
html_tree.php.txt
Replace on /&lt;path to cacti&gt;/lib/
(61.16 KiB) Downloaded 3103 times
graph.php.txt
Replace on /&lt;path to cacti&gt;/
(12.11 KiB) Downloaded 3144 times
html.php.txt
Replace on /&lt;path to cacti&gt;/lib/
(37.58 KiB) Downloaded 2987 times
jb_008
Posts: 8
Joined: Sun Mar 14, 2010 5:00 am

Post by jb_008 »

Hum, do I need to revert the graph_view.php back to the original file or use the one from PROF? I over wrote the ones I had download last night from PROF with your new ones but nothing is showing up yet.

I am not the biggest linux user so I maybe doing something wrong, but I take it that if I just over write these files it should display the snmp data correct, or is there a modification that I missed that goes along with these files?
tonyperez
Posts: 34
Joined: Sat Nov 05, 2005 12:43 am
Location: Guadalajara, Jalisco, Mexico

Post by tonyperez »

Hum, do I need to revert the graph_view.php back to the original file or use the one from PROF? I over wrote the ones I had download last night from PROF with your new ones but nothing is showing up yet.

I am not the biggest linux user so I maybe doing something wrong, but I take it that if I just over write these files it should display the snmp data correct, or is there a modification that I missed that goes along with these files?
I forgot to include the graph_view.php file !!!! My mistake. :oops:

Here's the file.
Attachments
graph_view.php.txt
Replace on /&lt;cacti path&gt;/
(40.4 KiB) Downloaded 2991 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest