4 unless(grep /blib/, @INC) {
6 @INC = '../lib' if -d '../lib';
10 BEGIN { $n = 17; plan tests => $n }
12 use vars qw($agent_port $comm $agent_host);
13 require "t/startagent.pl";
16 $SNMP::dump_packet = 0;
18 my $junk_oid = ".1.3.6.1.2.1.1.1.1.1.1";
19 my $oid = '.1.3.6.1.2.1.1.1';
20 my $junk_name = 'fooDescr';
21 my $junk_host = 'no.host.here';
22 my $name = "gmarzot\@nortelnetworks.com";
25 # create list of varbinds for GETS, val field can be null or omitted
26 $vars = new SNMP::VarList (
27 ['sysDescr', '0', ''],
39 ['snmpInBadVersions', '0'],
40 ['snmpInBadCommunityNames', '0'],
41 ['snmpInBadCommunityUses', '0'],
42 ['snmpInASNParseErrs', '0'],
43 ['snmpEnableAuthenTraps', '0'],
44 # ['snmpSilentDrops', '0'],
45 # ['snmpProxyDrops', '0'],
46 # ['snmpTrapEnterprise', '2'],
48 # ['hrStorageType', '2'],
49 # ['hrSystemDate', '0'],
50 # ['sysORIndex', '1'],
55 ['sysORLastChange', '0'],
56 ['ipInHdrErrors', '0'],
57 ['ipDefaultTTL', '0'],
58 ['ipInHdrErrors', '0'],
60 ################################################################
62 # test for the max limit the 'get' can provide.
63 # Figure out why the IP and Physical address are not getting printed.
64 # why ifname is not getting printed?
65 ################################################################
66 # ['ipNetToMediaPhysAddress', '0'],
67 # ['ipAdEntAddr', '0'],
68 # ['snmpTrapOID', '0'],
69 # ['hrSystemNumUsers', '0'],
70 # ['hrFSLastFullBackupDate', '0'],
71 # ['ifPromiscuousMode', '0'],
75 ######################################################################
78 new SNMP::Session (DestHost=>$agent_host,Version=>1,Community=>$comm,RemotePort=>$agent_port);
81 ######################################################################
82 # Get the standard Vars and check that we got some defined vars back
83 @ret = $s1->get($vars);
84 ok(!$s1->{ErrorStr} and defined($ret[0]));
85 #print STDERR "Error string = $s1->{ErrorStr}:$s1->{ErrorInd}\n";
86 ######################################################################
87 # Check that we got back the number we asked for.
88 ok($#ret == $#{$vars});
89 #print("dude : $#ret\n");
90 ################################################
93 $contact = $s1->get('sysContact.0');
94 #print("contact is : $contact\n");
95 ok( defined($contact));
98 $name = $s1->get('sysName.0');
99 #print("Name is : $name\n");
103 $location = $s1->get('sysLocation.0');
104 #print("Location is : $location\n");
105 ok( defined($location));
106 #########################################
109 # Test for an integer
110 $ttl = $s1->get('ipDefaultTTL.0');
111 #print("TTL is : $ttl\n");
113 ########################################
116 # Test for a TimeTicks
117 $time = $s1->get('sysUpTime.0');
118 #print("up time is : $time hundredths of a second\n");
120 #########################################
123 #Test for a Counter32 type.
124 $totalDatagramsReceived = $s1->get('ipInHdrErrors.0');
125 #print("totalDatagramsReceived is : $totalDatagramsReceived\n");
126 ok( defined($totalDatagramsReceived));
127 ################################################
130 #Test for a PhysicalAddr type
131 $physaddr = $s1->get('ipNetToMediaPhysAddress.0');
132 #print("physical addr is : $physaddr \n");
133 ok( defined($physaddr));
134 ##############################################
137 #Test for a IpAddr type
138 $ipaddr = $s1->get('ipAdEntAddr.0');
139 #print("Ip address is : $ipaddr \n");
140 ok( defined($ipaddr));
141 ##############################################
145 $trapOID = $s1->get('snmpTrapOID.0');
146 #print("trap OID is : $trapOID $s1->{ErrorStr}\n");
147 ok( defined($trapOID));
148 ##############################################
151 #Test for a Gauge type
152 #$numusers = $s1->get('hrSystemNumUsers.0');
153 #print("Number of users is : $numusers \n");
154 #ok( defined($numusers));
155 ##############################################
158 #Test for a date & time type
159 #$datetime = $s1->get('hrFSLastFullBackupDate.0');
160 #print("Number of users is : $datetime \n");
161 #ok( defined($datetime));
162 ##############################################
165 #Test for a Truth value type
166 #$mode = $s1->get('ifPromiscuousMode.16');
167 #print("Truth value(1 true, 2 false) is : $mode \n");
168 #ok( defined($mode));
169 ##############################################
172 $time = $s1->get('sysORLastChange.0');
173 #print("time stamp is : $time \n");
175 #############################################
178 #$index = $s1->get('sysORIndex.0');
179 #print("index is : $index\n");
180 #ok(defined($index));
181 #############################################
184 $oid = $s1->get('sysORID.1');
185 #print("index is : $oid\n");
187 #############################################
190 $descr = $s1->get('sysORDescr.1');
191 #print("Sys Descr is : $descr\n");
193 #############################################
196 $ifname = $s1->get('ifDescr.1');
197 #print("ifname is : $ifname $s1->{ErrorStr}\n");
198 ok(defined($ifname));
199 #############################################
202 # Try getting some unknown(wrong ?) data
203 $unknown = $s1->get('ifmyData.0');
204 ok(!defined($unknown));
205 ##############################################