Branch Coverage

blib/lib/Monitoring/GLPlugin/SNMP.pm
Criterion Covered Total %
branch 5 522 0.9


line true false branch
31 0 1 unless grep /BEGIN/, keys %Monitoring::GLPlugin::
33 1 0 unless grep /BEGIN/, keys %Monitoring::GLPlugin::SNMP::MibsAndOids::
35 1 0 unless grep /BEGIN/, keys %Monitoring::GLPlugin::SNMP::CSF::
37 1 0 unless grep /BEGIN/, keys %Monitoring::GLPlugin::SNMP::Item::
39 1 0 unless grep /BEGIN/, keys %Monitoring::GLPlugin::SNMP::TableItem::
47 0 0 if ($self->opts->community and $self->opts->community =~ /^snmpv3(.)(.+)/)
51 0 0 if defined $authprotocol and $authprotocol
53 0 0 if defined $authpassword and $authpassword
55 0 0 if defined $privprotocol and $privprotocol
57 0 0 if defined $privpassword and $privpassword
59 0 0 if defined $username and $username
61 0 0 if defined $contextengineid and $contextengineid
63 0 0 if defined $contextname and $contextname
67 0 0 if ($self->opts->authpassword || $self->opts->authprotocol || $self->opts->privpassword || $self->opts->privprotocol and !$self->opts->protocol eq '3')
216 0 0 if ($self->opts->mode eq 'walk') { }
217 0 0 if ($self->opts->snmpwalk and $self->opts->hostname) { }
0 0 elsif (not $self->opts->snmpwalk and $self->opts->hostname and $self->opts->mode eq 'walk') { }
218 0 0 if ($self->check_messages == 2)
223 0 0 if ($message eq sprintf('file %s not found', $self->opts->snmpwalk))
241 0 0 if ($self->opts->snmpwalk and not $self->opts->hostname) { }
0 0 elsif ($self->opts->snmpwalk and $self->opts->hostname) { }
253 0 0 if ($self->mode =~ /device::walk/) { }
0 0 elsif ($self->mode =~ /device::uptime/) { }
0 0 elsif ($self->mode =~ /device::supportedmibs/) { }
258 0 0 if ($self->opts->oids) { }
0 0 elsif ($self->can('trees')) { }
269 0 0 if ($self->opts->snmpdump)
272 0 0 if $self->opts->protocol =~ /^v(.*)/
273 0 0 if (defined $self->opts->offline) { }
275 0 0 unless ($self->check_pidfile)
301 0 0 if (not $snmpwalkpid) { }
307 0 0 unless $timedout
308 0 0 if -f $self->{'pidfile'}
309 0 0 if ($timedout) { }
343 0 0 if ($self->opts->name and -f $self->opts->name) { }
0 0 elsif ($self->opts->name and not -f $self->opts->name) { }
345 0 0 if $@
738 0 0 if $self->opts->protocol eq '1' and $mibinfo->[2] ne 'v1'
739 0 0 if $self->opts->protocol ne '1' and $mibinfo->[2] eq 'v1'
744 0 0 if ($self->implements_mib($mib))
753 0 0 unless substr($_, 0, length $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}) ne $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}
775 0 0 if ($self->opts->snmpwalk) { }
777 0 0 if (not -f $self->opts->snmpwalk) { }
0 0 elsif (-x $self->opts->snmpwalk) { }
789 0 0 if (/^([\.\d]+) = .*?: (\-*\d+)/) { }
0 0 elsif (/^([\.\d]+) = .*?: "(.*?)"/) { }
798 0 0 if (defined $self->opts->offline and $self->opts->mode ne 'walk')
799 0 0 if (time - (stat $self->opts->snmpwalk)[9] > $self->opts->offline)
804 0 0 if $self->opts->mode ne 'walk'
808 0 0 if (/^([\d\.]+) = .*?INTEGER: .*\((\-*\d+)\)/) { }
0 0 elsif (/^([\d\.]+) = .*?Opaque:.*?Float:.*?([\-\.\d]+)/) { }
0 0 elsif (/^([\d\.]+) = STRING:\s*$/) { }
0 0 elsif (/^([\d\.]+) = Network Address: (.*)/) { }
0 0 elsif (/^([\d\.]+) = Hex-STRING: (.*)/) { }
0 0 elsif (/^([\d\.]+) = \w+: (\-*\d+)\s*$/) { }
0 0 elsif (/^([\d\.]+) = \w+: "(.*?)"/) { }
0 0 elsif (/^([\d\.]+) = \w+: (.*)/) { }
0 0 elsif (/^([\d\.]+) = (\-*\d+)/) { }
0 0 elsif (/^([\d\.]+) = "(.*?)"/) { }
841 0 0 if ($oid =~ /^\./)
854 0 0 if (not $self->check_messages)
860 0 0 if (defined $sysUptime and defined $sysDescr) { }
863 0 0 if (defined $snmpEngineTime and $snmpEngineTime =~ /^\d+$/ and $snmpEngineTime > 0) { }
876 0 0 if ($tac - $tic >= $Monitoring::GLPlugin::SNMP::session->timeout) { }
883 0 0 if $Monitoring::GLPlugin::SNMP::session
891 0 0 if (eval 'require Net::SNMP') { }
903 0 0 if ($self->opts->port)
906 0 0 if ($self->opts->domain)
910 0 0 if ($self->opts->protocol eq '3') { }
913 0 0 if ($self->opts->authpassword)
917 0 0 if ($self->opts->authprotocol)
920 0 0 if ($self->opts->privpassword)
924 0 0 if ($self->opts->privprotocol)
940 0 0 if (not defined $session) { }
957 0 0 if $Monitoring::GLPlugin::SNMP::session
963 0 0 if ($self->opts->protocol eq '3') { }
965 0 0 if (defined $self->opts->community2 and $self->decode_password($self->opts->community2) ne $self->decode_password($self->opts->community))
979 0 0 if $Monitoring::GLPlugin::SNMP::session
981 0 0 if $Monitoring::GLPlugin::SNMP::session
992 0 0 if (ref $self eq 'Classes::Generic') { }
0 0 elsif (ref $self eq 'Classes::Device') { }
0 0 elsif (ref $self eq 'Monitoring::GLPlugin::SNMP') { }
998 0 0 $self->{'productname'} eq 'unknown' ? :
1007 0 0 if ($@)
1012 0 0 if (ref $self eq 'Monitoring::GLPlugin::SNMP')
1034 0 0 if ($sysobj and $oid eq $sysobj)
1044 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} or exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}) { }
1052 0 0 if ($self->get_variable('verbose'))
1054 0 0 exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} ? :
1058 0 0 if ($self->get_variable('verbose'))
1060 0 0 exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} ? :
1063 0 0 if (scalar @newkeys <= scalar @oldkeys)
1069 0 0 if ($@) { }
1072 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::requirements->{$mib})
1084 0 0 unless (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib})
1088 0 0 if $sysobj
1089 0 0 if ($sysobj and $sysobj eq $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib})
1093 0 0 if ($sysobj and $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib} eq substr($sysobj, 0, length $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}))
1100 0 0 if ($self->opts->snmpwalk) { }
1124 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1125 0 0 if $self->opts->contextengineid
1126 0 0 if $self->opts->contextname
1130 0 0 if ($traces and not exists $$traces{$Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}} and grep {substr($_, 0, length $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib}) eq $Monitoring::GLPlugin::SNMP::MibsAndOids::mib_ids->{$mib};} keys %{$traces;})
1142 0 0 if ($timestr =~ /\((\d+)\)/) { }
0 0 elsif ($timestr =~ /(\d+)\s*day[s]*.*?(\d+):(\d+):(\d+)\.(\d+)/) { }
0 0 elsif ($timestr =~ /(\d+):(\d+):(\d+):(\d+)\.(\d+)/) { }
0 0 elsif ($timestr =~ /(\d+):(\d+):(\d+)\.(\d+)/) { }
0 0 elsif ($timestr =~ /(\d+)\s*hour[s]*.*?(\d+):(\d+)\.(\d+)/) { }
0 0 elsif ($timestr =~ /(\d+)\s*minute[s]*.*?(\d+)\.(\d+)/) { }
0 0 elsif ($timestr =~ /(\d+)\.\d+\s*second[s]/) { }
0 0 elsif ($timestr =~ /^(\d+)$/) { }
1177 0 0 $days < 1 ? :
1185 0 0 if (exists $self->{'flat_indices'}) { }
1198 0 0 if ($self->opts->snmpwalk and not $self->opts->hostname)
1202 0 0 if ($self->opts->community)
1223 0 0 if (ref $key_attr ne 'ARRAY')
1231 0 0 if ($force or not -f $statefile or (stat $statefile)[9] < $update)
1247 0 0 if (ref $key_attr ne 'ARRAY')
1264 0 0 if (ref $key_attr ne 'ARRAY')
1271 0 0 if (-f $statefile)
1277 0 0 if ($@)
1302 0 0 if (defined $value)
1317 0 0 unless exists $self->{$arrayname}
1318 0 0 if (not exists $Monitoring::GLPlugin::SNMP::tablecache->{$mib} && exists $Monitoring::GLPlugin::SNMP::tablecache->{$mib}{$table}) { }
1323 0 0 if defined $filter and not &$filter($new_object)
1330 0 0 if defined $filter and not &$filter($new_object)
1343 0 0 if (exists $$into_indices{$element->{'flat_indices'}})
1361 0 0 if (&$func($into_elem, $from_elem))
1377 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition}) { }
1379 0 0 if (ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'CODE') { }
0 0 elsif (ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'HASH') { }
1391 0 0 if ($table and exists $Monitoring::GLPlugin::SNMP::tablecache->{$mib}) { }
0 0 elsif ($mib) { }
1406 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$mo})
1408 0 0 defined $index ? :
1411 0 0 if (defined $response->{$oid})
1412 0 0 if ($response->{$oid} eq 'noSuchInstance' or $response->{$oid} eq 'noSuchObject') { }
0 0 elsif (my(@symbols) = $self->make_symbolic($mib, $response, [[$index]])) { }
1418 0 0 defined $response->{$oid} ? :
1419 0 0 unless (defined $response->{$oid} or defined $index)
1456 0 0 scalar @{$rows;} ? :
1470 0 0 if ($table =~ /^(.*?)\+(.*)/)
1476 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$table})
1478 0 0 if (scalar @{$indices;} == 1 and $indices->[0] == -1) { }
0 0 elsif (scalar @{$indices;} == 1) { }
0 0 elsif (scalar @{$indices;} > 1) { }
0 0 elsif (scalar @{$rows;}) { }
1494 0 0 if ($augmenting_table and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$augmenting_table})
1537 0 0 if ($augmenting_table and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$augmenting_table})
1596 0 0 if ($augmenting_table and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$augmenting_table})
1669 0 0 unless (exists $Monitoring::GLPlugin::SNMP::rawdata->{$oid})
1673 0 0 if (not $self->opts->snmpwalk and scalar @notcached > 0)
1675 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 0) { }
0 0 elsif ($Monitoring::GLPlugin::SNMP::session->version == 1) { }
0 0 elsif ($Monitoring::GLPlugin::SNMP::session->version == 3) { }
1682 0 0 if $self->opts->contextengineid
1683 0 0 if $self->opts->contextname
1702 0 0 exists $$Monitoring::GLPlugin::SNMP::rawdata{$_ . '.0'} ? :
0 0 exists $Monitoring::GLPlugin::SNMP::rawdata->{$_} ? :
1714 0 0 if defined $params{'-startindex'}
1716 0 0 if defined $params{'-endindex'}
1718 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1719 0 0 if $self->opts->contextengineid
1720 0 0 if $self->opts->contextname
1733 0 0 if defined $params{'-startindex'}
1735 0 0 if defined $params{'-endindex'}
1737 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1738 0 0 if $self->opts->contextengineid
1739 0 0 if $self->opts->contextname
1751 0 0 if defined $params{'-startindex'}
1753 0 0 if defined $params{'-endindex'}
1757 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1758 0 0 if $self->opts->contextengineid
1759 0 0 if $self->opts->contextname
1781 0 0 if defined $params{'-startindex'}
1783 0 0 if defined $params{'-endindex'}
1786 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1787 0 0 if $self->opts->contextengineid
1788 0 0 if $self->opts->contextname
1809 0 0 if (not $self->opts->snmpwalk) { }
1811 0 0 unless ($result)
1812 0 0 if (scalar @{$params{'-columns'};} < 50 and $params{'-endindex'} and $params{'-startindex'} eq $params{'-endindex'}) { }
1817 0 0 if (not $result and defined $params{'-startindex'} and not $params{'-startindex'} =~ /\./)
1819 0 0 if ($Monitoring::GLPlugin::SNMP::session->error =~ /tooBig/i)
1822 0 0 unless ($result)
1825 0 0 unless ($result)
1831 0 0 if (substr($key, -1) eq ' ')
1873 0 0 if ($params{'-startindex'})
1878 0 0 if (substr($resoid, 0, $lpoid) eq $poid)
1881 0 0 if ($resoid =~ /^$oidpattern(.+)$/)
1882 0 0 if ($1 lt $params{'-startindex'})
1890 0 0 if ($params{'-endindex'})
1895 0 0 if (substr($resoid, 0, $lpoid) eq $poid)
1898 0 0 if ($resoid =~ /^$oidpattern(.+)$/)
1899 0 0 if ($1 gt $params{'-endindex'})
1916 0 0 if (not $self->opts->snmpwalk) { }
1918 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1919 0 0 if $self->opts->contextengineid
1920 0 0 if $self->opts->contextname
1925 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 0) { }
1952 0 0 unless ($self->opts->snmpwalk)
1954 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1955 0 0 if $self->opts->contextengineid
1956 0 0 if $self->opts->contextname
1961 0 0 if (scalar keys %{$result;} == 0)
1969 0 0 if (scalar keys %{$result;} == 0)
1979 0 0 if (substr($key, -1) eq ' ') { }
1983 0 0 unless (exists $result->{'shortkey'})
1986 0 0 if exists $result->{$key}
2002 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$oid}) { }
2006 0 0 if (defined $index)
2012 0 0 if (not defined $result && defined $result->{$oid} or $result->{$oid} eq 'noSuchInstance' or $result->{$oid} eq 'noSuchObject' or $result->{$oid} eq 'endOfMibView') { }
2035 0 0 if (not wantarray and ref \$result eq 'SCALAR' and ref \$indices eq 'SCALAR')
2043 0 0 if (ref $index eq 'ARRAY')
2044 0 0 if (scalar @{$index;} == 0) { }
0 0 elsif (not defined $index->[0]) { }
2055 0 0 if (ref $oid ne 'HASH')
2057 0 0 if (exists $result->{$fulloid})
2058 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}) { }
2059 0 0 if (ref $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'} eq 'HASH') { }
0 0 elsif ($Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'} =~ /^OID::(.*)/) { }
0 0 elsif ($Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'} =~ /^(.*?)::(.*)/) { }
2060 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}{$result->{$fulloid}}) { }
2070 0 0 if (scalar @result) { }
2078 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} and ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'CODE') { }
0 0 elsif (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} and ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'HASH' and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition}{$result->{$fulloid}}) { }
2102 0 0 if (@{$indices;} and scalar @{$indices;} == 1 and not defined $indices->[0][0])
2107 0 0 if (ref $oid ne 'HASH')
2108 0 0 if (exists $result->{$oid})
2109 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'})
2110 0 0 if (ref $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'} eq 'HASH') { }
0 0 elsif ($Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'} =~ /^(.*?)::(.*)/) { }
2111 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}{$result->{$oid}})
2118 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} and ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'CODE') { }
0 0 elsif (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} and ref $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition} eq 'HASH' and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::definitions->{$mib}{$definition}{$result->{$oid}}) { }
2138 0 0 if keys %{$mo;}
2140 0 0 if (wantarray) { }
2186 0 0 if /^$entrypat\.\d+\.(.*)/
2204 0 0 if ($dimensions == 1) { }
0 0 elsif ($dimensions == 2) { }
0 0 elsif ($dimensions == 3) { }
2209 0 0 unless $Monitoring::GLPlugin::SNMP::a->[0] <=> $Monitoring::GLPlugin::SNMP::b->[0]
2212 0 0 unless $Monitoring::GLPlugin::SNMP::a->[0] <=> $Monitoring::GLPlugin::SNMP::b->[0] or $Monitoring::GLPlugin::SNMP::a->[1] <=> $Monitoring::GLPlugin::SNMP::b->[1]
2217 0 0 if ($dimensions == 1) { }
0 0 elsif ($dimensions == 2) { }
0 0 elsif ($dimensions == 3) { }
2218 0 0 if ($_->[0] == $element[0])
2222 0 0 if ($_->[0] == $element[0] and $_->[1] == $element[1])
2226 0 0 if ($_->[0] == $element[0] and $_->[1] == $element[1] and $_->[2] == $element[2])
2265 0 0 if (ref $key_attr ne 'ARRAY')
2273 0 0 if ($self->opts->name) { }
2274 0 0 if ($self->opts->regexp) { }
2276 0 0 if ($descr =~ /$pattern/i)
2280 0 0 if ($self->opts->name =~ /^\d+$/) { }
2281 0 0 if ($index == 1 * $self->opts->name)
2285 0 0 if (lc $descr eq lc $self->opts->name)
2295 0 0 ref $_ eq 'ARRAY' ? :
2306 0 0 if defined $filter and not &$filter($new_object)
2321 0 0 if ($_ =~ /\.(\d+)$/)
2338 0 0 if (exists $to_i->{$i})
2340 0 0 if $_ =~ /indices/