NetXMS Support Forum

English Support => General Support => Topic started by: touton on June 18, 2013, 04:20:43 PM

Title: Custom Attributes
Post by: touton on June 18, 2013, 04:20:43 PM
Hello,

I'm creating templates for switch management. We have both Cisco and HP switches.
To handle this, I'm creating templates per Makers and template to handle DCI and other things.

Do you know if it is wise to use Custom Attributes to store specific OIDs ?

Is it possible to retrieve Custom Attribute values directly from SNMP DCI page ? or do I need to code transformation script for an internal dummy DCI ?

If a custom attribute is declared twice (ie : one on 2 templates attached to one node), is it possible to know which one will be used ?

Title: Re: Custom Attributes
Post by: touton on June 18, 2013, 04:53:17 PM
argrr...

Custom Attributes created in a template are not "visible" from script created in another one.

I've create a CA in HP template MaxMemoryOID = .1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.5.1
I've bind a HP switch to this template.

And in a generic Switch template, I've create a dummy DCI to get SNMP value :
sub main()
{
trace(1,"Get CA=" . GetCustomAttribute($node, "MaxMemoryOID"));
snmp = CreateSNMPTransport($node);
return SNMPGetValue(snmp, GetCustomAttribute($node, "MaxMemoryOID"));
}


If CA is manually defined in the node : it works, if it is inheritated from first template : value is NULL.

Any idea to overcome this ?
Title: Re: Custom Attributes
Post by: Victor Kirhenshtein on June 18, 2013, 04:59:52 PM
Hi!

Custom attributes are attached to the object. Template only handles data collection configuration, custom attributes will not be copied. Custom attributes was designed to store object-specific attributes, and often used by integration tools or scripts. For data collection it is usually enough to create different templates for different vendors/models.

Best regards,
Victor
Title: Re: Custom Attributes
Post by: touton on June 18, 2013, 05:03:41 PM
As I'm creating lots of settings (thresholds,...) I was hopping to be able to create template that can work with any devices, and move vendor specifics to another place.

what is the best to do this ?

Last solution may be to export one template,  modify the xml, and then re-import ? (not really clean, and don't know how the object IDs will match ?)
Title: Re: Custom Attributes
Post by: Victor Kirhenshtein on June 18, 2013, 05:13:26 PM
Another possible option is to use script type macros in templates. For example, you can use macro like

%{script:SelectOID}

instead of actual OID in template, and create script called [n]SelectOID[/b] in script library, which will return correct OID for given node. This script will have $node variable set, so it can get any information about the node.

For example:


if ($node->snmpOID like ".1.3.6.1.4.1.11.*")
   return ".1.3.6.1.4.1.11.2.3.4.5.6.7.8.0";
return return ".1.3.6.1.2.1.1.1.0";


Not sure if this will be easier then configuring separate templates...

Best regards,
Victor
Title: Re: Custom Attributes
Post by: touton on June 19, 2013, 10:59:56 AM
ok,

I've recreate specific template per maker. What is the best way to duplicate a template ? Is it clever to export / do modification or merge modification /re-import ?

Is there some info on how we can modify templates by scripts ?
Title: Re: Custom Attributes
Post by: Victor Kirhenshtein on June 19, 2013, 12:40:16 PM
Hi!

You can create new empty template, open data collection configuration for existing one, select DCIs you want to copy to new template, right-click, select "Copy to other node...", and select new template object as destination.

You can modify templates using nxshell and Python scripts. Info about nxshell can be found here: http://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations (http://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations), and Java API documentation is here: https://www.netxms.org/documentation/javadoc/latest/ (https://www.netxms.org/documentation/javadoc/latest/) (you call Java API from nxshell script).

Best regards,
Victor