Hi,
i'am trying to realize a filtering script that when an interface goes down get an snmp value from the switch, using the IfIndex of the interface.
Here is my filtering script:
sub main() {
   
   transport = CreateSNMPTransport($node);    // Create SNMP transport for node
   
   ifIndex= %5;   
    
   value = SNMPGetValue(transport, ".1.3.6.1.4.1.9.2.2.1.1.28.".ifIndex);
   
   
   
   CUSTOM_MESSAGE = "Description: ".value;
   
   
  
  return true;
}
The IfIndex of the interface is rapresented by the %5 special variable, because the filtering script is relative to "SYS_IF_DOWN" event which has as parameter:
"
   1) Interface object ID
   2) Interface name
   3) Interface IP address
   4) Interface netmask
   5) Interface index
"
But when the script is executed i get the following error code:
 Error in line 5: syntax error, unexpected T_INT32, expecting '('.
I have tryed to cast the value -> ifIndex = string(%5);
or
I have tryed to use a switch case to convert the value:
switch(%5):
   case "10134": etc
but nothing works :(
Can you help me?
Tnx
			
			
			
				Hi!
It should be $5. It's a bit confusing, but macros in message texts, etc. and NXSL scripts uses a bit different syntax. In macro expansion, % denotes a macro. In NXSL, parameters comes as $1, $2, etc., and % sign is a division remainder operation.
Best regards,
Victor
			
			
			
				Yes, it works!
Here is a working filtering script that get the interface description from the switch and put it in the alarm mail when interface goes down/up:
sub main() {
   
   transport = CreateSNMPTransport($node);    // Create SNMP transport for node
   
   ifIndex = $5 ;
   trace(0,"ifIndex =".ifIndex);
   
   value = SNMPGetValue(transport, ".1.3.6.1.4.1.9.2.2.1.1.28.".ifIndex);
   
   
   
   CUSTOM_MESSAGE = "Description: ".value;
   
   
  
  return true;
}
Works on Cisco. For other switch, just change the base OID in SNMPGetValue.
Is it possible to create a topic in forum in which share our NXSL script?
Sharing and example are so useful for nxsl devoloper ^^
Thank you :)
			
			
			
				Hi!
There is an area in wiki for NXSL script examples: http://wiki.netxms.org/wiki/SG:Script_Examples (http://wiki.netxms.org/wiki/SG:Script_Examples). Feel free to add your own!
Best regards,
Victor