|
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 |
|
16 README for demo_module_4 |
|
17 *********************************************************************** |
|
18 |
|
19 This example module demonstrates the following features: |
|
20 - Automatic Refresh of data at regular intervals |
|
21 - Check for alarm condition at regular intervals and generate trap if |
|
22 needed. |
|
23 - Read threshold values from configuration file demo_module_4.conf |
|
24 - use of SNMP_CALLBACK_POST_READ_CONFIG |
|
25 |
|
26 See the System Management Agent Developer's Guide for more information |
|
27 about traps, and demo_module_4. |
|
28 |
|
29 |
|
30 |
|
31 How to Use the demo_module_4 Code Example |
|
32 ========================================== |
|
33 |
|
34 The demo_module_4 code example includes the following files, by default |
|
35 located in the directory /usr/demo/sma_snmp/demo_module_4. |
|
36 |
|
37 Files: |
|
38 |
|
39 o Makefile - Compiles the module source code |
|
40 o me4LoadGroup.c - Source code for the module |
|
41 o me4LoadGroup.h - Header file for the module |
|
42 o SDK-DEMO4-MIB.txt - MIB file used in the module |
|
43 o demo_module_4.conf - configuration file used by the module |
|
44 |
|
45 |
|
46 |
|
47 To set up your environment for the demo: |
|
48 |
|
49 1. Copy the demo code to a directory for which you have write permission. |
|
50 For example: |
|
51 |
|
52 % cp -R /usr/demo/sma_snmp/demo_module_4 /home/username/demo |
|
53 |
|
54 |
|
55 2. Create a lib directory that you can use to store shared object libraries |
|
56 that you generate from demo code examples, if you have not already done so. |
|
57 For example: |
|
58 |
|
59 % mkdir /home/username/demo/lib |
|
60 |
|
61 |
|
62 3. Create a mibs directory that you can use to store MIB files for the |
|
63 demo code examples, if you have not already done so. |
|
64 For example: |
|
65 |
|
66 % mkdir /home/username/demo/mibs |
|
67 |
|
68 |
|
69 4. Set the CC environment variable to the location of the C compiler to be |
|
70 used. For example, if you are using Sun ONE Studio: |
|
71 |
|
72 % setenv CC /opt/SUNWspro/bin/cc |
|
73 |
|
74 |
|
75 5. Set your PATH environment variable to include the appropriate paths, so that |
|
76 needed binaries can be found during the compilation process. |
|
77 For example, in the csh: |
|
78 |
|
79 % setenv PATH .:/usr/bin:$PATH |
|
80 |
|
81 |
|
82 |
|
83 To build the example: |
|
84 |
|
85 1. Change to the directory where you copied the demo module files. |
|
86 For example: |
|
87 |
|
88 % cd /home/username/demo/demo_module_4 |
|
89 |
|
90 |
|
91 2. Use the make command to generate object files. |
|
92 |
|
93 If you are running the 64-bit SPARC Solaris kernel, type: |
|
94 % /usr/ccs/bin/make |
|
95 |
|
96 If you are running the 32-bit SPARC Solaris kernel, type: |
|
97 % /usr/ccs/bin/make ARCH=32 |
|
98 |
|
99 If you are running the Solaris x86 kernel, type: |
|
100 % /usr/ccs/bin/make ARCH=32 |
|
101 |
|
102 |
|
103 3. Copy the module shared library object to the lib directory you created. |
|
104 For example: |
|
105 |
|
106 % cp demo_module_4.so /home/username/demo/lib |
|
107 |
|
108 |
|
109 4. Copy the SDK-DEMO4-MIB.txt file to the mibs directory you created for |
|
110 the demos. |
|
111 For example: |
|
112 |
|
113 % cp SDK-DEMO4-MIB.txt /home/username/demo/mibs |
|
114 |
|
115 |
|
116 5. Copy the demo_module_4.conf file to a .snmp directory in your home |
|
117 directory. |
|
118 For example: |
|
119 |
|
120 % mkdir /home/username/.snmp |
|
121 % cp demo_module_4.conf /home/username/.snmp |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 Setting Up Agent to Run demo_module_4 |
|
127 ===================================== |
|
128 |
|
129 1. As root, edit the agent's configuration file /etc/sma/snmp/snmpd.conf, |
|
130 and insert a dlmod statement for the module. This statement enables the |
|
131 agent to load the module. |
|
132 For example: |
|
133 |
|
134 dlmod demo_module_4 /home/username/demo/lib/demo_module_4.so |
|
135 |
|
136 |
|
137 2. As root, start the SMA snmp agent. If the agent is already running, |
|
138 stop and restart it in debug mode. |
|
139 For example: |
|
140 |
|
141 # /etc/init.d/init.sma stop |
|
142 # /usr/sbin/snmpd -Ddemo_module_4 |
|
143 |
|
144 The optional -Ddemo_module_4 argument sends debugging statements from |
|
145 demo_module_4 to the /var/log/snmpd.log file. You can also use |
|
146 the -L and -f options to send debugging statements to the screen instead. |
|
147 |
|
148 |
|
149 |
|
150 Testing the Module |
|
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-DEMO4-MIB |
|
159 |
|
160 |
|
161 2. To get data from the module, issue an snmpwalk request. |
|
162 For example: |
|
163 |
|
164 % snmpwalk -v1 -c public localhost 1.3.6.1.4.1.42.2.2.4.4.4 |
|
165 .1.3.6.1.4.1.42.2.2.4.4.4.1.1.0 = STRING: "0.043" |
|
166 .1.3.6.1.4.1.42.2.2.4.4.4.1.2.0 = STRING: "0.031" |
|
167 .1.3.6.1.4.1.42.2.2.4.4.4.1.3.0 = STRING: "0.027" |
|
168 |
|
169 |
|
170 |
|
171 To catch traps generated by the module: |
|
172 |
|
173 |
|
174 1. Edit the /home/username/.snmp/demo_module_4.conf file and set the |
|
175 thresholds to values that are less than the current load values that |
|
176 were returned in the snmpwalk command. |
|
177 |
|
178 2. As root, edit the /etc/sma/snmp/snmpd.conf file and add |
|
179 the following lines to configure the snmp agent to send traps. |
|
180 |
|
181 trapcommunity public |
|
182 trapsink localhost |
|
183 |
|
184 |
|
185 3. Open a second terminal window and, as root, start snmptrapd in that window. |
|
186 For example, this command starts snmpdtrapd and specifies the format |
|
187 of the output to stderr: |
|
188 |
|
189 # /usr/sbin/snmptrapd -P -F "TRAP from %B on %m/%l/%y at %h:%j:%k \ |
|
190 Enterprise=%N Type=%w SubType=%q \nwith Varbinds: %v \n\n" localhost:162 |
|
191 |
|
192 2003-06-20 12:37:53 NET-SNMP version 5.0.8 Started. |
|
193 |
|
194 |
|
195 4. In the first window, as root, restart the agent. |
|
196 For example: |
|
197 |
|
198 # /etc/init.d/init.sma restart |
|
199 |
|
200 |
|
201 5. In the terminal where snmptrapd is running you should see traps that are |
|
202 generated by the agent. |
|
203 |
|
204 Trap output should be similar to the following: |
|
205 |
|
206 TRAP from sqa-blade-2 on 6/20/2003 at 12:37:57 Enterprise=. Type=0 SubType=0 |
|
207 with Varbinds: .1.3.6.1.2.1.1.3.0 = Timeticks: (13) 0:00:00.13 .1.3.6.1.6.3.1.1.4.1.0 = OID: |
|
208 .1.3.6.1.4.1.42.2.2.4.4.4.2.1 .1.3.6.1.4.1.42.2.2.4.4.4.3.1.0 = STRING: sqa-blade-2 |
|
209 .1.3.6.1.4.1.42.2.2.4.4.4.3.2.0 = STRING: demo_module_4 .1.3.6.1.4.1.42.2.2.4.4.4.3.3.0 = OID: |
|
210 .1.3.6.1.4.1.42.2.2.4.4.4.1.1.0 .1.3.6.1.4.1.42.2.2.4.4.4.3.4.0 = STRING: ERROR |
|
211 .1.3.6.1.4.1.42.2.2.4.4.4.3.5.0 = STRING: Load Average over last 1 minute crossed the threshold |
|
212 |
|
213 TRAP from sqa-blade-2 on 6/20/2003 at 12:37:57 Enterprise=. Type=0 SubType=0 |
|
214 with Varbinds: .1.3.6.1.2.1.1.3.0 = Timeticks: (13) 0:00:00.13 .1.3.6.1.6.3.1.1.4.1.0 = OID: |
|
215 .1.3.6.1.4.1.42.2.2.4.4.4.2.1 .1.3.6.1.4.1.42.2.2.4.4.4.3.1.0 = STRING: sqa-blade-2 |
|
216 .1.3.6.1.4.1.42.2.2.4.4.4.3.2.0 = STRING: demo_module_4 .1.3.6.1.4.1.42.2.2.4.4.4.3.3.0 = OID: |
|
217 .1.3.6.1.4.1.42.2.2.4.4.4.1.2.0 .1.3.6.1.4.1.42.2.2.4.4.4.3.4.0 = STRING: ERROR |
|
218 .1.3.6.1.4.1.42.2.2.4.4.4.3.5.0 = STRING: Load Average over last 5 minute crossed the threshold |
|
219 |
|
220 TRAP from sqa-blade-2 on 6/20/2003 at 12:37:57 Enterprise=. Type=0 SubType=0 |
|
221 with Varbinds: .1.3.6.1.2.1.1.3.0 = Timeticks: (13) 0:00:00.13 .1.3.6.1.6.3.1.1.4.1.0 = OID: |
|
222 .1.3.6.1.4.1.42.2.2.4.4.4.2.1 .1.3.6.1.4.1.42.2.2.4.4.4.3.1.0 = STRING: sqa-blade-2 |
|
223 .1.3.6.1.4.1.42.2.2.4.4.4.3.2.0 = STRING: demo_module_4 .1.3.6.1.4.1.42.2.2.4.4.4.3.3.0 = OID: |
|
224 .1.3.6.1.4.1.42.2.2.4.4.4.1.3.0 .1.3.6.1.4.1.42.2.2.4.4.4.3.4.0 = STRING: ERROR |
|
225 .1.3.6.1.4.1.42.2.2.4.4.4.3.5.0 = STRING: Load Average over last 15 minute crossed the threshold |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |