Script Example: Read SNMP Value From Node

Revision as of 12:16, 12 May 2013 by Victor (talk | contribs) (Created page with "This script can be put into Script Library and run from server's debug console. It accepts node object name or ID as parameter and prints value of SNMP sysDescription to conso...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This script can be put into Script Library and run from server's debug console. It accepts node object name or ID as parameter and prints value of SNMP sysDescription to console.

if ($1 == null)
{
   println "Please specify node name as parameter";
   return 3;
}

transport = CreateSNMPTransport(FindObject($1));    // Create SNMP transport for node
if (transport == null)
{
    println "Failed to create SNMP transport, exit";
    return 1;
}

value = SNMPGetValue(transport, ".1.3.6.1.2.1.1.1.0");
if (value == null)
{
    println "Failed to issue SNMP GET request";
    return 2;
}
else
{
    println "System description: " . value;
    return 0;
}

Example of script output:

C:\Source\NetXMS\x64\debug>nxadm -c "exec GetSysDescr cisco-2600-central"
System description: Cisco IOS Software, C2600 Software (C2600-ADVSECURITYK9-M), Version 12.4(1a), RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2005 by Cisco Systems, Inc.
Compiled Fri 27-May-05 15:09 by hqluong
INFO: Script finished with rc=0

C:\Source\NetXMS\x64\debug>