NetXMS Support Forum  
July 30, 2010, 04:04:25 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Binary packages for you favorite OS / Distribution. Which OS should go first? Help us decide!
 
   Home   Help Search Tags Login Register  
Pages: [1]
  Print  
Author Topic: RegEx in DCI  (Read 148 times)
jdl
Jr. Member
**
Posts: 52


View Profile
« on: March 10, 2010, 07:24:11 pm »

Quick one...

How would you handle regex in the DCI transformation?

Let's say you poll an SNMP OID which returns a string similar to "MyVal=18#-99#AB_01".
You want to extract the "-99" and return an integer to graph it...

In Perl it would sth like $1 ~=/#(.+)#/ - if I'm right.

Regards,

Jdamien
« Last Edit: March 10, 2010, 07:46:05 pm by jdl » Logged
jdl
Jr. Member
**
Posts: 52


View Profile
« Reply #1 on: March 10, 2010, 07:44:21 pm »

Well I'm glad I can answer myself this time ;-)

Solution is...

sub main()
{
   $1~="#(.*)#";
   return $1;
}


This script will return "-99" if I give it as input "MyVal=18#-99#AB_01".
And for those interested...

sub main()
{
    $1~="#(.*)#(.*)$";
    return $2;
}


This one will return "AB_01"

PS.: "main" not "Main"!!! Otherwise -> Error

JDamien
« Last Edit: March 10, 2010, 07:48:51 pm by jdl » Logged
Tags:
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!