|
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_8 |
|
16 ******************************************************************** |
|
17 |
|
18 This code example creates an agentX subagent that calls a module that returns |
|
19 load averages. See the System Management Agent Developer's Guide for |
|
20 more information about creating a subagent. |
|
21 |
|
22 |
|
23 How to Build the demo_module_8 Code Example |
|
24 =========================================== |
|
25 |
|
26 The demo_module_8 code example includes the following files, by default located |
|
27 in the directory /usr/demo/sma_snmp/demo_module_8. |
|
28 |
|
29 Files: |
|
30 |
|
31 o Makefile - Compiles the subagent and module source code |
|
32 o demo_module_8.c - Source code for agentX subagent |
|
33 o me1LoadGroup.c - Source code for module that returns load averages |
|
34 o me1LoadGroup.h - Header file for module |
|
35 o getme1LoadGroup - Script that executes snmpget requests on the OIDs defined |
|
36 in the module |
|
37 o SDK-DEMO1-MIB.txt - MIB file |
|
38 |
|
39 |
|
40 To set up your build environment for the demo: |
|
41 |
|
42 1. Copy the demo code to a directory for which you have write permission. |
|
43 For example: |
|
44 % cp -R /usr/demo/sma_snmp/demo_module_8 /home/username/demo |
|
45 |
|
46 |
|
47 2. Create a lib directory that you can use to store shared object libraries |
|
48 that you generate from demo code examples, if you have not already done so. |
|
49 For example: |
|
50 % mkdir /home/username/demo/lib |
|
51 |
|
52 |
|
53 3. Create a mibs directory that you can use to store MIB files for the demo |
|
54 code examples, if you have not already done so. |
|
55 For example: |
|
56 % mkdir /home/username/demo/mibs |
|
57 |
|
58 |
|
59 4. Set the CC environment variable to the location of the C compiler to be |
|
60 used. |
|
61 For example, if you are using Sun ONE Studio: |
|
62 % setenv CC /opt/SUNWspro/bin/cc |
|
63 |
|
64 |
|
65 5. Set your PATH environment variable to include the appropriate paths, so that |
|
66 needed binaries can be found during the compilation process. |
|
67 For example, in the csh: |
|
68 |
|
69 % setenv PATH .:/usr/bin:$PATH |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 To build the example: |
|
75 |
|
76 1. Change to the directory where you copied the demo module files. |
|
77 For example: |
|
78 |
|
79 % cd /home/username/demo/demo_module_8 |
|
80 |
|
81 |
|
82 2. Use the make command to generate object files. |
|
83 |
|
84 If you are running the 64-bit SPARC Solaris kernel, type: |
|
85 % /usr/ccs/bin/make |
|
86 |
|
87 If you are running the 32-bit SPARC Solaris kernel, type: |
|
88 % /usr/ccs/bin/make ARCH=32 |
|
89 |
|
90 If you are running the Solaris x86 kernel, type: |
|
91 % /usr/ccs/bin/make ARCH=32 |
|
92 |
|
93 |
|
94 3. Copy the module shared library object to the lib directory you created. |
|
95 For example: |
|
96 |
|
97 % cp me1LoadGroup.so /home/username/demo/lib |
|
98 |
|
99 |
|
100 4. This example uses the SDK-DEMO1-MIB.txt file from demo_module_1. If you |
|
101 have not already done so, copy this file to the mibs directory you created |
|
102 for the demos. |
|
103 For example: |
|
104 |
|
105 % cp SDK-DEMO1-MIB.txt /home/username/demo/mibs |
|
106 |
|
107 |
|
108 5. As root, edit the /etc/sma/snmp/snmpd.conf file by adding the following |
|
109 line to enable AgentX master agent support. This causes agentX to be |
|
110 started when the SMA agent starts. Make sure that there are no dlmod |
|
111 statements for the module: |
|
112 |
|
113 master agentx |
|
114 |
|
115 |
|
116 6. As root, start the SMA snmp agent. If the agent is already running, stop |
|
117 and restart it. |
|
118 For example: |
|
119 |
|
120 # /etc/init.d/init.sma stop |
|
121 # /usr/sbin/snmpd -Dagentx |
|
122 |
|
123 The optional -Dagentx argument sends debugging statements from agentX to |
|
124 the /var/log/snmpd.log file. You can also use the -L and -f options to |
|
125 send debugging statements to the screen instead. |
|
126 |
|
127 |
|
128 7. As root, set the LD_LIBRARY_PATH environment variable. |
|
129 For example, if you are using the C shell: |
|
130 |
|
131 In the 64-bit Solaris kernel: |
|
132 # LD_LIBRARY_PATH=/home/username/demo/lib:/usr/lib/sparcv9:/usr/openwin/lib |
|
133 # export LD_LIBRARY_PATH |
|
134 |
|
135 In the 32-bit or x86 Solaris kernel: |
|
136 # LD_LIBRARY_PATH=/home/username/demo/lib:/usr/lib:/usr/openwin/lib |
|
137 # export LD_LIBRARY_PATH |
|
138 |
|
139 |
|
140 8. As root, change to the directory where the demo_module_8 subagent is |
|
141 located and start the subagent in the background. For example: |
|
142 |
|
143 # cd /home/username/demo/demo_module_8 |
|
144 # ./demo_module_8 & |
|
145 |
|
146 The demon listens for agentX requests from the SMA agent. |
|
147 |
|
148 |
|
149 |
|
150 Testing the Example Subagent |
|
151 ============================ |
|
152 |
|
153 1. Set your MIBS and MIBDIRS environment variables to |
|
154 include the appropriate paths. |
|
155 For example, in the csh: |
|
156 |
|
157 % setenv MIBDIRS .:/home/username/demo/mibs:/etc/sma/snmp/mibs |
|
158 % setenv MIBS +SDK-DEMO1-MIB |
|
159 |
|
160 Note that step 1 is not required, but it enables snmpget to access the MIB |
|
161 to provide variable names instead of OIDs in its output in Step 2. |
|
162 |
|
163 |
|
164 2. Run the getme1LoadGroup script to execute snmpget commands against |
|
165 the OIDs defined in the module: |
|
166 |
|
167 % getme1LoadGroup |
|
168 |
|
169 SDK-DEMO1-MIB::me1SystemLoadAvg1min.0 = STRING: 3.906250e-02 Jobs |
|
170 SDK-DEMO1-MIB::me1SystemLoadAvg5min.0 = STRING: 2.734375e-02 Jobs |
|
171 SDK-DEMO1-MIB::me1SystemLoadAvg15min.0 = STRING: 3.906250e-02 Jobs |
|
172 |
|
173 |
|
174 3. View the /var/log/snmpd.log file. Near the beginning of the log file, |
|
175 you should see output similar to the following: |
|
176 |
|
177 agentx/subagent: init_subagent sess 0012bfd8 |
|
178 Turning on AgentX master support. |
|
179 agentx/master: initializing... |
|
180 agentx/master: initializing... DONE |