Configuring Behavior in SNMP Devices

 



 

Overview

 

The most important part of the simulation is to setup the simulated environment. You can setup the desired environment by defining the behavior of devices in the network, so that it will behave like a real device. The behavior of devices, is done through Jython scripts. For example, device values can be changed, rows can be dynamically added or deleted, Traps and Informs can be configured to be sent, SNMP agents can be added/deleted from the existing network etc. You can also define behavior in such a way that behavior of one device can affect another device.

 

AdventNet Simulation Toolkit provides a ScriptInterface, which defines methods to perform simple operations like update, insert and delete from a JPython script . The Script API is provided under the < simulator home >/examples/javadocs directory. The name of the Script API file is SNMP_TL1_SimScrIntf.html

 

If behavior is configured for a device in the device tree, this behavior will be reflected in all the devices dragged and dropped.

 

Enabling/Disabling Behavior Service

 

The Network Simulator provides option to enable/disable the execution of  behavior scripts configured for the SNMP devices in the network, at agent runtime. If  behavior service is disabled, the agent will not check for script configurations before sending the response. Hence, you can use this option to improve the performance of the network, if behavior scripts are not required to be executed.

 

By default, the service is enabled and the behavior scripts configured (if any), will be executed.  To disable the service,

Note: The options in the Initialize Services dialog will be disabled when the SNMP agent is started.

 

 

Configuring Behavior

 

The Network Designer provides an intuitive UI to configure Behavior scripts. To invoke the Behavior dialog,

The Configure Behavior dialog will list the configured scripts files, the defined conditions and actions to execute the script files. You can configure new Behavior, modify or delete an existing Behavior configuration, add new conditions and actions, modify existing conditions and actions, from this dialog.

 

Steps in Configuring Behavior

 

Step I : Configuring the Conditions to Execute the Script : Here, you will define when the script should be executed. Scripts can be executed based on three conditions. Scripts can be executed based on a request, based on a threshold condition and value, or timer based.

 

Step 2 and Step 3 is used for generating the script file from the UI, with the necessary actions to be executed and the conditions to execute the actions (if any). The conditions and actions are defined using the Script API methods.

 

Note: Defining Step 2 and Step 3 is not required in the following cases :

  • If you have defined your own script file, with necessary conditions and actions, you can configure this script file in step 1 and can Finish 'Behavior Configuration'.

  • If your scope for defining the conditions and actions is beyond the current scope of our API , you have to write your own script. Configure this script file in step 1 and Finish 'Behavior Configuration'.

  • If you want to configure the script file available in the ./examples directory, you can specify this file in Step 1 and Finish 'Behavior Configuration'.

In all the above cases, the conditions and actions defined in the script file will be executed only when the condition to execute the script (specified in step 1) is satisfied.

 

Step 2 : Configuring the Conditions to Execute the Actions : In this step you can define on what conditions the actions are to be executed. You can define any number of conditions.

 

Step 3 : Configuring the Actions to be Executed : In this step, you can define the actions to be executed, when the condition to executed the script and the condition to execute the action (if any) are satisfied.

 

Step 1: Configuring the Conditions to Execute the script

 

To configure conditions to execute the script, select the Add button in the Behavior Configuration dialog. The Define Your Script dialog is invoked. Select any of the following conditions and configure the necessary details on the right-side of the dialog.

Request Based Script

Threshold Based Script

Timer Based Script

Step 2 : Configuring the Conditions to Execute the Action

 

In this step you can define on what conditions you want the actions defined in the scripts, to be executed. You can define any number of conditions.

    1. If you wish to configure behavior across the network, select the agent from the network. Specify the OID and instance. The MIBs of the selected agent will only be displayed in the MIB tree.

    2. Select the operator from the drop down box. The list of operators are listed as follows.

Not equal to !=

Lesser than <

Greater than >

Lesser than or equal to <=

Greater than or equal to >=

    1. After choosing the operator you can specify the value to which the expression should be equated to.

    2. Click ok, You will see that the conditions that you have specified gets added to the Conditions to execute actions list.

    3. Click Add to define another condition (or) click Next to proceed to Step 3 or click Finish to finish Behavior configuration and exit the dialog.

    4. As already mentioned, you can specify as many conditions as you want . Hence you have to specify whether you want to

