Branch Coverage

blib/lib/Monitoring/GLPlugin/SNMP.pm
Criterion Covered Total %
branch 5 524 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})
1675 0 0 unless (exists $Monitoring::GLPlugin::SNMP::rawdata->{$oid})
1679 0 0 if (not $self->opts->snmpwalk and scalar @notcached > 0)
1681 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) { }
1688 0 0 if $self->opts->contextengineid
1689 0 0 if $self->opts->contextname
1708 0 0 exists $$Monitoring::GLPlugin::SNMP::rawdata{$_ . '.0'} ? :
0 0 exists $Monitoring::GLPlugin::SNMP::rawdata->{$_} ? :
1720 0 0 if defined $params{'-startindex'}
1722 0 0 if defined $params{'-endindex'}
1724 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1725 0 0 if $self->opts->contextengineid
1726 0 0 if $self->opts->contextname
1739 0 0 if defined $params{'-startindex'}
1741 0 0 if defined $params{'-endindex'}
1743 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1744 0 0 if $self->opts->contextengineid
1745 0 0 if $self->opts->contextname
1757 0 0 if defined $params{'-startindex'}
1759 0 0 if defined $params{'-endindex'}
1763 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1764 0 0 if $self->opts->contextengineid
1765 0 0 if $self->opts->contextname
1787 0 0 if defined $params{'-startindex'}
1789 0 0 if defined $params{'-endindex'}
1792 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1793 0 0 if $self->opts->contextengineid
1794 0 0 if $self->opts->contextname
1815 0 0 if (not $self->opts->snmpwalk) { }
1817 0 0 unless ($result)
1818 0 0 if (scalar @{$params{'-columns'};} < 50 and $params{'-endindex'} and $params{'-startindex'} eq $params{'-endindex'}) { }
1823 0 0 if (not $result and defined $params{'-startindex'} and not $params{'-startindex'} =~ /\./)
1825 0 0 if ($Monitoring::GLPlugin::SNMP::session->error =~ /tooBig/i)
1828 0 0 unless ($result)
1831 0 0 unless ($result)
1837 0 0 if (substr($key, -1) eq ' ')
1879 0 0 if ($params{'-startindex'})
1884 0 0 if (substr($resoid, 0, $lpoid) eq $poid)
1887 0 0 if ($resoid =~ /^$oidpattern(.+)$/)
1888 0 0 if ($1 lt $params{'-startindex'})
1896 0 0 if ($params{'-endindex'})
1901 0 0 if (substr($resoid, 0, $lpoid) eq $poid)
1904 0 0 if ($resoid =~ /^$oidpattern(.+)$/)
1905 0 0 if ($1 gt $params{'-endindex'})
1922 0 0 if (not $self->opts->snmpwalk) { }
1924 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1925 0 0 if $self->opts->contextengineid
1926 0 0 if $self->opts->contextname
1931 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 0) { }
1958 0 0 unless ($self->opts->snmpwalk)
1960 0 0 if ($Monitoring::GLPlugin::SNMP::session->version == 3)
1961 0 0 if $self->opts->contextengineid
1962 0 0 if $self->opts->contextname
1964 0 0 if ($Monitoring::GLPlugin::SNMP::maxrepetitions)
1972 0 0 if (scalar keys %{$result;} == 0)
1980 0 0 if (scalar keys %{$result;} == 0)
1990 0 0 if (substr($key, -1) eq ' ') { }
1994 0 0 unless (exists $result->{'shortkey'})
1997 0 0 if exists $result->{$key}
2013 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib} and exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$oid}) { }
2017 0 0 if (defined $index)
2023 0 0 if (not defined $result && defined $result->{$oid} or $result->{$oid} eq 'noSuchInstance' or $result->{$oid} eq 'noSuchObject' or $result->{$oid} eq 'endOfMibView') { }
2046 0 0 if (not wantarray and ref \$result eq 'SCALAR' and ref \$indices eq 'SCALAR')
2054 0 0 if (ref $index eq 'ARRAY')
2055 0 0 if (scalar @{$index;} == 0) { }
0 0 elsif (not defined $index->[0]) { }
2066 0 0 if (ref $oid ne 'HASH')
2068 0 0 if (exists $result->{$fulloid})
2069 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}) { }
2070 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'} =~ /^(.*?)::(.*)/) { }
2071 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}{$result->{$fulloid}}) { }
2081 0 0 if (scalar @result) { }
2089 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}}) { }
2113 0 0 if (@{$indices;} and scalar @{$indices;} == 1 and not defined $indices->[0][0])
2118 0 0 if (ref $oid ne 'HASH')
2119 0 0 if (exists $result->{$oid})
2120 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'})
2121 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'} =~ /^(.*?)::(.*)/) { }
2122 0 0 if (exists $Monitoring::GLPlugin::SNMP::MibsAndOids::mibs_and_oids->{$mib}{$symoid . 'Definition'}{$result->{$oid}})
2129 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}}) { }
2149 0 0 if keys %{$mo;}
2151 0 0 if (wantarray) { }
2197 0 0 if /^$entrypat\.\d+\.(.*)/
2215 0 0 if ($dimensions == 1) { }
0 0 elsif ($dimensions == 2) { }
0 0 elsif ($dimensions == 3) { }
2220 0 0 unless $Monitoring::GLPlugin::SNMP::a->[0] <=> $Monitoring::GLPlugin::SNMP::b->[0]
2223 0 0 unless $Monitoring::GLPlugin::SNMP::a->[0] <=> $Monitoring::GLPlugin::SNMP::b->[0] or $Monitoring::GLPlugin::SNMP::a->[1] <=> $Monitoring::GLPlugin::SNMP::b->[1]
2228 0 0 if ($dimensions == 1) { }
0 0 elsif ($dimensions == 2) { }
0 0 elsif ($dimensions == 3) { }
2229 0 0 if ($_->[0] == $element[0])
2233 0 0 if ($_->[0] == $element[0] and $_->[1] == $element[1])
2237 0 0 if ($_->[0] == $element[0] and $_->[1] == $element[1] and $_->[2] == $element[2])
2276 0 0 if (ref $key_attr ne 'ARRAY')
2284 0 0 if ($self->opts->name) { }
2285 0 0 if ($self->opts->regexp) { }
2287 0 0 if ($descr =~ /$pattern/i)
2291 0 0 if ($self->opts->name =~ /^\d+$/) { }
2292 0 0 if ($index == 1 * $self->opts->name)
2296 0 0 if (lc $descr eq lc $self->opts->name)
2306 0 0 ref $_ eq 'ARRAY' ? :
2317 0 0 if defined $filter and not &$filter($new_object)
2332 0 0 if ($_ =~ /\.(\d+)$/)
2349 0 0 if (exists $to_i->{$i})
2351 0 0 if $_ =~ /indices/