components/net-snmp-57/sun/sdk/demo/demo_module_2/README_demo_module_2
changeset 5867 445e2cf1c845
parent 252 ee0fb1eabcbf
equal deleted inserted replaced
5866:683c5c035a79 5867:445e2cf1c845
       
     1 #
       
     2 # Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
       
     3 #
       
     4 # U.S. Government Rights - Commercial software. Government users are subject
       
     5 # to the Sun Microsystems, Inc. standard license agreement and applicable
       
     6 # provisions of the FAR and its supplements.
       
     7 #
       
     8 #
       
     9 # This distribution may include materials developed by third parties. Sun,
       
    10 # Sun Microsystems, the Sun logo and Solaris are trademarks or registered
       
    11 # trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
       
    12 #
       
    13 #
       
    14 
       
    15 README for demo_module_2
       
    16 ***********************************************************************
       
    17 
       
    18 This example performs data retrieval and data setting for a simple
       
    19 table that provides file monitoring.
       
    20 
       
    21 
       
    22 Introduction
       
    23 ------------
       
    24 
       
    25 The demo_module_2.c code was generated by using  "mib2c -c mib2c.iterate.conf" 
       
    26 against the me1FileTable group in the SDK-DEMO1-MIB. Some functions have been 
       
    27 added to the generated code to implement a link list to provide the test data.
       
    28 
       
    29 mib2c created templates called me1FileTable.c and me1FileTable.h. 
       
    30 These were renamed demo_module_2.c and demo_module_2.h for this demo.  
       
    31 Within me1FileTable.c, mib2c generated init_me1FileTable, and this was renamed
       
    32 to init_demo_module_2.
       
    33 
       
    34 Note that even though the SDK-DEMO1-MIB.txt MIB file contains the
       
    35 specification of table and scalar, running mib2c with mib2c.iterate.conf
       
    36 generates template code only for the simple table in the MIB.
       
    37 
       
    38 
       
    39 
       
    40 How to Build the demo_module_2 Code Example
       
    41 ===========================================
       
    42 
       
    43 The demo_module_2 code example includes the following files, by default 
       
    44 located in the directory /usr/demo/sma_snmp/demo_module_2.
       
    45 
       
    46 
       
    47 Files:
       
    48 
       
    49 Makefile - makefile to build demo_module_2.so shared library file
       
    50 demo_module_2.c  - module source code
       
    51 demo_module_2.h - module header file
       
    52 SDK-DEMO1-MIB.txt - MIB file 
       
    53 
       
    54 
       
    55 To set up your build environment for the demo:
       
    56 
       
    57 1. Copy the demo code to a directory for which you have write permission.
       
    58    For example:
       
    59    % cp -R /usr/demo/sma_snmp/demo_module_2  /home/username/demo
       
    60 
       
    61 
       
    62 2. Create a lib directory that you can use to store shared object libraries 
       
    63    that you generate from demo code examples, if you have not already done so.
       
    64  
       
    65    For example:
       
    66    % mkdir /home/username/demo/lib
       
    67 
       
    68     
       
    69 3. Create a mibs directory that you can use to store MIB files for the demo 
       
    70    code examples, if you have not already done so. 
       
    71    For example:
       
    72    % mkdir /home/username/demo/mibs
       
    73 
       
    74 
       
    75 4. Set the CC environment variable to the location of the C compiler to be 
       
    76    used. For example, if you are using Sun ONE Studio:
       
    77    % setenv CC /opt/SUNWspro/bin/cc
       
    78 
       
    79 
       
    80 5. Set your PATH environment variable to include the appropriate paths, so that
       
    81    needed binaries can be found during the compilation process. 
       
    82    For example, in the csh: 
       
    83     
       
    84    % setenv PATH .:/usr/bin:$PATH
       
    85    
       
    86    
       
    87 
       
    88 To generate code templates from the sample MIB:
       
    89 
       
    90 
       
    91 1. Change to the directory where you copied the demo module files. 
       
    92    For example:
       
    93 
       
    94    % cd /home/username/demo/demo_module_2
       
    95    
       
    96 
       
    97 2. Copy the SDK-DEMO1-MIB.txt file to the mibs directory you created for the 
       
    98    demos, if you have not already done so.
       
    99    For example:
       
   100   
       
   101    % cp SDK-DEMO1-MIB.txt /home/username/demo/mibs
       
   102 
       
   103       
       
   104 3. Set your MIBS and MIBDIRS environment variables to
       
   105    include the appropriate paths.  
       
   106    For example, in the csh: 
       
   107     
       
   108    % setenv MIBDIRS .:/home/username/demo/mibs:/etc/sma/snmp/mibs
       
   109    % setenv MIBS +SDK-DEMO1-MIB
       
   110    
       
   111  
       
   112 4. Run mib2c on the me1ContactInfoTable group in the SDK-DEMO1-MIB.
       
   113    For example:
       
   114    
       
   115    % mib2c -c mib2c.iterate.conf me1FileTable
       
   116 
       
   117    The mib2c utility generates the following template files:
       
   118    me1FileTable.c 
       
   119    me1FileTable.h
       
   120    
       
   121 
       
   122 5. Compare the template files with the demo_module_2.c and the
       
   123    demo_module_2.h files.    
       
   124    
       
   125 
       
   126 
       
   127 To build the example:
       
   128 
       
   129 1. Change to the directory where you copied the demo module files. 
       
   130    For example:
       
   131 
       
   132    % cd /home/username/demo/demo_module_2
       
   133    
       
   134 
       
   135 2. Use the make command to generate object files.
       
   136   
       
   137    If you are running the 64-bit SPARC Solaris kernel, type:
       
   138    % /usr/ccs/bin/make
       
   139    
       
   140    If you are running the 32-bit SPARC Solaris kernel, type:
       
   141    % /usr/ccs/bin/make ARCH=32
       
   142    
       
   143    If you are running the Solaris x86 kernel, type:
       
   144    % /usr/ccs/bin/make ARCH=32
       
   145    
       
   146 
       
   147 3. Copy the module shared library object to the lib directory you created. 
       
   148    For example:
       
   149 
       
   150    % cp demo_module_2.so /home/username/demo/lib
       
   151    
       
   152 
       
   153 4. Copy the SDK-DEMO1-MIB.tx file to the mibs directory you created 
       
   154    for the demos, if you have not already done so.
       
   155    For example:
       
   156      
       
   157    % cp SDK-DEMO1-MIB.txt /home/username/demo/mibs
       
   158 
       
   159 
       
   160 
       
   161 Setting Up Agent to Run demo_module_2
       
   162 =====================================
       
   163     
       
   164 1. As root, edit the agent's configuration file /etc/sma/snmp/snmpd.conf,
       
   165    and insert a dlmod statement for the module. This statement enables 
       
   166    the agent to load the module.
       
   167    For example:
       
   168    
       
   169    dlmod demo_module_2 /home/username/demo/lib/demo_module_2.so
       
   170    
       
   171     
       
   172 2. As root, start the SMA snmp agent. If the agent is already running, 
       
   173    stop and restart it in debug mode.
       
   174    For example:
       
   175    
       
   176     # /etc/init.d/init.sma stop
       
   177     # /usr/sbin/snmpd -Ddemo_module_2
       
   178     
       
   179     The optional -Ddemo_module_2 argument sends debugging statements from 
       
   180     demo_module_2 to the /var/log/snmpd.log file. You can also use 
       
   181     the -L and -f options to send debugging statements to the screen instead.
       
   182 
       
   183 
       
   184 
       
   185 Testing the Module
       
   186 ==================
       
   187 
       
   188 1. Set your MIBS and MIBDIRS environment variables to
       
   189    include the appropriate paths.  
       
   190    For example, in the csh: 
       
   191     
       
   192    % setenv MIBDIRS .:/home/username/demo/mibs:/etc/sma/snmp/mibs
       
   193    % setenv MIBS +SDK-DEMO1-MIB
       
   194    
       
   195    
       
   196 2. As a non-root user, issue snmptable commands to retrieve table data 
       
   197    from the module.
       
   198    For example:
       
   199    
       
   200    % snmptable -v1 -c public localhost SDK-DEMO1-MIB::me1FileTable 
       
   201    
       
   202    me1FileIndex me1FileName me1FileSize me1FilePerm
       
   203               1  /etc/hosts          78         444
       
   204               2 /etc/passwd         595         644
       
   205               3   /etc/cron       56616         555
       
   206               4 /etc/system        1883         644 
       
   207   
       
   208    
       
   209 
       
   210 
       
   211