Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Multiple 3Com Switches

 
Post new topic   Reply to topic    Cacti Forum Index -> Help: Linux/Unix Specific
Author Message
Damin



Joined: 15 Feb 2003
Posts: 2

PostPosted: Sat Feb 15, 2003 6:57 pm    Post subject: Multiple 3Com Switches Reply with quote

Hello,
I have run accross an issue in Cacti 0.6.8a that I'd like some comments on. It's possible that I'm just missing something obvious, but I figure if that is the case, someone will point it out and I'll smack my forehead. The problem arises when attempting to create graphs for multiple switches of the same type. In my particular case, this is using 3Com SuperStack II Switch 1100 units. I have two of them on my network, and both return the exact same Interface Numbers and Descriptions for each port. This leads to Cacti creating the exact same Data Source Names for both switches.
The end result is that the two sets of graphs are exactly alike, but they are using only one set of RRD files. My first reaction was to try and change the description on the switch's SNMP descriptions, but that is a dead end. My second idea was to see if there are any ways that you can specify the Datasource Name "Prefix" for a specific SNMP host in Cacti, but could find no way to do this. It appears that Cacti creates it's Data Source Names on the fly from the SNMP data it returns.
It occurred to me that the 3Com stuff is probably not the only brain-dead SNMP equipment out there and that this probably affects other people. If so, I'd love to hear what your suggestion was. I'd hate to think that I'll have to manipulate all of the stuff by hand as that sort of takes the "fun" out of the Auto-Configure options (and makes a hell of a lot more work for me.)
So, I started to think about ways that this problem could be easily fixed and I came up with the following fizzles of brain activity:

1. Add a field called "DSN Alias" to the snmp_hosts table. If this table filed is not null, then use it to create the Datasource name. For example, if the DSN Alias is set to "3com-1100-1" then append this to the beginning of the Datasource name.

Under Current Code, the DSN would be:
traf_rmon_10100_port_25_on_unit_1_125_in

With a DSN Alias, the DSN would look like:
3com-1100-1_traf_rmon_10100_port_25_on_unit_1_125_in

2. To prevent datasource names from getting all crazy long and out of control, how about adding some configurability to the DSN Nameing behaviour? For example, allow the DSN to be created using similar "macro" capability that Create Graph uses. Under this system, a user could specify that DSN names could use:
<dsn_alias>
<snmp_description>
<snmp_interface_number>
<snmp_interface_speed>
<snmp_hardware_address>
<snmp_ip_address>

So, if I wanted to create DSNs that used the DSN Alias, I could specify the naming behaviour as:
<dsn_alias>_<snmp_interface_number>

Or.. any other combination of macros that I wanted to use.

This would have the additional benefit of making DSNs more meaningful, making the .rrd files more "meaningful" and allowing a higher level of configurability. Of course, I'm probably missing something really simple in the existing code that performs this function.

Comments?
Back to top
bulek
Cacti Pro User


Joined: 20 May 2002
Posts: 852
Location: Poland

PostPosted: Sun Feb 16, 2003 8:23 am    Post subject: Reply with quote

You don't miss anything. Cacti creates DS name in form:
traf_[ip_addr]_[interface_number]

If IP address field is empty (what is the case on most of switches) then it uses:
traf_[interface_description]_[interface_number]

For two similar switches as a result you will get exactly the same DS names of related interfaces. Your solution number two is flexible and looks good. If you just need quick and easy change that will allow for automated graph generation then I propose something simpler. You can by default add hostname field of snmp_hosts table just after "traf_". Every DS name in this case will start with traf_[hostname]_..... this makes unique DS names generation for every switch. You need to make such changes in snmp_interfaces.php around line 66 and 115.

- bulek
Back to top
Damin



Joined: 15 Feb 2003
Posts: 2

PostPosted: Sun Feb 16, 2003 8:44 pm    Post subject: Reply with quote

Excellent! Here is a combined patch that implements everything you need to make 3Com switches (and potentially other hardware) play nicely with Cacti. After reviewing the code, I chose to simply implement a naming convention that included the "hostid" from the snmp_interfaces table. Simple patch, but it works and it's effective for me. I've also included the patch to translate the ":" colon character that 3Com gear returns as that causes failures in the RRD arguement parsing routines.

There is a great possibility that this may hose stuff for certain people, and may violate someone's design intentions. If that's the case, please make appropriate suggestions and/or include patches that provide an alternate, more "correct" solution in the next release. If not, feel free to clean this up and slap it into the CVS tree. Comments and flames welcome!

