1 # common parameters used in SNMP::Session creation and tests
2 $agent_host = 'localhost';
5 $mibdir = '/usr/local/share/snmp/mibs';
7 $comm2 = 'v2c_private';
10 $oid = '.1.3.6.1.2.1.1.1';
12 $auth_pass = 'test_pass_auth';
13 $priv_pass = 'test_pass_priv';
15 # don't use any .conf files other than those specified.
16 $ENV{'SNMPCONFPATH'} |= "bogus";
18 # erroneous input to test failure cases
19 $bad_comm = 'BAD_COMMUNITY';
20 $bad_name = "badName";
21 $bad_oid = ".1.3.6.1.2.1.1.1.1.1.1";
22 $bad_host = 'bad.host.here';
23 $bad_port = '9999999';
24 $bad_auth_pass = 'bad_auth_pass';
25 $bad_priv_pass = 'bad_priv_pass';
26 $bad_sec_name = 'bad_sec_name';
34 sub snmptest_cleanup {
35 sleep 1; # strangely we need to wait for pid files to appear ??
36 if ((-e "t/snmpd.pid") && (-r "t/snmpd.pid")) {
37 # Making sure that any running agents are killed.
38 # warn "killing snmpd:", `cat t/snmpd.pid`, "\n";
39 system "kill `cat t/snmpd.pid` > /dev/null 2>&1";
42 if ((-e "t/snmptrapd.pid") && (-r "t/snmptrapd.pid")) {
43 # Making sure that any running agents are killed.
44 # warn "killing snmptrap:", `cat t/snmptrapd.pid`, "\n";
45 system "kill `cat t/snmptrapd.pid` > /dev/null 2>&1";
46 unlink "t/snmptrapd.pid";
50 #Open the snmptest.cmd file and get the info
51 if (open(CMD, "<t/snmptest.cmd")) {
52 while ($line = <CMD>) {
53 if ($line =~ /HOST\s*=>\s*(\S+)/) {
55 } elsif ($line =~ /MIBDIR\s*=>\s*(\S+)/) {
57 } elsif ($line =~ /AGENT_PORT\s*=>\s*(\S+)/) {
59 } elsif ($line =~ /SNMPD\s*=>\s*(\S+)/) {
61 } elsif ($line =~ /SNMPTRAPD\s*=>\s*(\S+)/) {
67 die ("Could not start agent. Couldn't find snmptest.cmd file\n");
70 if ($^O !~ /win32/i) {
72 if (-r $snmpd_cmd and -x $snmpd_cmd) {
73 # print STDERR "running: $snmpd_cmd -r -l t/snmptest.log -C -c t/snmptest.conf -P t/snmpd.pid $agent_port > /dev/null 2>&1\n";
74 system "$snmpd_cmd -r -l t/snmptest.log -C -c t/snmptest.conf -P t/snmpd.pid $agent_port > /dev/null 2>&1";
76 warn("Couldn't run snmpd\n");
80 if (-r $snmptrapd_cmd and -x $snmptrapd_cmd) {
81 system "$snmptrapd_cmd -u t/snmptrapd.pid -c t/snmptest.conf -C $trap_port > /dev/null 2>&1";
83 warn("Couldn't run snmptrapd\n");