Step 3 : Configuring the Actions to be Executed

 

In this step, you can configure the actions to be performed when the condition to execute the script and the condition to execute the action (if any) is satisfied.

  1. Click Add, to brings up the Configure Actions to be Performed dialog.

  2. Select a method from the drop down list. Methods are listed below

Update Value:

        1. Select the Update Value method

        2. When simulating behavior of devices across a network, the agents in the network are listed in the drop down list. When you select the agent the value will be updated in the specified agent.

        3. To specify the OID and instance on which it should be updated, click on the Select OID button. Only the MIBs of the selected agent will be displayed. When selecting the OID and the instance, the details of the nodes are displayed.

        4. The syntax of the node is displayed along with the simulation type. You can choose the simulation type the node should have, and specify values for the simulation type.

        5. Click OK to add the action to the list

          Example :

          If you select the OID .1.3.6.1.2.1.1.6 the syntax would be Display String. The options that you have with this node is constant and random. If you choose the random option , you will see the range button being enabled. Specify value and click Add so that the value will be associated at random.

Get Node Value :

 

This method is used to get the current value of a MIB node.

        1. Choose the method GetNode Value from the drop down list.

        2. When simulating behavior of devices across a network, the agents in the network will be listed in the drop down list. You will be able to select an agent from the network.

        3. To specify the OID, click on the Select OID button.  Only the MIBs of the selected agent will be displayed. Select the OID and the instance.

        4. Now you have to specify a variable in the field that is displayed at the right corner.

        5. The value of the selected OID will get updated in the specified variable.

        6. Click OK for the action to be added to the list

Insert Row to a Table :

 

This method is used to insert an entry in a table.

        1. Choose the method Insert Row to Table from the drop down list.

        2. When simulating behavior of devices across a network, the agents in the network will be listed in the drop down list. You will be able to select agent from the network.

        3. To specify the OID, click on the Select OID button. Only the MIBs of the selected agent will be displayed. Select a table node and instance to insert row into the table.

        4. Click Add to add a row. You will see dialog coming up with details that contain

          • Column name

          • Simulation type

          • value

        5. You can make the desired changes to the row entries.

        6. Click OK. You have chosen to insert the selected row when the script executes and condition that you have specified earlier is satisfied.

Delete a Row From Table.

 

This method is used to delete a specific row from the table.

        1. Select the method Delete a Row from Table from the drop down list.

        2. When simulating behavior of devices across a network, the agents in the network will be listed in the drop down list. You will be able to select agent from the network.

        3. To specify the OID, click on the Select OID button. Only the MIBs of the selected agent will be displayed. Specify the table OID and instance that you want to delete from the table.

        4. Click OK to delete table

Delete All Rows From Table

 

This method is used to delete all the rows from a given table.

        1. Select the method Delete All Rows from Table from the drop down list.

        2. When simulating behavior of devices across a network, the agents in the network will be listed in the drop down list. You will be able to select agent from the network.

        3. To specify the OID, click on the Select OID button. Only the MIBs of the selected agent will be displayed. Specify the table OID, all rows from the specified table node will be deleted.

        4. Click OK.

Send Trap

 

There are three trap versions available :Sending a V1 trap, Sending a V2 trap , Sending a V3 trap.

 

Trap Version : Select the Trap Version from the list displayed. If the trap version is v1, the trap type must be specified as either Generic type or Specific type. The default trap version is SNMPv1.

If the trap version is v3, the v3 agent must be started and the user name and context name of the v3 user must be specified. Please refer the topic "Simulating a v3 Agent" to know more about starting the v3 agent, the default user names and password, and configuring new user names and password.

 

Generic Type : If the trap type value is zero through five, then the trap is one of the generic SNMP traps defined by the snmp group of MIB-II and the Specific trap type will be zero. If the trap type value is six, then the trap is an enterprise-specific trap that is defined in a private MIB.

 

coldStart (0),
warmStart (1),
linkDown (2),
linkUp (3),
authenticationFailure (4),
egpNeighborLoss (5),
enterpriseSpecific (6).

 

