forked from etingof/snmpsim
-
Notifications
You must be signed in to change notification settings - Fork 6
/
runtests.sh
executable file
·188 lines (136 loc) · 4.25 KB
/
runtests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
#
# Stand up a couple of SNMP command responders, torture them
# with SNMP command recorders in many different ways.
#
# Fail the entire script on any failure.
#
set -e
snmpsim-command-responder \
--log-level error \
--data-dir data \
--variation-modules-dir variation \
--agent-udpv4-endpoint 127.0.0.1:1161 \
--agent-udpv4-endpoint 127.0.0.1:1162 &
SNMPSIMD_1_PID=$!
snmpsim-command-responder-lite \
--log-level error \
--data-dir data \
--variation-modules-dir variation \
--agent-udpv4-endpoint 127.0.0.1:1163 &
SNMPSIMD_2_PID=$!
SNMPSIMD_LOG=$(mktemp /tmp/snmpsimd.XXXXXX)
SNMPREC_LOG=$(mktemp /tmp/snmprec.XXXXXX)
MIB2DEV_LOG=$(mktemp /tmp/mib2dev.XXXXXX)
function cleanup()
{
rm -f $SNMPSIMD_LOG $SNMPSIMD_LOG $MIB2DEV_LOG
kill $SNMPSIMD_1_PID $SNMPSIMD_2_PID
}
trap cleanup EXIT
echo "step 0"
# test snmpsimd instance, 1-st endpoint
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1161
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 1"
# test snmpsimd instance, 2-nd endpoint
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1162
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 2"
# test snmpsimd instance, timeout
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1165 || { echo This is the expected timeout; }
# test snmpsimd instance, numeric module
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--community variation/virtualtable \
--agent-udpv4-endpoint=127.0.0.1:1162
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 3"
# test snmpsimd instance, snmpwalk format
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--community foreignformats/linux \
--agent-udpv4-endpoint=127.0.0.1:1162
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 4"
# test snmpsimd instance, sapwalk format
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--community foreignformats/winxp2 \
--agent-udpv4-endpoint=127.0.0.1:1162
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 5"
# test snmpsimd instance, GETBULK mode
snmpsim-record-commands \
--log-level error \
--use-getbulk \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1161
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 6"
# test snmpsimd instance, v3 noAuthNoPriv
snmpsim-record-commands \
--log-level error \
--v3-user simulator \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1161
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 7"
# test snmpsimd instance, v3 authNoPriv
snmpsim-record-commands \
--log-level error \
--v3-user simulator \
--v3-auth-key auctoritas \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1161
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 8"
# test snmpsimd instance, v3 authPriv
snmpsim-record-commands \
--log-level error \
--v3-user simulator \
--v3-auth-key auctoritas \
--v3-priv-key privatus \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1161
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 9"
# test lite snmpsim instance
snmpsim-record-commands \
--log-level error \
--output-file $SNMPREC_LOG \
--agent-udpv4-endpoint=127.0.0.1:1163
[ -z $SNMPREC_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
rm -f $SNMPREC_LOG
echo "step 10"
# TODO: Fails on --log-level and something else
#snmpsim-record-mibs \
# --log-level error \
# --output-file $MIB2DEV_LOG \
# --mib-module=SNMPv2-MIB
#
#[ -z $MIB2DEV_LOG ] && { echo "Empty .snmprec generated"; exit 1 ; }
#
#rm -f $MIB2DEV_LOG
echo "It works! \o/"