Hi Calvin, list,
according to the GetRegexp.xml, the function takes the following 3 parameters:
1) An input string
2) A regular expression pattern string
3) A number specifying the return part
0 ... return the whole matched part
n > 1 return the n-th subpart of the matched expression
subparts are referenced by enclosing the desired part
in the regular expression into brackets: ()
eg: "(critical|major|minor) ERROR"
will match any of the error combinations and return the full
string (eg "critical ERROR") for index 1, and just the error
severity ("critical") for index 1
</description>
The third parameter shall be an unsigned integer:
<procedure-parameter>
<parameter-position>3</parameter-position>
<parameter-type>
<parameter-uinteger/>
</parameter-type>
<parameter-description>
The index of the matched subexpression part that should be returned.
0 returns the whole matched portion.
</parameter-description>
</procedure-parameter>
</parameter-list>
Your procedure text below seems to pass '{S 7}' which is treated as text string.
Actually I don't know if this causes the parsing error, but it might be worth
looking at.
Mit freundlichen Gruessen - Yours sincerely
Raphael Franck
Consultant
Global Infrastructure Operations
Computacenter AG & Co oHG
Enabling Users
Europaring 34-40, 50170 Kerpen, Germany
E-Mail: [email protected]
WWW: www.computacenter.de
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]]
Gesendet: Donnerstag, 26. März 2015 13:54
An: spectrum
Betreff: [spectrum] Event procedure regex help needed
I created a watch that upon violation produces an event that looks like this:
"0.0.0.0.0.0.0.4E"
I wrote a little perl script that does what I need (keep in mind, I am not a
perl expert):
[spectrum@anddevspect04 SwScript]$ cat isoAndConv1.pl
#!/usr/bin/perl
#use strict;
use warnings;
my $input = "0.0.0.0.0.0.0.4E";
$input =~ s/\"//g;
print "Original octet string is $input \n";
$input =~ s/0.//g;
print "Isolated value at the end of the string is $input \n";
$output = $input;
my $output = hex($input);
print "The decimal equivalent of the isolated value is $output \n";
When I run the script, I get the following:
[spectrum@devspect SwScript]$ ./isoAndConv1.pl
Original octet string is 0.0.0.0.0.0.0.4E
Isolated value at the end of the string is 4E
The decimal equivalent of the isolated value is 78
[spectrum@devspect SwScript]$
It removes the double quotes, isolates the last part of the string, and the
converts that hex value to decimal.
I now need to do the same thing in Spectrum using event procedures. This is
what I have come up with this so far:
0xfff00049 E 50 P "\
CreateEventWithAttributes( { C CURRENT_MODEL }, { H 0xfff0004b }" \
SetEventAttribute( \
GetEventAttributeList(), \
{ S 7 }, \
GetRegexp( \
GetEventAttribute( { S 7 } ), {S\"s/(0.)+//g\"}, \
{ S 7 })))"
I've verified the code and it looks fine, but I'm getting the following :
Procedure did not parse successfully (error reason: Procedure parsing failure)
for event 0xfff00049 on line 60 of event disposition file
../custom/Events/EventDisp
0xfff00049 E 50 P "CreateEventWithAttributes( { C CURRENT_MODEL },
{ H 0xfff0004b } SetEventAttribute( GetEventAttributeList(), { S 7 },
GetRegexp( GetEventAttribute( { S 7 } ), {S\"s/(0.)+//g\"}, { S 7 })))"
I'm not sure where the parsing error is. I'm thinking that my regex statement
is wrong. I need a regex statement that removes the zeros and dots leaving the
last value, removes the quotes, and then converts the last value to a decimal
number. Any help is appreciated. Thanks.
---
To unsubscribe from spectrum, send email to [email protected] with the body:
unsubscribe spectrum [email protected]
---
To unsubscribe from spectrum, send email to [email protected] with the body:
unsubscribe spectrum [email protected]