Script as Instance Discovery

Started by Luis Montaño, February 03, 2017, 01:49:59 AM

Previous topic - Next topic

Luis Montaño

Hi all,
sorry for my english, I'm from Ecuador and I don't speak English very well.

I'm using netxms and I think that its great. I have the next problem:
I have some switches cisco 2960, I want to create a template to poll consumed ram from them
I checked cisco documentation and I know that I can get used ram wid oid ".1.3.6.1.4.1.9.9.48.1.1.1.5.1" and free ram with oid ".1.3.6.1.4.1.9.9.48.1.1.1.6.1"
those oid are not tables. The problem is that I dont have a oid to poll used ram in percentage so I create an script that I called SNMPOperations wich calculate percentage consumed.
I have tried this in several ways and I can't figure out what is wrong.
For example:
If I create the script with the function GetValueSNMP that recive a node object and return consumed ram (in percentage)

Script version 1:
sub GetValueSNMP(parameter)
{
   transport = CreateSNMPTransport(parameter);   // "parameter" is a node object
   usedRAM = SNMPGetValue(transport, ".1.3.6.1.4.1.9.9.48.1.1.1.5.1");
   freeRAM = SNMPGetValue(transport, ".1.3.6.1.4.1.9.9.48.1.1.1.6.1");
   totalRAM = usedRAM + freeRAM;
   usedRAMPercentage = ((usedRAM * 100)/totalRAM);
   return usedRAMPercentage;
}
I'm calling previous script in TransformationTab (doesn't work) and Instance Discovery(doesn't work)  in the following way:

use SNMPOperations;
return GetValueSNMP($node);



Script version 2:
   transport = CreateSNMPTransport($node);
   usedRAM = SNMPGetValue(transport, ".1.3.6.1.4.1.9.9.48.1.1.1.5.1");
   freeRAM = SNMPGetValue(transport, ".1.3.6.1.4.1.9.9.48.1.1.1.6.1");
   totalRAM = usedRAM + freeRAM;
   usedRAMPercentage = ((usedRAM * 100)/totalRAM);
   return usedRAMPercentage;
I'm using previous script in Instance Discovery(doesn't work)

I dont know if the script is wrong, or If I'm doing something wrong on dci template.
Please your help.

Victor Kirhenshtein

Hi,

you don't need instance discovery here. Script 2 is correct, you just have to place it into script library and use in script DCI. You can test it by selecting "Execute server script" on your switch node object, selecting library script or pasting script code, and executing.

Best regards,
Victor

Luis Montaño