Vse, chto dolzno proizojti - v pole status tekst "Outstanding" dolzen smenitsja na "Acknowledged". Ili etogo toze ne proishodit?
We really need your input in this questionnaire
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
Quote from: jdl on June 30, 2009, 04:28:15 PM
In the script, the $event->message refers to the text message defined in the event not in the alarm which can be more specific as we get additional macro's at that level, right?
Quote from: jdl on June 30, 2009, 11:21:04 AM
- Any possible way to insert comments? Using for example # as in Perl...
Quote from: jdl on June 30, 2009, 11:21:04 AM
- Is the operator ~= similar to the one in Perl? I.e. calling for regular expression?
Quote from: jdl on June 30, 2009, 11:21:04 AM
As far as reg.ex. are concerned, is the syntax the same?
If for example, I need a script parsing a message text to return different elements and use them to defined return argument(s)...
Message test is "TCP Socket is open on host xyz.domain.com (172.16.0.1) using port 3333" and my regular expression is:
$event->message ~= "^TCP Socket is (.*) on host (.*) \((.*)\) using port (\d)$"
Quote from: jdl on June 30, 2009, 11:21:04 AM
How can I put the matched info in different variables: $status, $host, $ipaddr and $port?
How do you define those variables?
if ($event->message ~= "^TCP Socket is (.*) on host (.*) \((.*)\) using port ([0-9]+)$")
{
status = $1;
host = $2;
ipaddr = $3;
port = $4;
}
Quote from: jdl on June 30, 2009, 11:21:04 AM
What about functions in script?
/* script entry point */
sub main()
{
// Call functions
result = my_function_1();
result2 = my_function_2(1, 2);
println "result1=" . result . " result2=" . result2;
}
/* additional function */
sub my_function()
{
return 1;
}
/* function with parameters */
sub my_function_2(param1, param2)
{
return param1 + param2;
}
Quote from: jdl on June 30, 2009, 11:21:04 AM
How do we return an array as argument?
Is syntax return ($val_1, $val_2); correct?
Will this array be returned as an array?
sub fx()
{
array a; // Create empty array and store reference to it in variable a
a[1] = "value1";
a[2] = "value2";
return a; // return reference to array
}
sub main()
{
x = fx(); // get array result from function
println "second element is " . x[2];
}
Quote from: jdl on June 30, 2009, 11:21:04 AM
Would you have a complex example to post that would illustrate as many things as possible about defining NXSL script?
I'll do this later.| code | Event code |
| id | Event ID |
| severity | Severity code (0=Normal 1=Warning 2=Minor 3=Major 4=Critical) |
| timestamp | Timestamp as number of seconds since 1 Jan 1970 00:00:00 UTC |
| message | Message text |
| customMessage | Custom message text (added in 0.2.27) |
| userTag | User tag |
| parameters | Event parameters (this property is an array with first element started at 1) |
$node->terminalId
sub main()
{
if (right($node->name, 11) == ".domain.com")
return "[email protected]";
if (right($node->name, 12) == ".domain2.com")
return "[email protected]";
return "[email protected]";
}