Menu

Show posts

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

Messages - Victor Kirhenshtein

#5611
Hi!

Alarm generation and actions are different things. For generating alarm you do not need an action - it's just special attributes in event processing policy rule. To set rule to generate alarm, do the following (assuming you already have rule object called "rule" of type EventProcessingPolicyRule):


rule.setFlags(rule.getFlags() | EventProcessingPolicyRule.GENERATE_ALARM);
rule.setAlarmMessage("%m");  // it's an example, you can specify your real alarm message here
rule.setAlarmSeverity(0);   // specify your severity
rule.setAlarmKey("");   // specify alarm key


and to set rule to terminate alarm:


rule.setFlags(rule.getFlags() | EventProcessingPolicyRule.GENERATE_ALARM);
rule.setAlarmSeverity(Severity.UNMANAGED);   // Severity UNMANAGED indicates alarm termination rule
rule.setAlarmKey("");   // specify alarm key


Also, you can take a look at property pages in nxmc-epp plugin in management console.

Best regards,
Victor
#5612
General Support / Re: Alarms
December 27, 2011, 11:53:02 AM
No, it is not necessary. Empty main() will be created by script compiler if it was not defined explicitly.

Best regards,
Victor
#5613
Feature Requests / Re: Java Console - Script Library
December 27, 2011, 11:22:04 AM
Just added "rename script" function to the Java console.

Quote from: lindeamon on December 25, 2011, 01:37:19 PM
when will the java console include all the old features of the native console ?

I hope that version 1.1.8 will be able to replace legacy console completely. There are no much functions left.

Best regards,
Victor
#5614
General Support / Re: Alarms
December 27, 2011, 11:17:42 AM
Hi!

There are some confusion caused primarily by giving script itself and a function inside this script the same name. In "use" operator you should use script name (you can think of it as of virtual file name) - the one you see in script list in the library. Then, you can call functions from that script using their respective names - name of the function may or may not be identical to script name. Note that each script has it's own main() function, even if you do not declare it explicitly, so you cannot call main() function of another script. One script may provide multiple functions, like in this example:

Script in the library called "MyScript":


/* function 1 */
sub f1(p)
{
   println "f1 called with parameter " . p;
}


/* function 2 */
sub f2(p)
{
   println "f2 called with parameter " . p;
}


and then you use it in some other script:


use MyScript;  /* load script from library by it's name */

f1(1);  /* call function f1 */

f2(2); /* call function f2 */


Script above will produce output


f1 called with parameter 1
f2 called with parameter 2


Best regards,
Victor
#5615
Hi!

Quote from: dogz on December 27, 2011, 06:26:03 AM
I would like to know the problem is due to the web service stop or the web service is started but can't response (maybe Apache daemon is dead) or due to the programming failure or the web page is changed by crackers and so on.

You should monitor multiple things and react to them differently. First, you should monitor state of Apache service via System.ServiceState parameter.  If it is not running, you can automatically restart it using actions. Also, you probably should monitor that your web server responds correctly to HTTP requests. You can done it by creating network service under web server node, or by using ServiceCheck.HTTP agent's parameter. Search the forum, there should be instructions about network service configuration. Also, if you have static web pages, you might want to monitor that they are not changed by using ESC subagent - it provides checksum calculation for web pages.

Best regards,
Victor
#5616
General Support / Re: Alarms
December 25, 2011, 05:33:35 PM
You should not have function main() in library script. Try to change it like this:


sub CISCO_Config_Event_Config(e)
{
    switch(e)
    {
    case 3: return "running";
    case 4: return "startup";
    }
}


It is strange that server crashes. I'll try to reproduce it myself.

Best regards,
Victor
#5617
General Support / Re: Alarms
December 25, 2011, 01:42:24 PM
Parameters can be passed to subroutines like that:


sub main()
{
   f(1, 2);
   f(3, 4);
}

sub f(p1, p2)
{
   println "parameter 1 is " . p1;
   println "parameter 2 is " . p2;
}


If you have multiple parameters which needs to be converted using same function, you can create separate script in the library containing this function, and call it from different small scripts. For example, create script called "convert" with function "convert":


convert(p)
{
   // do conversion here
   return converted_value;
}


then create scripts like that for each parameter:

convert_p1:


use convert;
return convert($event->parameters[1]);


convert_p2:


use convert;
return convert($event->parameters[2]);


and so on.

Best regards,
Victor
#5618
General Support / Re: Alarms
December 25, 2011, 01:25:17 PM
Hi!

Currently it is not possible - server always calls main() subroutine when expanding %[] macro. I can add an option to specify parameters and/or entry points to these scripts - in 1.1.8 or 1.1.9, depending on how fast I will fix other things from to-do list.

Best regards,
Victor
#5619
General Support / Re: cannot install netxms webserver
December 25, 2011, 01:19:51 PM
Sorry, I forgot to mention it - in 1.1.x correct configure option is --with-webui instead of --with-nxhttpd.

Best regards,
Victor
#5620
General Support / Re: Alarms
December 22, 2011, 07:24:33 PM
If I understand you need correctly, you need script which will convert numeric codes into strings, right? Then you can do the following:

Create script in script library, with some name, let's say "convert" (here I assume that you need to convert event's parameter %2 into text - otherwise change index in parameters[] accordingly):


switch($event->parameters[2])
{
   case 1: return "test";
   case 2: return "test2";
   // and so on...
}
return "unknown"; // default value


and then use it in a message like %[convert]

Best regards,
Victor
#5621
General Support / Re: Export: cannot load schema file
December 22, 2011, 11:50:41 AM
Hi!

It's a bug. Unfortunately there are no workaround, you have to wait for version 1.1.8 with a fix.

Best regards,
Victor
#5622
General / Re: About the discover poll
December 22, 2011, 11:47:56 AM
Yes, that's correct.

Best regards,
Victor
#5623
It's fixed already in the trunk, so 1.1.8 will not have this bug.

Best regards,
Victor
#5624
Try to use netstat -atnp command - then you will see what exact process keeps this port open.

Best regards,
Victor
#5625
General Support / Re: cannot install netxms webserver
December 21, 2011, 12:13:09 PM
It should be under /usr/local/bin if you have used default prefix.

Best regards,
Victor