Specific Type : Specify an integer value for the enterprise-specific trap that is defined in a private MIB.

 

Enterprise OID : The OID specified in the Enterprises field indicates exactly which management enterprise defines the trap.

 

Manager Name : Specify the manager name. If the Manager is running on the same machine it will contain the value localhost. If the Manager is running on a different machine specify the manager name or IP address of that machine.

 

Manager Port : The default manage port is 162. If the manager is running on a different port, specify the port number.

 

Community : Specify the community name of the manager.

 

Variable Bindings : It enables the user to add more varbinds to the trap other than the trap variables/objects It is optional.

 

        Note: When you configure a Timer based SNMP V3 trap, the trap will be sent regardless of the manager's presence. You need the User name and the context name only to receive the traps. But when the SNMP v3 trap is configured as request based, the trap will not be sent unless the request is generated from the manager with the user name and context name.

Send Inform

Generate Random Numbers

 

To generated random numbers, specify minimum value and a maximum value so that random numbers will be generated within the specified range.

 

Minumum value can be 100 and maximum value can 200, random numbers will be generated within this range.

 

Delay Action :

 

You can introduce a delay in the action. Specify the value in milliseconds and the script execution will be delayed by the specified time.

 

Terminate Operation

 

This action can be configured before a GET/GETNEXT/SET. It will terminate the ongoing operation and send the corresponding error message specified. The error message can be specified from the drop down box. You can choose any one of the following error types.

  1. You can add any number of conditions Click Add to define another condition or click Finish to finish Behavior configuration and exit the dialog.

Simulating Behavior Across Agents

 

You can simulate behavior across agents in the network. For example, you have a network with five devices ( device 1 ...device 5). You can simulate behavior in such a way that if a specific condition is satisfied define condition for execution in device1, define the condition for action in device2 and the action can be defined to take place on device5.

 

When you select an agent, the MIBs of the selected agent will only be displayed.

 

Modifying and Deleting Script

 

To modify a script,

    1. Select the script to be modified, from the list displayed in the Configure Behavior dialog.

    2. Click Modify, to display the existing configuration. Make the necessary changes and click Finish.

To delete a script,

    1. Select the script to be deleted, from the list displayed in the Configure Behavior dialog.

    2. Click Delete, to delete the script file. The conditions and actions configured for the script will also be deleted. 

Modifying & Deleting Condition for Action

 

To modify a condition for action,

 

If you require to change an existing condition.

    1. Select the condition from the Condition to execute action list and click Modify to change the defined condition.

    2. The Configure Condition to be Checked dialog is brought up, you can make the required changes and click OK for the changes to take effect.

To delete a condition,

 

You can delete a condition if it is no longer required.

    1. Select the condition from the Condition to execute action list.

    2. Click Delete to remove the condition from the list.

Modifying and Deleting Action to be Executed

 

To modify an action,

To delete an action,

    1. Select the action from the Actions to be Performed list

    2. Click Delete to delete the defined action.

Stopping Timer Script Execution

 

Selecting the device right-click option SNMP -> Stop Timer Scripts will stop the execution of timer scripts in Network Simulator. To stop the execution of timer scripts in all devices, right-click on the blank network area and select Stop All timer scripts.

 

Scripts in Examples Directory

 

The example scripts for SNMP devices are available in <SimulatorHome>/examples/scripting/snmp directory. Some of the example scripts are explained below:

 

1. DeleteAllRows.py

 

The script file uses the scriptAPI method deleteAllRows to delete all the entries in the ifTable. It takes the tableEntryOID as input.

 

Format :

    scriptinterface.deleteAllRows(String tableEntryOid)

2. DeleteRow.py

 

This script file uses the scriptAPI method deleteRow to delete the first entry in the ifTable.  It takes the tableEntryOID and the instance of the entry to be deleted, as input.

 

Format :

where

 

tableEntryOid is the Object Id of the table entry node

instance is the instance of the entry to be deleted

 

3. DeleteRowWithValue.py

 

This script uses the scriptAPI method deleteRowWithValue to delete a specific entry from a table when the value of the specified column matches the specified value.  It takes the tableEntryOID, the column name and value as input.

 

Format :

where

 

