[TODO] mactrack_strip_alpha function not working correctly

Support questions about the MAC Track plugin

Moderators: Moderators, Developers

Post Reply
Author
Message
User avatar
edc1
Posts: 4
Joined: Fri Dec 18, 2009 5:40 am

[TODO] mactrack_strip_alpha function not working correctly

#1 Post by edc1 » Fri Dec 18, 2009 5:49 am

I've been getting some of our Enterasys switches working with Mactrack and there's a problem with the mactrack_strip_alpha function not removing all alpha characters from the ifType string. The Enterasys switch returns values like this:

rs232(33)
ieee8023adLag(161)

for serial ports and lag ports. mactrack_strip_alpha will return:

rs232(33
ieee8023adLag(161

for these. I've changed the function to this:

function mactrack_strip_alpha($string = "")
{
$matches;
if (preg_match('/^.*\((\d+)\)$/', $string, $matches) == 1)
{
return $matches[1];
}
}

which correctly returns:

33
161

for these ifTypes. This might be useful to someone.

User avatar
TheWitness
Developer
Posts: 14804
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#2 Post by TheWitness » Fri Dec 18, 2009 9:05 pm

That's a net-snmp configuration change. You are getting the full type, when you should be getting the numerical value only. Which SNMP are you using php-snmp or net-snmp?

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

User avatar
edc1
Posts: 4
Joined: Fri Dec 18, 2009 5:40 am

#3 Post by edc1 » Mon Dec 21, 2009 8:59 am

I'm using the functions in mactrack_functions.php. I put in lots of print statements to the mactrack_enterasys.php script to help understand it better and it looks like when it retrieves the ifTypes it gets the text value and numerical values. Like this:

rs232(33)

mactrack_strip_alpha just calls trim which doesn't return 33 in this case which I would expect it to do. I think it's because there are digits in the part outside the brackets.

User avatar
TheWitness
Developer
Posts: 14804
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#4 Post by TheWitness » Mon Dec 21, 2009 9:23 am

I guess the fix would be to make strip alpha have two methods, one that removes non-numeric data and one that removes everything except what's inside of the brackets.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

Post Reply