Name | Date | Size | |
---|---|---|---|
.. | 2016-11-07 20:19:16 | 14 | |
demo_module_1.c | 2016-11-07 20:19:16 | 5.5 KiB | |
demo_module_1.h | 2016-11-07 20:19:16 | 939 | |
Makefile | 2016-11-07 20:19:16 | 1.2 KiB | |
README_demo_module_1 | 2016-11-07 20:19:16 | 5.9 KiB | |
SDK-DEMO1-MIB.txt | 2016-11-07 20:19:16 | 6.1 KiB |
README_demo_module_1
/*
*
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun,
* Sun Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*/
README for demo_module_1
********************************************************************
for more information about scalar data retrieval.
Introduction
------------
This example shows you how to generate templates with mib2c from a sample
MIB. You can then compare these templates with the source code and header
files provided with the example. The source files were created by modifying
the templates that you create in this example.
The example also shows you how to build a module from the modified source files.
The demo_module_1 code example includes the following files, by default
located in the directory /usr/demo/sma_snmp/demo_module_1.
Files:
o Makefile - Compiles the module source code
o demo_module_1.c - Source code for the module, returns load averages
o demo_module_1.h - Header file for the module
o SDK-DEMO1-MIB.txt - MIB file used in the module
How to Use the demo_module_1 Code Example
==========================================
To set up your environment for the demo:
1. Copy the demo code to a directory for which you have write permission.
For example:
2. Create a lib directory that you can use to store shared object libraries
that you generate from demo code examples, if you have not already done so.
For example:
3. Create a mibs directory that you can use to store MIB files for the
demo code examples, if you have not already done so.
For example:
4. Set the CC environment variable to the location of the C compiler to be used.
For example, if you are using Sun ONE Studio:
5. Set your PATH environment variable to include the appropriate paths, so that
needed binaries can be found during the compilation process.
For example, in the csh:
To generate code templates from the sample MIB:
1. Change to the directory where you copied the demo module files.
For example:
% cd /home/username/demo/demo_module_1
2. Copy the SDK-DEMO1-MIB.txt file to the mibs directory you created
for the demos.
For example:
% cp SDK-DEMO1-MIB.txt /home/username/demo/mibs
3. Set your MIBS and MIBDIRS environment variables to
include the appropriate paths.
For example, in the csh:
% setenv MIBS +SDK-DEMO1-MIB
4. Run mib2c on the me1LoadGroup group in the SDK-DEMO1-MIB.
For example:
% mib2c -c mib2c.scalar.conf me1LoadGroup
The mib2c utility generates the following template files:
me1LoadGroup.c
me1LoadGroup.h
5. Compare the template files with the demo_module_1.c and the
demo_module_1.h files.
The demo_module_1 files were created by modifying the templates.
=============================================
and insert a dlmod statement for the module. This statement enables
the agent to load the module.
For example:
dlmod demo_module_1 /home/username/demo/lib/demo_module_1.so
2. As root, start the SMA snmp agent. If the agent is already running, stop
and restart it in debug mode.
For example:
The optional -Ddemo_module_1 argument sends debugging statements
You can also use the -L and -f options to send debugging statements to
the screen instead.
Testing the Module
==================
1. As a non-root user, issue snmpget commands to retrieve scalar data from the module.
For example:
% snmpget -v1 -c public localhost SDK-DEMO1-MIB::me1SystemLoadAvg1min.0
% snmpget -v1 -c public localhost SDK-DEMO1-MIB::me1SystemLoadAvg5min.0
% snmpget -v1 -c public localhost SDK-DEMO1-MIB::me1SystemLoadAvg15min.0
Or
% snmpget -v1 -c public localhost .1.3.6.1.4.1.42.2.2.4.4.1.1.1.0
% snmpget -v1 -c public localhost .1.3.6.1.4.1.42.2.2.4.4.1.1.2.0
% snmpget -v1 -c public localhost .1.3.6.1.4.1.42.2.2.4.4.1.1.3.0
These commands should produce output similar to the following:
SDK-DEMO1-MIB::me1SystemLoadAvg1min.0 = STRING: 3.906250e-02 Jobs
SDK-DEMO1-MIB::me1SystemLoadAvg5min.0 = STRING: 2.734375e-02 Jobs
SDK-DEMO1-MIB::me1SystemLoadAvg15min.0 = STRING: 3.906250e-02 Jobs