tableEntryOid is the Object Id of the table entry node

columnName is the name of the column node in the table

value is the value of the specified column

 

4. GetAllTableValues.py

 

This script file uses the scriptAPI  method getAllTableValues to return the values of all the nodes for all the rows present in Table. It takes the tableEntryOID as input.

 

Format :

where

 

tableEntryOid is the Object Id of the table entry node

 

5. GetCurrentInstanceAndValue.py

 

This script file uses the scriptAPI method getCurrentInstance( ) and getCurrentValue( ) to return the instance and value of an incoming SET request. It should be configured for the condition "Before Processing Set" on a columnar node. This script gets the instance of the OID in the incoming SET request and its value and saves it in a text file named instance.txt

 

Format :

6. GetInstances.py

 

This script file uses the scriptAPI method getInstances( ) to get all the instances in a table. It takes the tableOID as input and will return the instances in a Vector.

 

Format:

where

 

tableOid is the Object Id of the table node

 

7. GetNextInstance.py

 

This script file uses the scriptAPI method getNextInstance( ) to get the instance next to the one specified. It takes the Table OID and the instance of a table as input. This will return the value as a String

 

Format :

    scriptinterface.getNextInstance(String tableOid,String instance)

where

 

tableOid is the Object Id of the table node

instance is the instance of a row present in the table

 

8. GetNodeValue.py

 

This script file uses the method getNodeValue( ), to get the current value of a scalar or a table node. It takes the OID of the MIB node and the instance as input. This method will return the value as a String

 

Format :

    scriptinterface.getNodeValue(String objectId,String instance)

where

 

objectId is the object identifier (without the instance) of the MIB Node

instance is the instance of the node whose value should be obtained, for scalar nodes this should be ".0"

 

9. GetRowCount.py

 

This script files uses the method getRowCount( ) to get the total number of rows in a table. It takes the Table OID as input and returns an integer value.

 

Format :

    scriptinterface.getRowCount(String tableOid)

where

 

tableOid is the Object Id of the table node

 

10. InsertRow.py

 

This script file uses the insertrow( ) method is used to insert an entry in the Table . It takes the Table OID, the Object Id of the columns in the table, the values of each column and its simulation type as input.

 

Format :

    scriptinterface.insertRow(String tableOid, String[] objectId,String[] values String[] simTypes)

where

 

tableOid is the object id of the table node in which the entry has to be added

objectId is an array of the object Id of the columns in the table

values is an array of values for the columns in the table

simTypes is an array of the simulation types for the columns

 

11. MaskNode.py

 

This script file uses the method maskNode( ) to mask a MIB node from the Manager.

 

Format :

    scriptinterface.maskNode(String objectId,String instance,String maskValue).

12. UpdateColumnarValue.py and UpdateScalarValue.py

 

This script file uses the method updateValue( ) to update the value of a scalar node and columnar node. It takes the OID and instance of the MIB node for which the value should be updated, the value to be assigned and the simulation type.  

 

Format

    scriptinterface.updateValue(String objectId,String instance,String value,String simType)

where

 

objectId is the object identifier (without the instance) of the mib node whose value has to be updated

instance is the instance for which the value should be updated, for scalar nodes this should be ".0"

value is the value to be assigned to the node

simType is the type of simulation required

 

13. SendInform.py

 

This script file uses the method sendInform( ) to send an inform request with no extra varbinds. It takes the manager name, manager port, community, sysUpTime and SNMP Trap OID as input.

 

Format

    scriptinterface.sendInform(String mgrName,String mgrPort,String community, String sysUpTime,String snmpTrapOid)

where

 

mgrName - the name of the manager to which the inform has to be sent

mgrPort - the port at which the manager is listening for incoming inform requests

community - the snmp community

sysUpTime - the System UpTime

snmpTrapOid - the value of the snmpTrapOid

 

14. SendInform_varbinds.py

 

This script file uses the scriptAPI method sendInform( ) to send an inform request with extra varbinds. The varbind for the inform is specified with the following information :

 

varbindOid is OID of the inform varbind

varbindTypes is the type of the varbind

varbindValues is the value of the varbinds.

 

