RE: DB locked ?

From: Victor Kirhenshtein <victor_at_DOMAIN_REMOVED>
Date: Fri, 24 Feb 2006 19:25:44 +0200

Hello!

Scripts was introduced in version 0.2.9, and still not documented. I
will try to write short language reference as fast as possible. I would
also recommend to wait for version 0.2.10, which is almost ready. New
version will contain improvements in the scripting engine, including
functions to check if given IP address is within range or subnet.

Very short and non-structured description of scripting language:

NXSL is a scripting language with syntax very similar to C. You have not
to declare variables nor specify variable data types - all this stuff
handled automatically by the engine. Every script can be written in two
forms: short, in a form of single expression, or full, with main()
function definition. Example of a script in a short form:

x + y * 10

Note that it's just an expression, without trailing ; character. Result
of an expression's evaluation will be the script return value. And an
example of a script in a full form:

sub main()
{
        a = $1 + 10;
        b = a * 0.2;
        return b;
}

Note special variable $1 - it represents first parameter passed to
script. You can access second parameter via $2 variable, and so on.

Among atomic data types, variable can be a reference to an object. In
this case, you can access various object's properties like this:
var->property. Below is an example of checking if given object supports
SNMP:

sub main()
{
   return $1->isSNMP;
}

or, in short form:

$1->isSNMP

List of object properties, accessible in filter scripts:

ipAddr - object's IP address
subnet - object's subnet
netMask - network mask of object's subnet
isAgent - 1 if NetXMS agent is supported, 0 if not
isBridge - 1 if bridge MIB is supported, 0 if not
isRouter - 1 if IP forwarding is enabled, 0 if not
isSNMP - 1 if SNMP is supported, 0 if not
snmpVersion - highest supported SNMP version
snmpOID - object's SNMP OID
agentVersion - NetXMS agent's version
platformName - platform name as reported by NetXMS agent

When filter script is called, variable $1 will hold the reference to
newly discovered object.

And as conclusion, another filter example:

sub main()
{
        if ($1->isSNMP)
        {
                if ($1->snmpOID == ".1.3.6.1.4.1.45.3.30.1")
                        return 1;
                if ($1->snmpOID == ".1.3.6.1.4.1.45.3.61.2")
                        return 1;
        }
        return 0;
}

Also, note that variable and function names are case sensitive, like in
C.

Best regards,
Victor

> -----Original Message-----
> From: TIM MOORE [mailto:MOORET10_at_odjfs.state.oh.us]
> Sent: Friday, February 24, 2006 4:13 PM
> To: netxms-users_at_alk.lv; Victor Kirhenshtein
> Subject: Re: [netxms-users] DB locked ?
>
>
> Thanks for the help. I may try this. Is there any
> documentation on how to write these scripts? I would really
> like to only allow snmp and be able to filter based on
> subnet. We have a very large network and I would like to
> keep some networks from being discovered (some people might
> not be happy getting scanned). What would be the best way to do this?
>
> Any thoughts on the snmp trap configurator? How to get most
> of cisco trap mibs loaded?
>
> --------------------------------------
> Tim Moore
> 614.387.8197
> Network Operations Center
> ODJFS
>
> >>> victor_at_opticom.lv 2/24/2006 8:51:02 AM >>>
>
> Hello!
>
> Network Discovery
>
> Yes, NetXMS is able to do network discovery, but it's
> disabled by default. To enable it, you should go to View ->
> Control Panel -> Server Configuration in console, select
> variable "RunNetworkDiscovery" and change it's value to 1.
> Then, you should restart NetXMS server so new settings will
> take effect. After that, NetXMS server will instantly scan
> your network for new hosts and devices and add them to
> database. However, it will add EVERYTHING which have an IP
> address configured - workstations, printers, etc. If you wish
> to limit discovery process, you should create discovery
> filter. Filter is a script writtent in NXSL - NetXMS
> Scripting Language. It will receive information about newly
> discovered object and should return 0 if this object should
> not be added to database and 1 if it should. You are creating
> your scripts in Control Panel -> Script Library. After script
> is created, you should set server's variable
> "DiscoveryFilter" the the name of your script. By default,
> NetXMS has 3 pre-defined filters:
>
> 1. Filter::Agent - allows only hosts with NetXMS agent
> installed 2. Filter::SNMP - allows only hosts with SNMP
> support 3. Filter::AgentOrSNMP - allows only hosts with
> either NetXMS agent or SNMP
>
> If you have non-standard SNMP community string on your
> devices, network discovery will not work until you change
> server's variable "DefaultCommunityString".
>
> Hope this helps!
>
> Best regards,
> Victor
>
> > -----Original Message-----
> > From: TIM MOORE [mailto:MOORET10_at_odjfs.state.oh.us]
> > Sent: Friday, February 24, 2006 3:25 PM
> > To: NetXMS Users
> > Subject: Re: [netxms-users] DB locked ?
> >
> >
> >
> > Forwarding to all users.
> >
> > Well, I have some good news. I loaded this on a regular compaq pc
> > running Fedora Core 4. So far no crashes. I wonder it has anything

