Demo Application
The demo application is a Java GUI application which has multiple
independent small sections.
The demo application could be used for the following:
- Learn SNMP basics. Modify various scalars and tables in the application
and watch how these modifications are reflected in the SNMP browser.
Modify read-write scalars and tables in a MIB browser and watch how these
modifications are reflected in the application.
Create notifications.
- Learn FriendlySNMP and SNMP4J functionality.
Demo application source code is an open source
and you are welcome to use it.
- Test SNMP connection with different protocols and credentials.
The demo application depends on the following Java libraries:
The demo application could be downloaded in two forms:
- Binary form as
zip or
tar.
Archive contains a single JAR file, cmd-file to start the demo application
and all supported MIB files.
All required dependent JAR files packed into a single distribution JAR.
- Eclipse project as
zip or
tar.
Archive file contains Eclipse project with source code,
all required libraries, all supported MIB files, build and run scripts.
The demo application has the following panes:
Pane: About and Info
This pane has two tabs in the right pane: About and Info.
The About tab contains generic information about the application.
The Info tab contains a list of properties which were loaded from the
DemoApp.properties file.
This tab could be helpful to debug SNMP connection.
Pane-1: Scalar read-only
Java code for this pane shows how to use read-only SNMP scalars.
Load
DEMO-SCALAR-RO-MIB
into a MIB browser to access the demo scalars.
The code uses
org.friendlysnmp.event.FScalarGetListener
listeners to respond to GET requests from a MIB browser.
These listeners are implemented only for scalars which values
are changing during the application lifetime.
- Scalar Default user directory is an example of a static value
which does not change during application lifetime.
Scalar managed object of this type should be initialized only once
at application startup.
It makes no sense to implement
org.friendlysnmp.event.FScalarGetListener
listener to respond to GET requests from a MIB browser for this scalar value
because the value never changes.
The code shows how to use class
org.friendlysnmp.FHandler
to initialize static objects.
- Scalar Ticks is an example of a value which is changing at runtime.
The dedicated ticker thread is used to increment ticks counter each second.
The code shows how to use class
org.friendlysnmp.FHandler
to start / stop ticker thread.
- Scalar User name is an example of a string value
which could be modified during application lifetime.
Update the value in the UI and monitor the update in a MIB browser.
- Scalar User level is an example of an enumeration value
which could be modified during application lifetime.
Update the value in the UI and monitor the update in a MIB browser.
- Scalar User age is an example of an integer value
which could be modified during application lifetime.
Update the value in the UI and monitor the update in a MIB browser.
The demo application has registered
org.friendlysnmp.event.FExceptionListener
with the agent.
Test the listener with the following steps.
Enter invalid value (for example 25a ) for the User age and
click button Validate Age.
The validation is performed indirectly by using FriendlySNMP functionality.
Attempt to set value of a wrong type to a scalar throws an exception
while string-to-integer conversion.
The input string value is received from a UI text box,
the output value type is retrieved from a scalar syntax type.
The conversion exception is propagated to all registered
org.friendlysnmp.event.FExceptionListener
event listeners.
The demo application receives the exception and presents it in a message box:
Pane-2: Scalar read-write
Java code for this pane shows how to use read-write SNMP scalars.
Load
DEMO-SCALAR-RW-MIB
into a MIB browser to access the demo scalars.
The code shows how to use the following listeners:
See also section Events and Listeners.
- Scalar Image file name is an example of a string value.
- Scalar Image format is an example of an enumeration value.
- Scalar Image size is an example of a value which has a validation rule.
The valid format for the image size is NNNxMMM.
Attempt to set invalid value is rejected by validator in
org.friendlysnmp.event.FScalarValidationListener
code. Try to set invalid image size from a MIB browser and
check how it is rejected by the demo application with error code
WRONG VALUE .
Pane-3: Static table (URL)
Java code for this pane shows how to use data stored in the SNMP agent
without preserving a copy in Java member variables.
This technique is useful for data which has a static nature.
Examples of this data are application version, configuration parameters, dictionaries and so on.
The application takes responsibility to update data of this type in the SNMP agent
directly when data is available, e.g. when data is loaded from external sources.
Usually this is happening only at application startup.
Load
DEMO-TABLE-URL-MIB
into a MIB browser to access the demo table.
Try to modify data in the demo table.
Modified data is stored directly in the SNMP agent and retrieved from it for display.
MIB browser GET requests are served by SNMP agent with data already available.
Pane-4: Dynamic table (flights)
Java code for this pane shows how to use read-write SNMP tables.
Load
DEMO-TABLE-FLIGHT-MIB
into a MIB browser to access the demo table.
The code shows how to use the following listeners:
-
org.friendlysnmp.event.FTableGetListener
Table content could be retrieved by a MIB browser using GET request.
The demo application receives a GET request, processes it in a listener
and returns the requested values to a MIB browser.
Usually read-write managed objects are not modified in the application.
The demo application gives this option to test GET requests.
The modified table cell values via UI are not marking the table modified.
The table content in this case is not preserved in the persistent storage
and is set to the default value after application restart.
-
org.friendlysnmp.event.FTableSetListener
Table content could be updated from a MIB browser.
The demo application receives a SET request, processes it in a listener
and updates the UI.
Setting a new value of any single cell from a MIB browser
makes the whole table flagged as modified and
preserves the whole table in a persistent storage.
The next time application is restarted the whole table is loaded from
the persistent storage.
A user of the MIB browser has an option to view and modify
persistent storage content.
-
org.friendlysnmp.event.FTableValidationListener
Table with validation listener has an option to reject the value SET
from a MIB browser.
-
org.friendlysnmp.event.FRestoreDefaultListener
Removing an entry from a persistent storage
triggers the
org.friendlysnmp.event.FRestoreDefaultEvent
which is processed in the demo application and restores original default value.
See also section Events and Listeners.
- The columns Carrier and Destination are examples of string values.
- The column Flight No is an example of a numeric value.
- The column Depart Time is an example of a string value which has a validation rule.
The valid departure time has the form HH:MM where HH=00..23, MM=00..59.
Attempt to set invalid value is rejected by validator in
org.friendlysnmp.event.FTableValidationListener
code. Try to set invalid value from a MIB browser and
check how it is rejected by the demo application with error code
WRONG TYPE .
- The column Status is an example of an enumeration value.
Pane-5: Two-index table (warehouse)
This demo is very similar to the Dynamic table (flights) demo.
Java code for this pane shows how to use read-write SNMP tables
with two numeric indices.
Load
DEMO-TABLE-WAREHOUSE-MIB
into a MIB browser to access the demo table.
- The column Department is an index of enumeration value.
- The column ID is an index of an numeric value
(most commonly used in SNMP tables).
- The columns Brand and Item are examples of string values.
- The column Price is an example of float value
which is stored as SNMP numeric value and formatted for display with
two decimal points.
Pane-6: Two-index table (marriage)
This demo is very similar to the Dynamic table (flights) demo.
Java code for this pane shows how to use read-write SNMP tables
with two string indices.
Load
DEMO-TABLE-MARRIAGE-MIB
into a MIB browser to access the demo table.
- The columns Husband and Wife are string indices.
- The column Year is a numeric value.
- The column City is a string value.
Pane-7: Notifications
Java code for this pane shows how to SNMP notifications.
Load
DEMO-NOTIFY-WEATHER-MIB
into a MIB browser to declare notifications.
Select radio button for one of notifications and click Send Notification
button. Examine received notification in the MIB browser.
Check parameters sent with notifications.
The notification rain has additional parameters.
Pane-8: Deadlock detection
The FriendlySNMP agent has built-in deadlock detection functionality.
The user of the demo application has an option to test this functionality
by creating deadlocks with multiple threads in a chain.
Each new deadlock chain is labeled with letters A, B, C and so on.
The FriendlySNMP agent sends SNMP notification on deadlock detection.
The extensive information about deadlocked threads is available in a MIB browser.
See details in Deadlock Detection section.
Pane-9: Uncaught exception detection
The FriendlySNMP agent has built-in uncaught runtime exceptions detection
functionality.
The user of the demo application has an option to test this functionality
by creating runtime exceptions.
The FriendlySNMP agent sends SNMP notification on uncaught runtime exception
detection.
The extensive information about each exception is available in a MIB browser.
See details in Exceptions section.
The FriendlySNMP agent generates uncaught exception event
and distributes it to registered listeners.
The demo application has a registered such a listener and receives these events
which are displayed in a message box.
Pane-10: Caught exception reporting
The FriendlySNMP agent could report any caught exception to the MIB browser.
The application discovers exception of this kind in try / catch blocks
and notifies FriendlySNMP agent about this event.
The user of the demo application has an option to test this functionality
by creating checked exceptions.
Exceptions created manually could have any message and might have
any level of cause exceptions.
The exception could be also supplied with an optional comment.
See details in Exceptions section.
Pane-11: Agent & Remote shutdown
The FriendlySNMP agent could be stopped and restarted.
This functionality could be tested on this pane.
Each time the agent is cold-started, stopped, re-started or shutdown it
sends a SNMP notification.
The demo application could be shutdown remotely from a MIB browser
by sending SET request. The demo application has an option to enable
or disable this functionality.
See details in Events and Listeners section.
|