Format

    scriptinterface.sendInform(String mgrName,String mgrPort,String community,String sysUpTime,String snmpTrapOid,String[] varbindOid,String[] varbindTypes,String[] varbindValues)

15. SendV1Trap.py

 

This script file uses the scriptAPI method sendV1Trap( ) to send a v1 trap without varbinds. It takes the manager name, manager port, community, enterprise OID, generic type and specifi type as input.

 

Format

    scriptinterface.sendV1Trap(String mgrName,int mgrPort,String community, String enterpriseOid,int genericType,int specificType)

where

 

mgrName - the name of the manager to which the trap has to be sent

mgrPort - the port at which the manager is listening for incoming traps

community - the snmp community

enterpriseOid - the Enterprise OID

genericType - the Generic Type

specificType - the Specific Type

 

16. SendV1Trap_varbinds.py

 

This script file uses the scriptAPI method sendv1Trap( ) to send a v1 trap with varbinds. It takes the manager name, manager port, community, enterprise OID, generic type, specific type, varbind OID, type and value as input.

 

Format

    scriptinterface.sendV1Trap(String mgrName,int mgrPort,String community, String enterpriseOid,int genericType,int specificType,String[] varbindOid,String[] varbindTypes,String[] varbindValues)

where

 

mgrName - the name of the manager to which the trap has to be sent

mgrPort - the port at which the manager is listening for incoming traps

community - the snmp community

enterpriseOid - the Enterprise OID

genericType - the Generic Type

specificType - the Specific Type

varbindOid - oid of the varbind

varbindTypes - the type of the varbind

varbindValues - the value

 

17. SendV2Trap.py

 

This script file uses the sendv2Trap( ) method to send a v2 trap with no extra varbinds.

    scriptinterface.sendV2Trap(String mgrName,int mgrPort,String community,String trapOID)

18. SendV2Trap_varbinds.py

 

This script file uses the sendv2Trap( ) method to send a v2 trap with extra varbinds. The varbinds for the trap is specified with the following information:

 

varbindOid - oid of the varbind

varbindTypes - the type of the varbind

varbindValues - the value

    scriptinterface.sendV2Trap(String mgrName,int mgrPort,String community, String trapOID,String[] varbindOid,String[] varbindTypes,String[] varbindValues)

19. SendV3Trap.py

 

This script file uses the sendv3Trap( ) method to send a v3 trap with no extra varbinds.

    scriptinterface.sendV3Trap(String mgrName,int mgrPort,String community, String trapOID,String userName,String contextName)

20. SendV3Trap_varbinds.py

 

This script file uses the sendV3Trap( ) method to send a v3 trap with extra varbinds. The varbinds for the trap is specified with the following information:

 

varbindOid is oid of the varbind

varbindTypes is the type of the varbind

varbindValues is the value

    scriptinterface.sendV3Trap(String mgrName,int mgrPort,String community,String trapOID,String userName,String contextName,String[] varbindOid,String[] varbindTypes,String[] varbindValues)

21. TerminateOperation.py

 

This script file uses the scriptAPI method terminateOperation( ) for terminating the current operation i.e. a Get, GetNext or Set operation. The general format of the terminateOperation method is :

    scriptinterface.terminateOperation(int errorNumber)

where, errorNumber is the error to be thrown on terminating the operation.

 

24. GetTotalColumns.py

 

This script file invokes the method getTotalColumns( ) and returns the total number of columns in a table.  It takes the table entry oid as input.

 

Format

    scriptinterface.getTotalColumns(String tableEntryOid);

25. GetAllColumnByNames.py

    

This script file invokes the method getAllColumnByNames( ) and returns the name of all the columns in the table.  It takes the table entry oid as input.

 

Format

     scriptinterface.getAllColumnByNames(String tableEntryOid);

26. getAllColumnByOids.py

 

This script file uses the method getAllColumnByOids( ) and returns the OID value of all the columns in the table.   It takes the table entry oid as input.

 

Format :

    scriptinterface.getAllColumnByOids(String tableEntryOid);

27. GetAllIndices.py

 

This script file uses the method getAllIndices( ) to return the string array having name of all the indices defined in a table.  It takes the table entry oid as input.

 

Format :

28. SendTrap.py

 

