Branch Coverage

blib/lib/Zabbix/ServerScript.pm
Criterion Covered Total %
branch 96 108 88.8


line true false branch
26 0 19 unless eval { do { require Zabbix::ServerScript::Config; 1 } } or eval { do { require Zabbix::ServerScript::DefaultConfig; 1 } }
51 13 7 if (defined $opt) { }
52 1 12 unless ref $opt eq 'HASH'
57 81 14 unless defined $opt->{$_}
66 1 18 unless &GetOptions($opt, @opt_specs)
86 2 10 if (defined $id) { }
96 15 63 unless defined $opt
98 0 78 unless defined $Zabbix::ServerScript::Config->{'log_dir'}
99 3 75 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
100 31 44 if (defined $opt->{'log_filename'}) { }
101 28 3 if ($opt->{'log_filename'} ne '') { }
110 3 69 unless defined $Zabbix::ServerScript::Config->{'log'}
114 15 51 if (defined $opt->{'logger'}) { }
115 12 3 if ($opt->{'logger'} eq '') { }
121 16 35 if (defined $opt->{'console'} and $opt->{'console'} == 1) { }
130 7 5 if (defined $opt->{'verbose'} and $opt->{'verbose'})
133 5 61 if (defined $opt->{'debug'} and $opt->{'debug'} == 1)
139 36 21 if ($^S and not defined $ENV{'ZBX_TESTING'} && $ENV{'ZBX_TESTING'} == 1)
160 1 13 unless defined $ENV{'BASENAME'} and $ENV{'ID'}
162 11 2 unless (defined $config_filename)
165 13 0 if ($config_filename ne '')
166 2 11 if (-f $config_filename) { }
168 0 1 unless $config = YAML::LoadFile($config_filename)
170 11 0 unless $config_filename eq ''
180 8 9 if (defined $api)
189 3 5 if defined $id
201 2 9 if (defined $unique and $unique)
203 0 1 if ('Proc::PID::File'->running($pid))
211 2 9 if $daemon
217 1 3 unless (defined $cache_filename)
222 3 1 if (-f $cache_filename) { }
227 1 2 unless (eval { do { $cache = retrieve($cache_filename); 1 } })
238 1 2 unless (defined $cache_filename)
246 1 2 unless (eval { do { store($cache, $cache_filename); 1 } })
269 1 2 if (defined $value) { }
281 1 2 unless defined $dbname
284 1 1 unless $dbh = 'DBI'->connect("dbi:ODBC:DSN=$dbname", $user, $password)
295 6 2 if (ref $request_data eq 'HASH') { }
1 1 elsif (ref $request_data ne 'ARRAY') { }
306 0 6 unless my $request_json = &encode_json($request_data)
312 0 1 unless my $response_data = &decode_json($response_json)
318 10 2 unless defined $trapper_host
319 11 1 unless defined $trapper_port
320 0 12 unless (defined $trapper_host and defined $trapper_port)
327 4 8 unless my $socket = 'IO::Socket::INET'->new('PeerAddr', $trapper_host, 'PeerPort', $trapper_port, 'Proto', 'tcp', 'Timeout', 10)
339 2 4 unless $socket->write($request_json, $request_length)
340 1 3 unless $socket->read($response_json, 2048)
341 1 2 unless $socket->close
351 4 0 defined $opt ? :
365 1 3 unless -d $module_dir and -w $module_dir
369 2 1 if (-f $module_filename)
370 1 1 unless $term->ask_yn('prompt', "\n$module_filename exists.\nOverwrite?", 'default', 'n')
384 0 2 unless open my $fh, '>', $module_filename
388 0 2 unless require $module_filename