RegEx in DCI
-
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
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login