Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sun Apr 23, 2017 12:45 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: [TODO] mactrack_strip_alpha function not working correctly
PostPosted: Fri Dec 18, 2009 5:49 am 
Offline
User avatar

Joined: Fri Dec 18, 2009 5:40 am
Posts: 4
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 18, 2009 9:05 pm 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 21, 2009 8:59 am 
Offline
User avatar

Joined: Fri Dec 18, 2009 5:40 am
Posts: 4
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 21, 2009 9:23 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group