Hello again.
I am trying to prove automatic template application and automatic node binding to containers based on filters (node name begins with "FG100A") and do not work none of these filters:
Quotesub main()
{
return left($1,6) = "FG100A" ? 1 : 0;
}
Quotesub main()
{
return left($node,6) = "FG100A" ? 1 : 0;
}
Quotesub main()
{
return left($node,6) = "FG100A" ? $node : 0;
}
What is wrong?
Thanks in advanced
Hello!
You should use == for compare operation. = is an assignment operation.
For example:
a = 1
means "assign value 1 to variable a"
and
a == 1
means "test if variable's value is 1".
Second error is that $node variable is an object, and you need to compare it's name attribute. To access it, use
$node->name
And compare always returns 1 or 0, so you can omit ? 1 : 0 part and simply use
left($node->name,6) == "FG100A"
So, correct script will looks like
sub main()
{
return left($node->name, 6) == "FG100A";
}
Best regards,
Victor
Ok. Thanks for the explanation. ;)
Now it complete auto bind/apply. But it takes a few minutes. Is there any parameter in server configuration that I can setting to make it faster?
Quote...$node variable is an object, and you need to compare it's name attribute.
What other attributes for $node object? Some other usefull objects->attributes for auto bind/apply operations?
Best regards.
Hi!
Auto bind/apply occurs during configuration polls. You can force configuration poll for specific node from console (via Poll -> Configuration menu), or decrease interval between configuration polls by changing server's parameter ConfigurationPollingInterval.
Attributes of node object:
name | Node name |
id | Object identifier |
status | Node status (0 = Normal, 1 = Warning, 2 = Minor, 3 = Major, 4 = Critical, 5 = Unknown, 6 = Unmanaged) |
ipAddr | Node primary IP address (as text string, like 10.2.1.4) |
isAgent | Agent presense flag: 1 if NetXMS agent present on node, 0 if not |
isSNMP | SNMP support flag: 1 if SNMP is supported by node, 0 if not |
isBridge | Bridge flag: 1 if node is bridge or switch, 0 if not |
isRouter | IP router flag: 1 if node is Ip router (can forward IP packets), 0 if not |
isPrinter | Printer flag: 1 if node detected to be a network printer, 0 if not |
isCDP | CDP (Cisco Discovery Protocol) support flag: 1 node supports CDP, 0 if not |
isSONMP | SONMP (SynOptics Network Management Protocol) support flag: 1 node supports SONMP, 0 if not |
isLLDP | LLDP (Link Layer Discovery Protocol) support flag: 1 node supports LLDP, 0 if not |
snmpVersion | SNMP version used for communication with node's SNMP agent |
snmpOID | SNMP object ID |
agentVersion | NetXMS agent version (as string, like 0.2.26) |
platformName | Platform name, as returned by NetXMS agent (for example, windows-i386) |
Best regards,
Victor
is this scripting stuff documented somewhere? Because I can't find it..
i'm trying to figure out how it works, but it's tough to find resources about auto bind filters etc. etc.
Hi!
There are documentation chapter about scripting language itself, and reference for all functions. However, writing transformation and filtering script are not covered. I'll try to add additional information on this topic to documentation.
Best regards,
Victor