User defined discovery process can be implemented using the following steps:
Write a user class implementing the UserDiscoveryInterface.
Specify the entry of the user class representing the user defined discovery process in userdiscovery.conf file, to invoke the user defined discovery process.
Write a user class implementing the UserDiscoveryInterface. The method to be implemented is discover(String ipAddress, Vector vectOfProp). The user class name representing the user defined discovery process and other required entries are specified in the userdiscovery.conf file. The discovery engine of Web NMS reads the entries specified in the userdiscovery.conf file and invokes the user class.
The discover() of the user class will be invoked for each Ip to be discovered, where Web NMS tries to discover the objects in the networks. The discover() takes the IP address and a Vector of Properties as arguments. The Vector object contains the properties (name-value pairs in the <ARGS> tag) read from the userdiscovery.conf file. Multiple <ARGS> tags can be specified in the userdiscovery.conf file, where each <ARGS> tag is taken as a properties object.
You can retrieve the net mask of the managed
object from the vector argument of the discover(String
ipAddress, Vector vectOfProps) method of the User Discovery class.
Use the following code snippet to retrieve the netmask :
Properties nMaskProp = (Properties)vectOfProps.lastElement();
String netMask = nMaskProp.get("NetMask"));
When the user defined discovery process succeeds in performing the user-specific test, the discover() would return a Vector of Properties object. The Vector of Properties object contains the properties object returned from the user class. Each properties object in the Vector of Properties object, is added as an object into the database. The number of objects added into the database is equal to the number of properties object in the Vector of Properties object. Thus for every user class (representing the user defined discovery process), multiple objects can be added into the database.
The user object added into the database is instantiated using the Class ManagedObject or any of its derived class. The class name to be instantiated is specified using the OBJECT_TYPE parameter in the userdiscovery.conf file or using the setProperty() of Class Properties, which can be set in the user class. This is done as follows.
prop = new Properties();
Specify the fully qualified class name. If the class name is set using both the methods, then the latter method overrides the former i.e., the class name set using the setProperty() of Class Properties takes precedence. If none of them is set, Web NMS, by default, instantiates the user object using the Class ManagedObject and adds the object into the database with the properties assigned from the properties object. Please note that even if the user properties are not specified in the userdiscovery.conf file, multiple objects can be added if the user specific test is programmatically defined in the user class.
When the user defined discovery process fails, it would just return a 'null' indicating the failure of the user defined discovery process.
Note: The name of the managed object or user object to be added must be passed as a property to the Vector of Properties, else the discover() would return a "null" indicating the failure of the user defined discovery process. When there are multiple user defined discovery processes, multiple objects might get added for each discovery process. Hence you need to ensure that the name of the objects to be added, which is passed as a property using the setProperty() of Class Properties is unique. Else, only the first object will get added and exceptions are thrown while trying to add the following objects.
In addition to the user defined discovery process, the conventional discovery process of Web NMS using TL1, SNMP or ICMP ping process will still be carried out, irrespective of whether the user defined discovery process is successful or not. The SNMP and ICMP discovery processes can be disabled if not required, by setting 'false' to the parameters viz., ENABLE_SNMP_DISCOVERY and ENABLE_ICMP_DISCOVERY in the seed.file in <Web NMS Home>/conf directory.
Note: You can set the 'type' property to any desired value in the ManagedObject table while using discovery filters to identify the type. To identify the type is to identify whether the managed object passed as an argument to the discovery filters is discovered using the user defined discovery process or SNMP/ICMP ping process. This value can be checked in the discovery filters using the getType() of Class ManagedObject, to know whether the object passed is discovered using the conventional discovery process or using the user defined discovery process.