Here is the patch.. If formatting is hosed, you can pick it up at ftp://ftp.nacs.net/cacti/cacti-0.6.8a-3com-fix.patch

Code:

--- cacti/include/functions.php.greg    Thu Sep  5 17:20:52 2002
+++ cacti/include/functions.php Sun Feb 16 20:35:11 2003
@@ -145,8 +145,13 @@
 }
 
 function CleanUpName($string) {
-       $new_string = ereg_replace("[ ]|[.]|[)]|[(]","_",$string);
-       $new_string = ereg_replace("[*]|[/]|[\]|[*]|[&]|[%]|[\"]|[\']|[,]|[)]|[(]","",$new_string);
+        /*
+        * Gregory J. Boehnlein <damin@nacs.net> - 2/15/2003
+        * Added colon substitution to deal with 3Com hardware.
+        *
+        */
+       $new_string = ereg_replace("[ ]|[.]|[)]|[(]|[:]","_",$string);
+       $new_string = ereg_replace("[*]|[/]|[\]|[*]|[&]|[%]|[\"]|[\']|[,]|[)]|[(]|[:]","",$new_string);
 
        return $new_string;
 }
--- cacti/snmp_interfaces.php.greg      Sun Feb 16 19:31:57 2003
+++ cacti/snmp_interfaces.php   Sun Feb 16 20:17:33 2003
@@ -63,8 +63,23 @@
                /* get a nice default name */
                $sql_id = mysql_query("select * from snmp_hosts_interfaces where id=$id", $cnn_id);
 
-               if (mysql_result($sql_id, 0, "ipaddress") == "") {
-                       $snmp_description = mysql_result($sql_id, 0, "description") . "_" . mysql_result($sql_id, 0, "interfacenumber");
+                /*
+                * Do some intelligent DSN Creation - Gregory J. Boehnlein <damin@nacs.net> - 2/16/2003
+                * This helps us deal with situations whereby we are using two devices that return the
+                * exact same information for all interfaces, such as 3COM SSII-1100 Units.
+                *
+                * In the event that the interface does not have an IP Address, we use a naming scheme that
+                * is built using the following naming convention:
+                *
+                * [hostid]_[description]_[interfacenumber]
+                *
+                * otherwise the standard convention is:
+                *
+                * [ipaddress]_[interfacenumber]
+                *
+                */
+                if (mysql_result($sql_id, 0, "ipaddress") == "") {
+                       $snmp_description = mysql_result($sql_id, 0, "hostid") . "_" . mysql_result($sql_id, 0, "description") . "_" . mysql_result($sql_id, 0, "interfacenumber");
                }else{
                        $snmp_description = mysql_result($sql_id, 0, "ipaddress") . "_" . mysql_result($sql_id, 0, "interfacenumber");
                }
@@ -111,9 +126,25 @@
                DrawFormItem("Data Source Name(s)","Please enter a name for the data source, this name
                        cannot contain spaces or other strange charcters.");
 
-               while ($i < $rows) {
-                       if (mysql_result($sql_id, $i, "ipaddress") == "") {
-                               $snmp_description = mysql_result($sql_id, $i, "description") . "_" . mysql_result($sql_id, $i, "interfacenumber");
+                       /*
+                        * Do some intelligent DSN Creation - Gregory J. Boehnlein <damin@nacs.net> - 2/16/2003
+                        * This helps us deal with situations whereby we are using two devices that return the
+                        * exact same information for all interfaces, such as 3COM SSII-1100 Units.
+                        *
+                        * In the event that the interface does not have an IP Address, we use a naming scheme that
+                        * is built using the following naming convention:
+                        *
+                        * [hostid]_[description]_[interfacenumber]
+                        *
+                        * otherwise the standard convention is:
+                        *
+                        * [ipaddress]_[interfacenumber]
+                        *
+                        */
+
+                  while ($i < $rows) {
+                       if (mysql_result($sql_id, $i, "ipaddress") == "") {
+                               $snmp_description = mysql_result($sql_id, $i, "hostid") . "_" . mysql_result($sql_id, $i, "description") . "_" . mysql_result($sql_id, $i, "interfacenumber");
                        }else{
                                $snmp_description = mysql_result($sql_id, $i, "ipaddress") . "_" . mysql_result($sql_id, $i, "interfacenumber");
                       
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Help: Linux/Unix Specific All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group