> > to do with SuSE SLES. I am going to reload the server I was running

> > Netxms on and put a Red Hat based distro on it and see if it runs
> > stable.
> >
> > I have just a couple questions that I can't find answers in the
> > documentation.
> >
> > 1) Is there a way to do some network discovery? I thought I saw
> > that there was a way, but can't find anything in the netxms console.

> > Or is there a way to populate the devices in the tree?
> >
> > 2) Has anyone populated the server with more mibs for the
> snmp traps?
>
> > If you look at the snmp trap configurator, it seems there are only 6

> > by default? What is the easiest way of going about this? I need as

> > many cisco mibs as possible. Are these trap mibs or regular device
> > mibs?
> >
> >
> >
> > --------------------------------------
> > Tim Moore
> > 614.387.8197
> > Network Operations Center
> > ODJFS
> >
> > --------------------------------------
> > Tim Moore
> > 614.387.8197
> > Network Operations Center
> > ODJFS
> >
> > >>> Alex Kirhenshtein <alk_at_ctco.lv> 2/21/2006 9:27:22 AM >>>
> > My bad, i remembered now.
> >
> > Does it leave a core file? If no, can you set core limit to
> > unlimited (run "ulimit -c unlimited" before netxmsd) and try again?
> >
> > If it crashed and there is a core file, then i'll will be happy to

> see
> > backtrace:
> >
> > # gdb /path/bin/netxmsd /path/core
> > (first argument - executable file, second - core file)
> > gdb> backtrace
> > (this will show you backtrace)
> >
> > or, if you don't have gdb installed, just send me executable + core.
> >
> > thanks in advance, alex.
> >
> > On Tue, 2006-02-21 at 08:58 -0500, TIM MOORE wrote:
> > > I was not trying to shutdown netxmsd. It died on its own. If I
> > leave
> > > it up over 1 day's time, it crashes and leaves the db locked.
> > >
> > > I am running 0.2.9 on SuSE SLES9 on a Compaq ML360 server. I gave
> > the
> > > specs in a prior email regarding my server. I'm the one who had
> to
> > use
> > > the stdarg settings in a few files to get it to compile.
> > >
> > > --------------------------------------
> >
> >
> >
> > This e-mail message, including any attachments, is for the sole use
> > of the intended recipient(s) and may contain private, confidential,
> > and/or privileged information. Any unauthorized review, use,
> > disclosure, or distribution is prohibited. If you are not the
> > intended recipient, employee, or agent responsible for delivering
> > this message, please contact the sender by reply e-mail and destroy
> > all copies of the original e-mail message.
> >
> >
>
>
> This e-mail message, including any attachments, is for the
> sole use of the intended recipient(s) and may contain
> private, confidential, and/or privileged information. Any
> unauthorized review, use, disclosure, or distribution is
> prohibited. If you are not the intended recipient, employee,
> or agent responsible for delivering this message, please
> contact the sender by reply e-mail and destroy all copies of
> the original e-mail message.
>
>
Received on Fri Feb 24 2006 - 19:25:44 EET

This archive was generated by hypermail 2.2.0 : Fri Feb 24 2006 - 19:29:24 EET