Auto bind and auto apply script
-
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:
sub main()
{
return left($1,6) = "FG100A" ? 1 : 0;
}sub main()
{
return left($node,6) = "FG100A" ? 1 : 0;
}sub 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 = 1means "assign value 1 to variable a"
and
a == 1means "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->nameAnd 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?...$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 -
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login