Important This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management.

snmp_config()


Return the default parameters for one or more open PATROL SNMP sessions that were opened with the snmp_open() function.

Syntax

snmp_config()
snmp_config(session)
snmp_config(session,community,timeout,retries)

Parameter

Parameter

Definition

session

ID of the SNMP session whose default parameters are to be returned or set The session is the ID returned when an snmp_open() function is executed.

community

character string used as a community string for SNMP operations

*Default* 
no change to existing community

timeout

integer value of the session timeout parameter in milliseconds (ms)

Default 
no change to exiting timeout

retries

integer value indicating the number of retries to attempt when a timeout occurs

*Default* 
no change to exiting retries

Description

The snmp_config() function has three different formats that perform three distinct actions:

  • The format snmp_config() returns a list of all open SNMP session separated by new-line characters. If no sessions are open the NULL string is returned. The following is an example of the snmp_config() function output for three active sessions:
    sess1
    sess2
    sess3
  • The format snmp_config( session ) returns a string of the default parameters for session separated by spaces.
    The output string for each session is as follows:

     

    host community timeout retries

    Value

    Definition

    host

    TCP/IP address of the computer system to which the session is opened

    community

    name of community string used for SNMP operations

    timeout

    session timeout value in milliseconds (ms)

    retries

    number of retries to attempt when a timeout occurs

  • The format snmp_config( sessioncommunitytimeoutretries ) sets the default parameters of session to the indicated values. If any parameter is specified in the snmp_config() function as the NULL string(""), the existing default value for the parameter is unchanged. Returns the string OK if successful or set the errno variable to 93 indicating a bad session id.

Example

The following example includes each of the three uses of the snmp_config() function (listing existing sessions, listing session settings, and setting session settings):

# Open three snmp sessions
snmp_sessiona = snmp_open("runner","","","","","");
snmp_sessionb = snmp_open("gsmithisdn","","","1000","6","161");
snmp_sessionc = snmp_open("gsmith","","","","","8161");
# Print session id for each of the sessions
print("snmp_sessiona: ".snmp_sessiona."\n");
print("snmp_sessionb: ".snmp_sessionb."\n");
print("snmp_sessionc: ".snmp_sessionc."\n");
print("\n");
# Capture and print list of open snmp sessions ignoring blank lines
sessions = grep("^$",snmp_config(),"v");
print("Output from snmp_config():\n".sessions."\n");
print("Number of open sessions: ".lines(sessions)."\n");
print("\n");
# Loop through list of open snmp sessions and print snmp_config for each
foreach session (sessions)
{
print("Output from snmp_config for ".session."".snmp_config(session)."\n");
}
print("\n");
# Change default snmp session parameters for sessiona. Change timeout to 700
# and retries to 5.
print("Use snmp_config() to change default parameters for ".snmp_sessiona."");
print(snmp_config(snmp_sessiona,"",800,5)."\n");
# Change default snmp session parameters for sessionb. Change community to
# "internal", timeout to 600, and retries to 7.
print("Use snmp_config() to change default parameters for ".snmp_sessionb."");
print(snmp_config(snmp_sessionb,"internal",600,7)."\n");
print("\n");
# Loop through list of open snmp sessions and print snmp_config for each
# then close the snmp session.
foreach session (sessions)
{
print("Output from snmp_config for ".session."".snmp_config(session)."\n");
snmp_close(session);
}

This example produces the following output:

snmp_sessiona: sess21
snmp_sessionb: sess22
snmp_sessionc: sess23
Output from snmp_config():
sess21
sess22
sess23
Number of open sessions: 3
Output from snmp_config for sess21: 172.19.201.36 public 500 3
Output from snmp_config for sess22: 172.21.1.223 public 1000 6
Output from snmp_config for sess23: 172.19.1.13 public 500 3
Use snmp_config() to change default parameters for sess21: OK
Use snmp_config() to change default parameters for sess22: OK
Output from snmp_config for sess21: 172.19.201.36 public 800 5
Output from snmp_config for sess22: 172.21.1.223 internal 600 7
Output from snmp_config for sess23: 172.19.1.13 public 500 3