This script file uses the scriptAPI method sendTrap( ) to send traps configured in the Trap Configuration dialog. It takes the associated variable as input.  The parameter 'associatedVariable' is the name with which the trap is configured  in 'TrapConfiguration' dialog .

 

The manager details and trap details will be taken as such configured in the 'TrapConfiguration' dialog.

 

Format :

    scriptinterface.sendTrap(String associatedVariable);

29. SendTrapWithEnterpriseOid.py

 

The script file uses the method sendTrap( ) to send traps configured in the Trap Configuration dialog. It takes the associated variable as input.  The parameter 'associatedVariable' is the name with which the trap is configured  in 'TrapConfiguration' dialog . The 'enterpriceOid' is the one which is going to be sent in the trap.

 

The manager details and trap details will be taken as such configured in the 'TrapConfiguration' dialog. The enterpriceOid will be the one specified in the second argument irrespective of the one configured in 'TrapConfiguration' dialog.

 

Format :

30. GetConfigDirectory.py

 

This script file uses the scriptAPI method getConfigDirectory( ) to get the current working directory name . It returns the directory name as a string.

 

Format :

    scriptinterface.getConfigDirectory();

31. SendV1TrapWhileAddingRow.py

 

This Script file will send the V1 Trap while adding the row in the tables. This Script file using the following Script API Methods:

32. SendV1TrapWithVarbindsWhileAddingRow.py

 

This Script file will send the V1 Trap with Varbinds while adding the row in the tables. This Script file uses the following Script API Methods:

33. StartSnmpAgent.py

 

This script file uses the scriptAPI method startAgent( ) to start an SNMP agent. This method is useful in the runtime to start any SNMP agent in the Network from any other agent. This file will work only for the Network Simulator and not for the SNMP Agent Simulator.

 

Format :

 

34. StopSnmpAgent.py

 

This script file uses the scriptAPI method stopAgent( ) to stop an SNMP agent. This method is useful in the runtime to stop any SNMP agent in the Network from any other agent. This file will work only for the Network Simulator and not for the SNMP Agent Simulator.

 

Format :

 

Sample Scripts Defined

 

Given below are some sample behavior scenarios. The steps to define the behavior scenario and the output script file are given.

 

Script with condition for execution alone

 

In this sample, the script DeleteAllRows.py will be executed, after a get request is made on the MIB node "ifDescr" in the ifTable of the RFC 1213 MIB, with instance as .1

Script with condition for execution, condition for action, action to be executed

 

In this sample, the script file, ifOutErrors.py will be executed, when a set request is made on the node ifOutErrors. The condition for action is "if current value of ifOutErrors is greater than 10", the action to be executed is "send a v2trap". Hence, the script will send a trap, when a set is made on ifOutErrors with value greater than 10. The steps given below, defines the above Behavior :

The script file ifOutErrors.py is given below:

Script with condition for execution and actions to be executed

 

In this sample, the script file, timer.py will be executed, when the agent is started. The following actions are configured to be executed at agent startup : Get the node value sysUpTime and store it in a variable., send v1Trap. The steps given below, defines the above Behavior :

    1. Select the Add button in the Behavior Configuration dialog.

    2. Choose the Timer based icon that is displayed on the left of the wizard.

    3. Specify the script filename as timer.py

    4. Select the option Execute Script while Agent Starts.

    5. Specify the Time Interval and Number of Times the script must be executed.

    6. Click Next. The dialog to define the condition for action will be displayed. In this sample, we are not defining any condition for action. Hence click Next, to go the next dialog.

    7. Click Add to add the action to the list. Select GetNodeValue, browse and select the OID as sysUpTime in System group of RFC 1213 MIB, specify the variable name as agentUpTime. The value of the node will be stored in this variable.

    8. Click OK. You will find the action GetValue of Node of oid .1.3.6.1.2.1.1.3 with Instance .0, added to the list.

    9. Click Add again, to add the second action. Select the method Send Trap, with other options like version, Manager, Port and Community as default.

    10. Click OK. You will find the second action Send a V1 trap to localhost and port 162, added to the list.

    11. Click Finish to end Behavior configuration. You will find the script timer.py, added to the list with the defined actions, the main dialog. Click Close to exit from the dialog.

