Parameters in monitored URIs

You can use user-defined parameters to define the resource ID in the URI passed to the Monitor function.

For example, instead of creating a monitor for a specific interface on a switch, you can define a parameter for that interface. Then, when the agent is created, the user supplies the identifier of interface to be monitored.

The following example shows the use of a parameter for the ID of an interface:

self.monitor = Monitor("/system/interfaces/{}?attributes=rx_bytes", 
	              [self.params["iface_id"] ],name="Interface Received Bytes")

In the example:

  • In the URI, instead of specifying a specific interface, the URI contains the following characters to indicate that a parameter is expected:

    {}
  • The following argument indicates that the name of the user-defined parameter is iface_id:

    [self.params["iface_id"] ],
  • The iface_id parameter is defined in the ParameterDefinitions portion of the script:

    ParameterDefinitions = {
        'iface_id': {
            'Name': 'Interface Id',
            'Description': 'Interface to be monitored',
            'Type': 'string',
            'Default': '1/1/1'
        }

Parameters can only be used to specify resource identifiers, which are the last part of the path before the query string. Using parameters to specify attributes or other URI components is not supported.

The following parameter definition is invalid because it attempts to create a parameter for an attribute, such as received bytes or transmitted bytes:

# Example of invalid parameter usage: attribute
self.monitor = Monitor("/system/interfaces/1%2F1%2F5?attributes={}", 
           [self.params["attr"] ], name="Interface Received Bytes") 

The following parameter definition is invalid because it attempts to create a parameter for a component of the URI that is not the resource ID:

# Example of invalid parameter: URI component not resource ID  
self.monitor = Monitor("/system/{}/1%2F1%2F5?attributes=rx_bytes", 
           [self.params["resource"] ],name="Interface Received Bytes")