Name Date Size

.. 2016-11-07 20:19:16 14

demo_module_2.c 2016-11-07 20:19:16 15.1 KiB

demo_module_2.h 2016-11-07 20:19:16 1.5 KiB

Makefile 2016-11-07 20:19:16 1.2 KiB

README_demo_module_2 2016-11-07 20:19:16 6 KiB

SDK-DEMO1-MIB.txt 2016-11-07 20:19:16 6.1 KiB

README_demo_module_2

#
# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
#
# 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_2
***********************************************************************
This example performs data retrieval and data setting for a simple
table that provides file monitoring.
Introduction
------------
The demo_module_2.c code was generated by using "mib2c -c mib2c.iterate.conf"
against the me1FileTable group in the SDK-DEMO1-MIB. Some functions have been
added to the generated code to implement a link list to provide the test data.
mib2c created templates called me1FileTable.c and me1FileTable.h.
These were renamed demo_module_2.c and demo_module_2.h for this demo.
Within me1FileTable.c, mib2c generated init_me1FileTable, and this was renamed
to init_demo_module_2.
Note that even though the SDK-DEMO1-MIB.txt MIB file contains the
specification of table and scalar, running mib2c with mib2c.iterate.conf
generates template code only for the simple table in the MIB.
How to Build the demo_module_2 Code Example
===========================================
The demo_module_2 code example includes the following files, by default
located in the directory /usr/demo/sma_snmp/demo_module_2.
Files:
Makefile - makefile to build demo_module_2.so shared library file
demo_module_2.c - module source code
demo_module_2.h - module header file
SDK-DEMO1-MIB.txt - MIB file
To set up your build environment for the demo:
1. Copy the demo code to a directory for which you have write permission.
For example:
% cp -R /usr/demo/sma_snmp/demo_module_2 /home/username/demo
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:
% mkdir /home/username/demo/lib
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:
% mkdir /home/username/demo/mibs
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:
% setenv CC /opt/SUNWspro/bin/cc
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:
% setenv PATH .:/usr/bin:$PATH
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_2
2. Copy the SDK-DEMO1-MIB.txt file to the mibs directory you created for the
demos, if you have not already done so.
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 MIBDIRS .:/home/username/demo/mibs:/etc/sma/snmp/mibs
% setenv MIBS +SDK-DEMO1-MIB
4. Run mib2c on the me1ContactInfoTable group in the SDK-DEMO1-MIB.
For example:
% mib2c -c mib2c.iterate.conf me1FileTable
The mib2c utility generates the following template files:
me1FileTable.c
me1FileTable.h
5. Compare the template files with the demo_module_2.c and the
demo_module_2.h files.
To build the example:
1. Change to the directory where you copied the demo module files.
For example:
% cd /home/username/demo/demo_module_2
2. Use the make command to generate object files.
If you are running the 64-bit SPARC Solaris kernel, type:
% /usr/ccs/bin/make
If you are running the 32-bit SPARC Solaris kernel, type:
% /usr/ccs/bin/make ARCH=32
If you are running the Solaris x86 kernel, type:
% /usr/ccs/bin/make ARCH=32
3. Copy the module shared library object to the lib directory you created.
For example:
% cp demo_module_2.so /home/username/demo/lib
4. Copy the SDK-DEMO1-MIB.tx file to the mibs directory you created
for the demos, if you have not already done so.
For example:
% cp SDK-DEMO1-MIB.txt /home/username/demo/mibs
Setting Up Agent to Run demo_module_2
=====================================
1. As root, edit the agent's configuration file /etc/sma/snmp/snmpd.conf,
and insert a dlmod statement for the module. This statement enables
the agent to load the module.
For example:
dlmod demo_module_2 /home/username/demo/lib/demo_module_2.so
2. As root, start the SMA snmp agent. If the agent is already running,
stop and restart it in debug mode.
For example:
# /etc/init.d/init.sma stop
# /usr/sbin/snmpd -Ddemo_module_2
The optional -Ddemo_module_2 argument sends debugging statements from
demo_module_2 to the /var/log/snmpd.log file. You can also use
the -L and -f options to send debugging statements to the screen instead.
Testing the Module
==================
1. Set your MIBS and MIBDIRS environment variables to
include the appropriate paths.
For example, in the csh:
% setenv MIBDIRS .:/home/username/demo/mibs:/etc/sma/snmp/mibs
% setenv MIBS +SDK-DEMO1-MIB
2. As a non-root user, issue snmptable commands to retrieve table data
from the module.
For example:
% snmptable -v1 -c public localhost SDK-DEMO1-MIB::me1FileTable
me1FileIndex me1FileName me1FileSize me1FilePerm
1 /etc/hosts 78 444
2 /etc/passwd 595 644
3 /etc/cron 56616 555
4 /etc/system 1883 644