The script file timer.py is given below:

    # The Actions

     

    def actionfunc0():

    agentUpTime = scriptinterface.getNodeValue(".1.3.6.1.2.1.1.3" , ".0")

    scriptinterface.sendV1Trap("localhost",162,"public",".1.3.6.1.2.1.11",1,0)

     

    # The end of the Actions

     

    # The Condition

    actionfunc0()

    # The end of Conditions

Script with different sets of conditions for action and actions to be executed

 

In this sample, the script file, ifAdminStatus.py will be executed, when a get request is made on the node ifAdminStatus in ifTable of the RFC 1213 MIB. Two sets of conditions and actions are defined as given below:

The steps given below, defines the above Behavior :

The script file ifAdminStatus.py is given below:

    # Imports required for the scripts

    # to create an array the following lines should be in the script file

    from java.lang import String

    from jarray import array

    # The end of imports

    #############################################################################

    # Row values of Tables

     

    objectid1 = array([".1.3.6.1.2.1.2.2.1.1",".1.3.6.1.2.1.2.2.1.2",".1.3.6.1.2.1.2.2.1.3",".1.3.6.1.2.1.2.2.1.4",

    ".1.3.6.1.2.1.2.2.1.5", ".1.3.6.1.2.1.2.2.1.6",".1.3.6.1.2.1.2.2.1.7",".1.3.6.1.2.1.2.2.1.8",".1.3.6.1.2.1.2.2.1.9"

    ,".1.3.6.1.2.1.2.2.1.10",".1.3.6.1.2.1.2.2.1.11",".1.3.6.1.2.1.2.2.1.12",".1.3.6.1.2.1.2.2.1.13",

    ".1.3.6.1.2.1.2.2.1.14",".1.3.6.1.2.1.2.2.1.15",".1.3.6.1.2.1.2.2.1.16",".1.3.6.1.2.1.2.2.1.17",

    ".1.3.6.1.2.1.2.2.1.18",".1.3.6.1.2.1.2.2.1.19",".1.3.6.1.2.1.2.2.1.20",".1.3.6.1.2.1.2.2.1.21",

    ".1.3.6.1.2.1.2.2.1.22"],String)

    nodetypes1 = array(["CONST","CONST","CONST","CONST","CONST","CONST","CONST","CONST","CONST",

    "LINEAR","LINEAR","LINEAR","LINEAR","LINEAR","LINEAR","LINEAR","LINEAR","LINEAR","LINEAR",

    "LINEAR","CONST","CONST"],String)

    values1 = array(["2","Test Interface","32","1","1","ifPhysAddress","1","1","101010","1|1|0","1|1|0","1|1|0","1|1|0",

    "1|1|0","1|1|0","1|1|0","1|1|0","1|1|0","1|1|0","1|1|0","1",".1.3.6.1.2.1.2.2.1.22"],String)

    # The end of the varbinds

    #############################################################################

     

    # The Actions

    def actionfunc0():

    scriptinterface.sendV1Trap("localhost",162,"public",".1.3.6.1.2.1.11",0,0)

     

    def actionfunc1():

    scriptinterface.insertRow(".1.3.6.1.2.1.2.2",objectid1,values1,nodetypes1)

    # The end of the Actions

     

    # The Condition

    if(scriptinterface.getNodeValue(".1.3.6.1.2.1.2.2.1.7" , ".1") != "1"):

    actionfunc0()

     

    if(scriptinterface.getRowCount(".1.3.6.1.2.1.2.2") < 5):

    actionfunc1()

    # The end of Conditions

Script with condition for execution in device1, condition for action in device2, action to be executed in device3

 

In this sample, the network has three devices, with IP address 0.0.0.1, 0.0.0.2, 0.0.0.3 running at port 8001. All three devices, implement the same agent. The script file, device.py is configured on device 1 with IP address 0.0.0.1. This script file will be executed, when a set request is made on the node sysName. If sysName="simulation" in device 1, the node value sysName in device 2 and device 3 is updated with the same value.

 

The script file device.py is given below:

 



Copyright © 1996-2006, AdventNet Inc. All Rights Reserved.