SSL connect attempt failed because of handshake problems using Net::FTPSSL - perl

I am trying to create a Perl script with Net::FTPSSL that move the files from the FTP server to actual server.
The script will run every X minutes / seconds to check if the customers uploaded something new on the FTP server and move it.
#!/usr/bin/perl -w
use strict;
use warnings;
use DateTime;
use Net::FTPSSL;
my $ftp;
sub connect_ftp {
$ftp = Net::FTPSSL->new('sftp.domain.com',
Encryption => EXP_CRYPT,
Debug => 1, DebugLogFile => "/usr/logs/ftpssl.log");
$ftp->login('username', 'password');
$ftp->binary();
}
sub copy_files {
my #folder_list;
my $folder;
#folder_list = $ftp->nlst();
foreach $folder (#folder_list) {
if ($folder ne "globa_username") {
$ftp->cwd($folder);
my #file_list;
my $video;
#file_list = $ftp->nlst();
foreach $video (#file_list) {
my $file_status;
my $result;
if ($video =~ /\.mp4$/i) {
if (!file_exist($video, $folder)) {
$file_status = $ftp->is_file($video);
if ($file_status > 0) {
$result = $ftp->get($video, "/usr/media/$folder/$video");
if (defined $result) {
#$ftp->delete($video);
}
}
}
}
}
}
$ftp->cdup();
}
#$ftp->quit();
}
sub file_exist {
my ($video, $folder) = #_;
return -f "/usr/media/$folder/$video";
}
connect_ftp();
for (;;) {
copy_files();
#sleep 60;
#sleep 30;
}
The script works fine until returns: **555 TLSv12: SSL connect attempt failed because of handshake problems**.
Net-FTPSSL Version: 0.42
IO-Socket-SSL Version: 1.94
Net-SSLeay Version: 1.55
IO-Socket-INET Version: 1.33
IO-Socket-INET6 might not be installed.
IO-Socket-IP Version: 0.21
IO Version: 1.25_06
Socket Version: 2.030
No IPv6 support available. You must 1st upgrade IO::Socket::SSL to support it!
Perl: 5.016003 [5.16.3], OS: linux
***** IPv6 not yet supported in Net::FTPSSL! *****
Server (port): sftp.domain.com (21)
Keys: (Debug), (Encryption), (DebugLogFile)
Values: (1), (E), (/usr/logs/ftpssl.log)
SKT <<< 220 (vsFTPd 3.0.2)
SKT >>> AUTH TLS
SKT <<< 234 Proceed with negotiation.
Object HASH Details ... (SSL:arguments - E)
SSL_hostname ==> sftp.domain.com
SSL_verify_mode ==> 0
SSL_version ==> TLSv12
Timeout ==> 120
Object Net::FTPSSL Details ... (sftp.domain.com:21 - E)
_FTPSSL_arguments ==> HASH(0x272cee8)
-- Croak ===> (undef)
-- Crypt ===> E
-- FixGetTs ===> 0
-- FixPutTs ===> 0
-- Host ===> sftp.domain.com
-- Pret ===> 0
-- Timeout ===> 120
-- buf_size ===> 10240
-- data_prot ===> P
-- dcsc_mode ===> 1
-- debug ===> 2
-- debug_extra ===> 0
-- debug_no_help ===> 0
-- ftpssl_filehandle ===> GLOB(0x2a6d8c8)
-- last_ftp_msg ===> 234 Proceed with negotiation.
-- myContext ===> HASH(0x2747d18)
-- SSL_ca_file ----> /etc/pki/tls/certs/ca-bundle.crt
-- SSL_reuse_ctx ----> IO::Socket::SSL::SSL_Context=HASH(0x2a8f1f0)
-- context ++++> 44543648
-- mySocketOpts ===> HASH(0x2746ec0)
-- PeerAddr ----> sftp.domain.com
-- PeerPort ----> 21
-- Proto ----> tcp
-- Timeout ----> 120
-- start_SSL_opts ===> HASH(0x272c840)
-- SSL_hostname ----> sftp.domain.com
-- SSL_verify_mode ----> 0
-- SSL_version ----> TLSv12
-- Timeout ----> 120
-- trace ===> 0
-- type ===> A
_SSL_arguments ==> HASH(0x2a8e770)
-- PeerAddr ===> 33.44.55.66
-- PeerPort ===> 21
-- Proto ===> tcp
-- SSL_ca_file ===> /etc/pki/tls/certs/ca-bundle.crt
-- SSL_cert_file ===> certs/client-cert.pem
-- SSL_check_crl ===> 0
-- SSL_honor_cipher_order ===> 0
-- SSL_hostname ===> sftp.domain.com
-- SSL_key_file ===> certs/client-key.pem
-- SSL_server ===> 0
-- SSL_use_cert ===> 0
-- SSL_verify_mode ===> 0
-- SSL_version ===> TLSv12
_SSL_ctx ==> IO::Socket::SSL::SSL_Context=HASH(0x2a8f1f0)
-- context ===> 44543648
_SSL_fileno ==> 4
_SSL_ioclass_upgraded ==> IO::Socket::INET
_SSL_last_err ==> SSL wants a read first
_SSL_object ==> 44657040
_SSL_opened ==> 1
io_socket_domain ==> 2
io_socket_proto ==> 6
io_socket_timeout ==> 120
io_socket_type ==> 1
************************************************************
>>> USER +++++++
<<< 331 Please specify the password.
>>> PASS *******
<<< 230 Login successful.
>>> HELP
<<< 214-The following commands are recognized.
<<< ABOR ACCT ALLO APPE CDUP CWD DELE EPRT EPSV FEAT HELP LIST MDTM MKD
<<< MODE NLST NOOP OPTS PASS PASV PORT PWD QUIT REIN REST RETR RMD RNFR
<<< RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD
<<< XPWD XRMD
<<< 214 Help OK.
>>> FEAT
<<< 211-Features:
<<< AUTH SSL
<<< AUTH TLS
<<< EPRT
<<< EPSV
<<< MDTM
<<< PASV
<<< PBSZ
<<< PROT
<<< REST STREAM
<<< SIZE
<<< TVFS
<<< UTF8
<<< 211 End
<<+ 111 Auto-adding OPTS Command!
>>> HELP SITE
<<< 214-The following commands are recognized.
<<< ABOR ACCT ALLO APPE CDUP CWD DELE EPRT EPSV FEAT HELP LIST MDTM MKD
<<< MODE NLST NOOP OPTS PASS PASV PORT PWD QUIT REIN REST RETR RMD RNFR
<<< RNTO SITE SIZE SMNT STAT STOR STOU STRU SYST TYPE USER XCUP XCWD XMKD
<<< XPWD XRMD
<<< 214 Help OK.
>>> SITE HELP
<<< 214 CHMOD UMASK HELP
<<+ 214 The HELP command is supported.
>>> TYPE I
<<< 200 Switching to Binary mode.
<<< 200 Switching to Binary mode.
>>> PBSZ 0
<<< 200 PBSZ set to 0.
>>> PROT P
<<< 200 PROT now Private.
>>> PASV
<<< 227 Entering Passive Mode (33,44,55,66,20,207).
--- Host (33.44.55.66) Port (5327)
>>> NLST
<<< 150 Here comes the directory listing.
<<< 226 Directory send OK.
>>> CWD demo3
<<< 250 Directory successfully changed.
>>> PBSZ 0
<<< 200 PBSZ set to 0.
>>> PROT P
<<< 200 PROT now Private.
>>> PASV
<<< 227 Entering Passive Mode (33,44,55,66,20,144).
--- Host (33.44.55.66) Port (5264)
>>> NLST
<<< 150 Here comes the directory listing.
<<< 226 Directory send OK.
>>> CDUP
<<< 250 Directory successfully changed.
>>> CDUP
<<< 250 Directory successfully changed.
>>> CWD demo2
<<< 250 Directory successfully changed.
>>> PBSZ 0
<<< 200 PBSZ set to 0.
>>> PROT P
<<< 200 PROT now Private.
>>> PASV
<<< 227 Entering Passive Mode (33,44,55,66,20,179).
--- Host (33.44.55.66) Port (5299)
>>> NLST
<<< 150 Here comes the directory listing.
<<< 226 Directory send OK.
>>> CDUP
<<< 250 Directory successfully changed.
>>> CWD demo
<<< 250 Directory successfully changed.
>>> PBSZ 0
<<< 200 PBSZ set to 0.
>>> PROT P
<<< 200 PROT now Private.
>>> PASV
...
<<< 227 Entering Passive Mode (33,44,55,66,19,196).
--- Host (33.44.55.66) Port (5060)
>>> NLST
<<< 150 Here comes the directory listing.
<<+ 555 TLSv12: SSL connect attempt failed because of handshake problems
>>> PBSZ 0
<<+ 555 Unexpected EOF on Command Channel [0] (0, 1) ()
>>> PROT P
<<+ 555 Can't write command on socket:
UPDATE:
Tried downgrading SSL_version to SSLv3 but it still doesn't work.
$ftp = Net::FTPSSL->new('sftp.domain.com',
Encryption => EXP_CRYPT,
Debug => 1, DebugLogFile => "/usr/logs/ftpssl.log", SSL_version => "SSLv3");
Net::FTP
I created another script using Net::FTP it's works fine until:
Net::FTP>>> Net::FTP(3.11)
Net::FTP>>> Exporter(5.68)
Net::FTP>>> Net::Cmd(3.11)
Net::FTP>>> IO::Socket::SSL(2.072)
Net::FTP>>> IO::Socket::INET(1.33)
Net::FTP>>> IO::Socket(1.34)
Net::FTP>>> IO::Handle(1.33)
Net::FTP=GLOB(0x11d7400)<<< 220 (vsFTPd 3.0.2)
Net::FTP=GLOB(0x11d7400)>>> AUTH TLS
Net::FTP=GLOB(0x11d7400)<<< 234 Proceed with negotiation.
Net::FTP=GLOB(0x11d7400)>>> PBSZ 0
Net::FTP=GLOB(0x11d7400)<<< 200 PBSZ set to 0.
Net::FTP=GLOB(0x11d7400)>>> PROT P
Net::FTP=GLOB(0x11d7400)<<< 200 PROT now Private.
Net::FTP=GLOB(0x11d7400)>>> USER username
Net::FTP=GLOB(0x11d7400)<<< 331 Please specify the password.
Net::FTP=GLOB(0x11d7400)>>> PASS ....
Net::FTP=GLOB(0x11d7400)<<< 230 Login successful.
Net::FTP=GLOB(0x11d7400)>>> TYPE I
Net::FTP=GLOB(0x11d7400)<<< 200 Switching to Binary mode.
Net::FTP=GLOB(0x11d7400)>>> PASV
Net::FTP=GLOB(0x11d7400)<<< 227 Entering Passive Mode (33,44,55,66,21,107).
Net::FTP=GLOB(0x11d7400)>>> NLST
Net::FTP=GLOB(0x11d7400)<<< 150 Here comes the directory listing.
Net::FTP=GLOB(0x11d7400)<<< 226 Directory send OK.
Net::FTP=GLOB(0x11d7400)>>> CWD demo
Net::FTP=GLOB(0x11d7400)<<< 250 Directory successfully changed.
Net::FTP=GLOB(0x11d7400)>>> PASV
...
Net::FTP=GLOB(0x13e2400)<<< 150 Here comes the directory listing.
Net::FTP=GLOB(0x13e2400)<<< 226 Directory send OK.
Net::FTP=GLOB(0x13e2400)>>> CWD demo3
Net::FTP=GLOB(0x13e2400)<<< 250 Directory successfully changed.
Net::FTP=GLOB(0x13e2400)>>> PASV
Net::FTP=GLOB(0x13e2400)<<< 227 Entering Passive Mode (33,44,55,66,19,196).
Net::FTP=GLOB(0x13e2400)>>> NLST
failed to ssl upgrade dataconn: SSL wants a read first at ./upload_ftp.pl line 40.
Net::FTP=GLOB(0x13e2400)<<< 150 Here comes the directory listing.
Net::FTP=GLOB(0x13e2400)>>> CDUP
Net::FTP: Net::Cmd::getline(): unexpected EOF on command channel: at ./upload_ftp.pl line 56.
Net::FTP: Net::Cmd::_is_closed(): unexpected EOF on command channel: at ./upload_ftp.pl line 56.

Related

Why some entries are missing in Perl ENV hash

Perl is giving me an undef value when I access a variable that is supposed to be defined in the %ENV hash. How is this possible?
root#23cd5f45def7:~/bin$ perl -e 'warn $ENV{SHELL}'
Warning: something's wrong at -e line 1.
I would expect perl to output /bin/bash instead.
More info on the environment:
root#23cd5f45def7:~/bin$ echo $SHELL
/bin/bash
root#23cd5f45def7:~/bin$ $SHELL --version
GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
...
root#23cd5f45def7:~/bin$ perl -v
This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
(with 91 registered patches, see perl -V for more detail)
...
I am running this on Debian wheezy in a docker container.
The image was created with
sudo debootstrap wheezy ../_build http://ftp.us.debian.org/debian
sudo tar -C ../_build -c . | docker import - wheezy/bootstrap
I get the same beheviour with perl-5.24.1 compiled manually from sources.
The error message
Warning: something's wrong at -e line 1.
indicates that the environment variable $SHELL does not exist or is not exported.
You can list the exported variables using the export command. You can add SHELL to the exported variables using the command:
export SHELL
Something is wrong with your installation. It looks like the string
Warning: something's wrong at -e line 1.
would only ever be produced by the following code on line 461 in pp_sys.c (that is, when the argument to warn is undefined). Therefore, I am going to deduce that something sanitizes the environment before perl is invoked. You might also want to examine root's .profile, .bashrc, .bash_profile and other possibly relevant configuration files.
421 PP(pp_warn)
422 {
423 dSP; dMARK;
424 SV *exsv;
425 STRLEN len;
426 if (SP - MARK > 1) {
427 dTARGET;
428 do_join(TARG, &PL_sv_no, MARK, SP);
429 exsv = TARG;
430 SP = MARK + 1;
431 }
432 else if (SP == MARK) {
433 exsv = &PL_sv_no;
434 EXTEND(SP, 1);
435 SP = MARK + 1;
436 }
437 else {
438 exsv = TOPs;
439 if (SvGMAGICAL(exsv)) exsv = sv_mortalcopy(exsv);
440 }
441
442 if (SvROK(exsv) || (SvPV_const(exsv, len), len)) {
443 /* well-formed exception supplied */
444 }
445 else {
446 SV * const errsv = ERRSV;
447 SvGETMAGIC(errsv);
448 if (SvROK(errsv)) {
449 if (SvGMAGICAL(errsv)) {
450 exsv = sv_newmortal();
451 sv_setsv_nomg(exsv, errsv);
452 }
453 else exsv = errsv;
454 }
455 else if (SvPOKp(errsv) ? SvCUR(errsv) : SvNIOKp(errsv)) {
456 exsv = sv_newmortal();
457 sv_setsv_nomg(exsv, errsv);
458 sv_catpvs(exsv, "\t...caught");
459 }
460 else {
461 exsv = newSVpvs_flags("Warning: something's wrong", SVs_TEMP); ## <-- Here ...
462 }
463 }
464 if (SvROK(exsv) && !PL_warnhook)
465 Perl_warn(aTHX_ "%" SVf, SVfARG(exsv));
466 else warn_sv(exsv);
467 RETSETYES;
468 }

Perl - Issue installing or connecting to queue manager from MQSeries - 1.34 (Reason = 2059)

I tried to install MQSeries 1.34 from CPAN, and I was getting an error, which I found a fix for on the CPAN bug tracking website. So I applied the fix and still got a few test errors, but the build seemed okay. Installing it with a force install MQSeries worked. Once I had installed it, I can construct objects and reference the libraries in my other perl scripts, but when I try to connect to the queue manager or queue, I get an error back.
Any advice on what is wrong with the setup or how to fix this and get my connection back up and running would be much appreciated.
Here are specifics about my configuration:
$ uname -srvpio
Linux 2.6.32-573.22.1.el6.x86_64 #1 SMP Thu Mar 17 03:23:39 EDT 2016 x86_64 x86_64 GNU/Linux
$ /opt/mqm/bin/dspmqsver
Name: WebSphere MQ Advanced Message Security
Version: 7.5.0.0
Level: p000-L120604
BuildType: IKAP - (Production)
$ rpm -qa |grep 'MQ' |sort
MQSeriesAMS-7.5.0-0.x86_64
MQSeriesClient-7.5.0-0.x86_64
MQSeriesExplorer-7.5.0-0.x86_64
MQSeriesFTAgent-7.5.0-0.x86_64
MQSeriesFTBase-7.5.0-0.x86_64
MQSeriesFTLogger-7.5.0-0.x86_64
MQSeriesFTService-7.5.0-0.x86_64
MQSeriesFTTools-7.5.0-0.x86_64
MQSeriesGSKit-7.5.0-0.x86_64
MQSeriesJava-7.5.0-0.x86_64
MQSeriesJRE-7.5.0-0.x86_64
MQSeriesMan-7.5.0-0.x86_64
MQSeriesMsg_cs-7.5.0-0.x86_64
MQSeriesMsg_de-7.5.0-0.x86_64
MQSeriesMsg_es-7.5.0-0.x86_64
MQSeriesMsg_fr-7.5.0-0.x86_64
MQSeriesMsg_hu-7.5.0-0.x86_64
MQSeriesMsg_it-7.5.0-0.x86_64
MQSeriesMsg_ja-7.5.0-0.x86_64
MQSeriesMsg_ko-7.5.0-0.x86_64
MQSeriesMsg_pl-7.5.0-0.x86_64
MQSeriesMsg_pt-7.5.0-0.x86_64
MQSeriesMsg_ru-7.5.0-0.x86_64
MQSeriesMsg_Zh_CN-7.5.0-0.x86_64
MQSeriesMsg_Zh_TW-7.5.0-0.x86_64
MQSeriesRuntime-7.5.0-0.x86_64
MQSeriesSamples-7.5.0-0.x86_64
MQSeriesSDK-7.5.0-0.x86_64
MQSeriesServer-7.5.0-0.x86_64
MQSeriesXRClients-7.5.0-0.x86_64
MQSeriesXRService-7.5.0-0.x86_64
$ ./dispModVersion.pl MQSeries
Module Installed CPAN
MQSeries 1.34 1.34
$ perl -v
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
$ perl -V
Summary of my perl5 (revision 5 version 22 subversion 1) configuration:
Platform:
osname=linux, osvers=2.6.32-573.22.1.el6.x86_64, archname=x86_64-linux
uname='linux ******* 2.6.32-573.22.1.el6.x86_64 #1 smp thu mar 17 03:23:39 edt 2016 x86_64 x86_64 x86_64 gnulinux '
config_args='-des -Dprefix=******'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
optimize='-O2',
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.4.7 20120313 (Red Hat 4.4.7-16)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /lib/../lib64 /usr/lib/../lib64 /lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.12'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO
USE_PERL_ATOF
Built under linux
Compiled at Apr 18 2016 15:46:59
%ENV:
PERL5BIN="*******/bin"
PERL5HOME="*******"
PERL5SITE="*******/lib/site_perl/5.22.1"
#INC:
*******/lib/site_perl/5.22.1/x86_64-linux
*******/lib/site_perl/5.22.1
*******/lib/5.22.1/x86_64-linux
*******/lib/5.22.1
When I first tried to install MQSeries, I got the following error:
t/99-pod.t .. 2/63
# Failed test 'POD test for MQSeries/Message/IIH.pm'
# at Test/Pod.pm line 187.
# MQSeries/Message/IIH.pm (415): Non-ASCII character seen before =encoding in 'Villag▒mez'. Assuming CP1252
# Looks like you failed 1 test of 63.
t/99-pod.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/63 subtests
Test Summary Report
-------------------
t/99-pod.t (Wstat: 256 Tests: 63 Failed: 1)
Failed test: 61
Non-zero exit status: 1
Files=1, Tests=63, 1 wallclock secs ( 0.02 usr 0.01 sys + 0.34 cusr 0.00 csys = 0.37 CPU)
Result: FAIL
Failed 1/1 test programs. 1/63 subtests failed.
Then, I modified the file MQSeries/Message/IIH.pm to add =encoding ISO-8859-1 at the start of the file, per bug report on CPAN, I ran the install again and got the following:
t/99-pod.t .. ok
All tests successful.
Files=1, Tests=63, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.34 cusr 0.01 csys = 0.39 CPU)
Result: PASS
make[1]: Entering directory `build/MQSeries-1.34-SLJq6K/MQClient'
PERL_DL_NONLAZY=1 "perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, '../blib/lib', '../blib/arch')" t/*.t
t/10constants.t ........... ok
t/20convert.t ............. Failed 5/6 subtests
t/30basic.t ............... ok
t/31properties.t .......... ok
t/32async_put.t ........... ok
t/40oo-qmgr.t ............. 3/14 MQCONN failed (Reason = 2059) (Queue manager not available for connection.) at t/40oo-qmgr.t line 38.
# Failed test 'MQSeries::QueueManager - constructor'
# at t/40oo-qmgr.t line 39.
t/40oo-qmgr.t ............. 5/14 MQCONN failed (Reason = 2059) (Queue manager not available for connection.) at t/40oo-qmgr.t line 52.
# Failed test 'MQSeries::QueueManager - Connect'
# at t/40oo-qmgr.t line 58.
t/40oo-qmgr.t ............. 7/14 MQCONN failed (Reason = 2059) (Queue manager not available for connection.) at t/40oo-qmgr.t line 73.
# Failed test 'MQSeries::QueueManager - constructor'
# at t/40oo-qmgr.t line 74.
Can't call method "Open" on an undefined value at t/40oo-qmgr.t line 77.
# Looks like you planned 14 tests but ran 7.
# Looks like you failed 3 tests of 7 run.
# Looks like your test exited with 13 just after 7.
t/40oo-qmgr.t ............. Dubious, test returned 13 (wstat 3328, 0xd00)
Failed 10/14 subtests
t/50oo-command.t .......... ok
t/51oo-command-changes.t .. ok
t/52oo-command-filter.t ... ok
t/60-logs.t ............... ok
t/70-config.t ............. ok
Test Summary Report
-------------------
t/20convert.t (Wstat: 0 Tests: 2 Failed: 1)
Failed test: 2
Parse errors: Bad plan. You planned 6 tests but ran 2.
t/40oo-qmgr.t (Wstat: 3328 Tests: 7 Failed: 3)
Failed tests: 3, 5, 7
Non-zero exit status: 13
Parse errors: Bad plan. You planned 14 tests but ran 7.
Files=11, Tests=5334, 1264 wallclock secs ( 0.96 usr 0.02 sys + 1.56 cusr 0.18 csys = 2.72 CPU)
Result: FAIL
Failed 2/11 test programs. 4/5334 subtests failed.
If I force the install, I can get it to finish the install after everything is said and done, but then I get the following error when trying to connect:
MQCONN failed (Reason = 2059) (Queue manager not available for connection.) at testMQConnectivity.pl line 16.
MQCONN failed (Reason = 2059) (Queue manager not available for connection.) at testMQConnectivity.pl line 16.
at MQSeries/QueueManager.pm line 809.
MQSeries::QueueManager::Connect(MQSeries::QueueManager=HASH(0x24a7180)) called at MQSeries/QueueManager.pm line 155
MQSeries::QueueManager::new(undef, "QueueManager", "*******", "Reason", SCALAR(0x151d4f0), "CompCode", SCALAR(0x151d610), "ClientConn", ...) called at testMQConnectivity.pl line 16
I edited the CONFIG file after pulling the data from CPAN to reference my remote MQ Queues that I can connect to using /opt/mqm/samp/bin/amqsputc or /opt/mqm/samp/bin/amqsgetc, after setting export MQSERVER=..., if I run make test TEST_VERBOSE=1 from the working CPAN directory, I see the following output:
t/20convert.t:
t/20convert.t .............
1..6
ok 1
ok 2
ok 3
ok 4
MQGET failed: CompCode => 2, Reason => 2033
not ok 5
Message conversion failed.
Should be: 'This msg is in EBCDIC'
Is: ''
not ok 6
Failed 2/6 subtests
t/31properties.t:
t/31properties.t ..........
1..22
ok 1 - use MQClient::MQSeries;
Connecting to queue manager '*******' (MQCONN)
ok 2 - MQCONN
Opening queue manager for inquire
ok 3 - MQOPEN - queue manager
Querying queue manager attributes (MQINQ)
ok 4 - MQINQ
Closing queue manager object handle (MQCLOSE)
ok 5 - MQCLOSE - queue manager
Create message handle object (MQCRTMH)
ok 6 - MQCRTMH
Set message property (MQSETMP - string)
ok 7 - MQSETMP - string
Set message property (MQSETMP - float)
ok 8 - MQSETMP - float
Set message property (MQSETMP - int)
ok 9 - MQSETMP - int
Inquire message property (MQINQMP - float)
ok 10 - MQINQMP - float
ok 11 - MQINQMP - float value okay (3.14164996147156)
Delete float property
ok 12 - MQDLTMP - float
Opening queue '*******' (MQOPEN)
ok 13 - MQOPEN - queue
Putting message with properties (MQPUT)
ok 14 - MQPUT
Create message handle object (MQCRTMH #2)
ok 15 - MQCRTMH \#2
Getting message (MQGET)
not ok 16 - MQGET
# Failed test 'MQGET'
# at t/31properties.t line 146.
Inquire message property (MQINQMP - int)
not ok 17 - MQINQMP - int
# Failed test 'MQINQMP - int'
# at t/31properties.t line 156.
Use of uninitialized value $prop in concatenation (.) or string at t/31properties.t line 157.
not ok 18 - MQINQMP - int value okay ()
# Failed test 'MQINQMP - int value okay ()'
# at t/31properties.t line 157.
# got: undef
# expected: '42'
Delete message handle (MQDLTMH)
ok 19 - MQDLTMH
Delete message handle (MQDLTMH #2)
ok 20 - MQDLTMH \#2
Closing queue (MQCLOSE)
ok 21 - MQCLOSE
Disconnecting (MQDISC)
ok 22 - MQDISC
# Looks like you failed 3 tests of 22.
Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/22 subtests
t/32async_put.t:
t/32async_put.t ...........
1..25
ok 1 - use MQClient::MQSeries;
Connecting to queue manager '*******' (MQCONN)
ok 2 - MQCONN
Opening queue manager for inquire
ok 3 - MQOPEN - queue manager
Querying queue manager attributes (MQINQ)
MQINQ returned: CompCode => 0, Reason => 0
ok 4 - MQINQ
Closing queue manager object handle (MQCLOSE)
ok 5 - MQCLOSE - queue manager
Opening queue '*******' (MQOPEN)
ok 6 - MQOPEN - queue
Putting message #1 (async MQPUT)
ok 7 - MQPUT - 1
Putting message #2 (async MQPUT)
ok 8 - MQPUT - 2
Putting message #3 (async MQPUT)
ok 9 - MQPUT - 3
Putting message #4 (async MQPUT)
ok 10 - MQPUT - 4
Putting message #5 (async MQPUT)
ok 11 - MQPUT - 5
Getting status info (MQSTAT)
ok 12 - MQSTAT
not ok 13 - MQSTAT result
# Failed test 'MQSTAT result'
# at t/32async_put.t line 120.
# Structures begin differing at:
# $got->{PutSuccessCount} = '5'
# $expected->{PutSuccessCount} = '0'
Getting message #1 (MQGET)
ok 14 - MQGET - 1
ok 15 - MQGET message content - 1
Getting message #2 (MQGET)
ok 16 - MQGET - 2
ok 17 - MQGET message content - 2
Getting message #3 (MQGET)
ok 18 - MQGET - 3
ok 19 - MQGET message content - 3
Getting message #4 (MQGET)
ok 20 - MQGET - 4
ok 21 - MQGET message content - 4
Getting message #5 (MQGET)
ok 22 - MQGET - 5
ok 23 - MQGET message content - 5
Closing queue (MQCLOSE)
ok 24 - MQCLOSE
Disconnecting (MQDISC)
ok 25 - MQDISC
# Looks like you failed 1 test of 25.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/25 subtests
And t/40oo-qmgr.t, which was previously failing now executes successfully:
t/40oo-qmgr.t:
t/40oo-qmgr.t .............
1..14
ok 1 - use MQClient::MQSeries;
ok 2 - use MQSeries::QueueManager;
ok 3 - MQSeries::QueueManager - constructor
ok 4 - MQSeries::QueueManager - constructor - AutoConnect=0
ok 5 - MQSeries::QueueManager - Connect
ok 6 - MQSeries::QueueManager - Disconnect
ok 7 - MQSeries::QueueManager - constructor
ok 8 - MQSeries::QueueManager - Open
ok 9 - MQSeries::QueueManager - Inquire
ok 10 - MQSeries::QueueManager - Inquire - Platform
ok 11 - MQSeries::QueueManager - Inquire - CodedCharSetId
ok 12 - MQSeries::QueueManager - Inquire - CommandLevel
ok 13 - MQSeries::QueueManager - Inquire - DeadLetterQName
ok 14 - MQSeries::QueueManager - Close
ok
Yielding the final results:
Test Summary Report
-------------------
t/20convert.t (Wstat: 0 Tests: 6 Failed: 2)
Failed tests: 5-6
t/31properties.t (Wstat: 768 Tests: 22 Failed: 3)
Failed tests: 16-18
Non-zero exit status: 3
t/32async_put.t (Wstat: 256 Tests: 25 Failed: 1)
Failed test: 13
Non-zero exit status: 1
Files=11, Tests=5345, 183 wallclock secs ( 1.02 usr 0.08 sys + 1.48 cusr 0.18 csys = 2.76 CPU)
Result: FAIL
Failed 3/11 test programs. 6/5345 subtests failed.
Any ideas on how to get this resolved and get the package up and running?
If I run /opt/mqm/samp/bin/amqsputc or /opt/mqm/samp/bin/amqsgetc, I can connect to the same host, port, channel, queue manager, and queue from this host.
Thanks!

date is error when run zabbix_bind.9.6_stats.pl on Solaris

analyse named.stats file On Solaris 10, SunOS azalea 5.10 Generic_150400-13 sun4u sparc SUNW,Sun-Fire-V490
perl version: v5.8.4 built for sun4-solaris-64int
BIND 9.9.5-P1, this dns has view zone!
When I ran zabbix_bind.9.6_stats.pl script, the date in the first line of the result file zabbix_named.stats.txt is wrong.
Input file: named.stats
+++ Statistics Dump +++ (1411256097)
++ Incoming Requests ++
245677755 QUERY
11 IQUERY
131 NOTIFY
5 UPDATE
++ Incoming Queries ++
7 RESERVED0
214646337 A
195659 NS
194834 CNAME
67573 SOA
11863353 PTR
13 HINFO
311508 MX
80961 TXT
17684359 AAAA
313197 SRV
35 NAPTR
1026 A6
377 DS
2 NSEC
16 DNSKEY
2658 SPF
6 AXFR
317449 ANY
14 Others
++ Outgoing Queries ++
[View: GLU]
97641561 A
913138 NS
1668 CNAME
3496 SOA
584400 PTR
215941 MX
222061 TXT
8968008 AAAA
10839 SRV
74 DS
1 DNSKEY
11600 ANY
[View: Other]
[View: _bind]
++ Name Server Statistics ++
245679139 IPv4 requests received
6939549 requests with EDNS(0) received
29010 requests with TSIG received
56072 TCP requests received
1735225 auth queries rejected
50400546 recursive queries rejected
6 transfer requests rejected
231559258 responses sent
39867 truncated responses sent
6886241 responses with EDNS(0) sent
28879 responses with TSIG sent
134630025 queries resulted in successful answer
7564120 queries resulted in authoritative answer
145275533 queries resulted in non authoritative answer
33203 queries resulted in referral answer
8608506 queries resulted in nxrrset
26580073 queries resulted in SERVFAIL
9569385 queries resulted in NXDOMAIN
86774948 queries caused recursion
12879202 duplicate queries received
1239821 queries dropped
52135771 other query failures
++ Zone Maintenance Statistics ++
130 IPv4 notifies received
4114 IPv4 SOA queries sent
20 IPv4 AXFR requested
10 IPv4 IXFR requested
30 transfer requests succeeded
++ Resolver Statistics ++
[Common]
223764 mismatch responses received
[View: GLU]
108570571 IPv4 queries sent
76450226 IPv4 responses received
519727 NXDOMAIN received
150555 SERVFAIL received
50543 FORMERR received
394845 other errors received
64245 EDNS(0) query failures
6679270 truncated responses received
77150 lame delegations received
39157947 query retries
32176451 query timeouts
2446839 IPv4 NS address fetches
131398 IPv4 NS address fetch failed
10663 queries with RTT < 10ms
55311397 queries with RTT 10-100ms
17022288 queries with RTT 100-500ms
3465431 queries with RTT 500-800ms
455258 queries with RTT 800-1600ms
12639 queries with RTT > 1600ms
[View: Other]
[View: _bind]
++ Cache DB RRsets ++
[View: GLU (Cache: GLU)]
20848 A
28539 NS
4810 CNAME
4 SOA
140 PTR
4 MX
18 TXT
1523 AAAA
1 SRV
167 DS
774 RRSIG
423 NSEC
1 DNSKEY
20 !A
5 !TXT
314 !AAAA
237 NXDOMAIN
[View: Other (Cache: Other)]
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
101917427 UDP/IPv4 sockets opened
6679398 TCP/IPv4 sockets opened
101934142 UDP/IPv4 sockets closed
6736965 TCP/IPv4 sockets closed
32659 UDP/IPv4 socket bind failures
1614 TCP/IPv4 socket connect failures
101889277 UDP/IPv4 connections established
6417057 TCP/IPv4 connections established
622 TCP/IPv4 connection accept failures
57536 TCP/IPv4 connections accepted
5 TCP/IPv4 send errors
173008 UDP/IPv4 recv errors
37707 TCP/IPv4 recv errors
++ Per Zone Query Statistics ++
[0.0.127.in-addr.arpa (view: GLU)]
27 queries resulted in successful answer
164 queries resulted in authoritative answer
137 queries resulted in NXDOMAIN
[160.192.222.in-addr.arpa (view: GLU)]
141 queries resulted in successful answer
792 queries resulted in authoritative answer
651 queries resulted in NXDOMAIN
[0.0.127.in-addr.arpa (view: Other)]
[160.192.222.in-addr.arpa (view: Other)]
92115 queries resulted in successful answer
106915 queries resulted in authoritative answer
123 queries resulted in nxrrset
14677 queries resulted in NXDOMAIN
[glu.edu.cn (view: Other)]
5 transfer requests rejected
1764308 queries resulted in successful answer
2849091 queries resulted in authoritative answer
574347 queries resulted in nxrrset
510456 queries resulted in NXDOMAIN
[version.bind (view: _bind)]
264 queries resulted in successful answer
264 queries resulted in authoritative answer
[hostname.bind (view: _bind)]
3 queries resulted in successful answer
3 queries resulted in authoritative answer
[authors.bind (view: _bind)]
[id.server (view: _bind)]
--- Statistics Dump --- (1411256097)
+++ Statistics Dump +++ (1411256113)
++ Incoming Requests ++
245678141 QUERY
11 IQUERY
131 NOTIFY
5 UPDATE
++ Incoming Queries ++
7 RESERVED0
214646692 A
195659 NS
194834 CNAME
67578 SOA
11863360 PTR
13 HINFO
311512 MX
80961 TXT
17684371 AAAA
313199 SRV
35 NAPTR
1026 A6
377 DS
2 NSEC
16 DNSKEY
2658 SPF
6 AXFR
317450 ANY
14 Others
++ Outgoing Queries ++
[View: GLU]
97641832 A
913147 NS
1668 CNAME
3496 SOA
584400 PTR
215944 MX
222061 TXT
8968013 AAAA
10839 SRV
74 DS
1 DNSKEY
11600 ANY
[View: Other]
[View: _bind]
++ Name Server Statistics ++
245679525 IPv4 requests received
6939573 requests with EDNS(0) received
29010 requests with TSIG received
56072 TCP requests received
1735231 auth queries rejected
50400606 recursive queries rejected
6 transfer requests rejected
231559636 responses sent
39867 truncated responses sent
6886265 responses with EDNS(0) sent
28879 responses with TSIG sent
134630301 queries resulted in successful answer
7564152 queries resulted in authoritative answer
145275810 queries resulted in non authoritative answer
33203 queries resulted in referral answer
8608514 queries resulted in nxrrset
26580076 queries resulted in SERVFAIL
9569410 queries resulted in NXDOMAIN
86775072 queries caused recursion
12879204 duplicate queries received
1239821 queries dropped
52135837 other query failures
++ Zone Maintenance Statistics ++
130 IPv4 notifies received
4114 IPv4 SOA queries sent
20 IPv4 AXFR requested
10 IPv4 IXFR requested
30 transfer requests succeeded
++ Resolver Statistics ++
[Common]
223769 mismatch responses received
[View: GLU]
108570859 IPv4 queries sent
76450431 IPv4 responses received
519730 NXDOMAIN received
150555 SERVFAIL received
50543 FORMERR received
394845 other errors received
64245 EDNS(0) query failures
6679285 truncated responses received
77150 lame delegations received
39158038 query retries
32176528 query timeouts
2446848 IPv4 NS address fetches
131398 IPv4 NS address fetch failed
10663 queries with RTT < 10ms
55311569 queries with RTT 10-100ms
17022314 queries with RTT 100-500ms
3465436 queries with RTT 500-800ms
455260 queries with RTT 800-1600ms
12639 queries with RTT > 1600ms
[View: Other]
[View: _bind]
++ Cache DB RRsets ++
[View: GLU (Cache: GLU)]
20863 A
28540 NS
4848 CNAME
4 SOA
140 PTR
4 MX
18 TXT
1523 AAAA
1 SRV
167 DS
774 RRSIG
423 NSEC
1 DNSKEY
20 !A
5 !TXT
307 !AAAA
240 NXDOMAIN
[View: Other (Cache: Other)]
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
101917700 UDP/IPv4 sockets opened
6679413 TCP/IPv4 sockets opened
101934409 UDP/IPv4 sockets closed
6736981 TCP/IPv4 sockets closed
32659 UDP/IPv4 socket bind failures
1614 TCP/IPv4 socket connect failures
101889550 UDP/IPv4 connections established
6417072 TCP/IPv4 connections established
622 TCP/IPv4 connection accept failures
57537 TCP/IPv4 connections accepted
5 TCP/IPv4 send errors
173008 UDP/IPv4 recv errors
37707 TCP/IPv4 recv errors
++ Per Zone Query Statistics ++
[0.0.127.in-addr.arpa (view: GLU)]
27 queries resulted in successful answer
164 queries resulted in authoritative answer
137 queries resulted in NXDOMAIN
[160.192.222.in-addr.arpa (view: GLU)]
141 queries resulted in successful answer
792 queries resulted in authoritative answer
651 queries resulted in NXDOMAIN
[glu.edu.cn (view: GLU)]
390933 queries resulted in successful answer
485439 queries resulted in authoritative answer
56638 queries resulted in nxrrset
37870 queries resulted in NXDOMAIN
[0.0.127.in-addr.arpa (view: Other)]
[160.192.222.in-addr.arpa (view: Other)]
92115 queries resulted in successful answer
106915 queries resulted in authoritative answer
123 queries resulted in nxrrset
14677 queries resulted in NXDOMAIN
[glu.edu.cn (view: Other)]
5 transfer requests rejected
1764319 queries resulted in successful answer
2849104 queries resulted in authoritative answer
574349 queries resulted in nxrrset
510456 queries resulted in NXDOMAIN
[GLU.cn (view: Other)]
1 transfer requests rejected
63626 queries resulted in successful answer
243178 queries resulted in authoritative answer
42873 queries resulted in nxrrset
136679 queries resulted in NXDOMAIN
[version.bind (view: _bind)]
264 queries resulted in successful answer
264 queries resulted in authoritative answer
[hostname.bind (view: _bind)]
3 queries resulted in successful answer
3 queries resulted in authoritative answer
[authors.bind (view: _bind)]
[id.server (view: _bind)]
--- Statistics Dump --- (1411256113)
Output file: /tmp/zabbix_named.stats.txt
date: 0 Thu Jan 1 08:00:00 1970
Per_Zone_Query_Statistics_Zone_0.0.127.in-addr.arpa__view__GLU__queries_resulted_in_NXDOMAIN: 137
Per_Zone_Query_Statistics_Zone_0.0.127.in-addr.arpa__view__GLU__queries_resulted_in_authoritative_answer: 164
Per_Zone_Query_Statistics_Zone_0.0.127.in-addr.arpa__view__GLU__queries_resulted_in_successful_answer: 27
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__CERNET__queries_resulted_in_NXDOMAIN: 32er: 423
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__GLU__queries_resulted_in_NXDOMAIN: 651
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__GLU__queries_resulted_in_authoritative_answer: 792
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__GLU__queries_resulted_in_successful_answer: 141
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__Other__queries_resulted_in_NXDOMAIN: 14678
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__Other__queries_resulted_in_authoritative_answer: 106920
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__Other__queries_resulted_in_nxrrset: 124
Per_Zone_Query_Statistics_Zone_160.192.222.in-addr.arpa__view__Other__queries_resulted_in_successful_answer: 92118
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__GLU__queries_resulted_in_NXDOMAIN: 37890
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__GLU__queries_resulted_in_authoritative_answer: 485515
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__GLU__queries_resulted_in_nxrrset: 56662
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__GLU__queries_resulted_in_successful_answer: 390965
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__Other__queries_resulted_in_NXDOMAIN: 510477
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__Other__queries_resulted_in_authoritative_answer: 2849383
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__Other__queries_resulted_in_nxrrset: 574397
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__Other__queries_resulted_in_successful_answer: 1764529
Per_Zone_Query_Statistics_Zone_glu.edu.cn__view__Other__transfer_requests_rejected: 5
Per_Zone_Query_Statistics_Zone_hostname.bind__view___bind__queries_resulted_in_authoritative_answer: 3
Per_Zone_Query_Statistics_Zone_hostname.bind__view___bind__queries_resulted_in_successful_answer: 3
Per_Zone_Query_Statistics_Zone_version.bind__view___bind__queries_resulted_in_authoritative_answer: 266
Per_Zone_Query_Statistics_Zone_version.bind__view___bind__queries_resulted_in_successful_answer: 266
zabbix_bind.9.6_stats.pl (from https://www.zabbix.com/forum/showthread.php?t=38970):
#!/usr/bin/perl
# Dmitry Maksimov 5.02.2013 dima_dm#hotmail.com
# bind 9.6.X and high statistics for Zabbix
#######
# Need!!! perl-suidperl-5.8.5-36.el4_6.3.i386.rpm or later
# Permissions on script
# chmod 4755 zabbix_bind.9.6_stats.pl
# ls -l zabbix_bind.9.6_stats.pl
# -rwsr-xr-x 1 root root 2876 Feb 5 17:40 zabbix_bind.9.6_stats.pl
# Per Zone Query Statistics via Zabbix Low Level Descovery (LLD) (bind option zone-statistics yes) which is only available in Zabbix 2.0 and high.
#### Config ######
my $rndc = '/usr/local/bind9/sbin/rndc';
my $retry = 3; # if error
my $sleep = 5; # in sec
my $data = 10000; # in bytes, size of one statictics sample
my $maxsize
= 5000000; # in bytes $stats file maximum size. If size of file more, whis file ($stats) will be cleared.
my $stats = '/var/named/named.stats';
my $stat_file = '/tmp/zabbix_named.stats.txt';
#### End Config ###
#### Error Code ####
# 1 - OK
# 2 - Error
####################
my $i;
my $date = 0;
my $flag = 0;
my $stat_name = "";
my $zone = "";
my $text = "";
my $counter = "";
my $view = "";
my $code = 1;
my %RESULT = ();
my %ZONENAME = ();
delete #ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
$ENV{'PATH'} = "/usr/local/bin:/bin:/usr/bin";
while ( $code > 0 && $i < $retry ) {
$i++;
$code = system("$rndc stats");
if ( $code > 0 ) { sleep($sleep); }
}
my $position = ( stat($stats) )[7];
if ( $position < $data ) {
$position = 0;
} else {
$position = $position - $data;
}
open( FILE, "$stats" );
seek( FILE, $position, 0 );
while (<FILE>) {
if (/^\+{3} Statistics Dump \+{3}\s+\((\d+)\)/) { $date = $1; $flag = 1; %RESULT = (); }
if (/^--- Statistics Dump ---/) { $flag = 0; }
if (/^\+{2}\s+(.*)?\s+(?=\+{2})/) {
$stat_name = $1;
$view = "";
if ( $stat_name eq "Per Zone Query Statistics" ) { $flag = 2; $zone = ""; }
}
if (/^\[View:\s+(.*)?(?=\])/) { $view = "_View_" . $1; }
if ( /^\[(.*)?(?=\])/ && $flag == 2 ) { $zone = "_Zone_" . $1; $zone =~ s#[^a-zA-Z0-9_\.\-]#_#g; }
if ( /^\s+(\d+)\s+(.*)?(?=\n)/ && $flag == 1 ) {
$text = $stat_name . $view . "_" . $2;
$counter = $1;
$text =~ s#[^a-zA-Z0-9_\.\-]#_#g;
$RESULT{$text} = $counter;
}
if ( /^\s+(\d+)\s+(.*)?(?=\n)/ && $flag == 2 ) {
$text = $stat_name . $zone . "_" . $2;
$counter = $1;
$text =~ s#[^a-zA-Z0-9_\.\-]#_#g;
$RESULT{$text} = $counter;
$ZONENAME{$zone} = 1;
}
}
close(FILE);
if ( ( stat($stats) )[7] > $maxsize ) {
open( FILE, ">$stats" );
close(FILE);
}
open( FILE, ">$stat_file" );
print FILE "date: $date ", scalar( localtime($date) ), "\n";
foreach $i ( sort( keys %RESULT ) ) {
print FILE "$i:\t$RESULT{$i}\n";
}
close(FILE);
if ( defined( $ARGV[0] ) && lc( $ARGV[0] ) eq "lld" ) {
print_lld();
} else {
if ( $code > 0 ) {
print "2\n";
} else {
print "1\n";
}
}
sub print_lld {
my $first = 1;
my $key = "";
print "{\n";
print "\t\"data\":[\n\n";
foreach $key ( keys %ZONENAME ) {
print "\t,\n" if not $first;
$first = 0;
print "\t{\n";
print "\t\t\"{#ZONENAME}\":\"$key\"\n";
print "\t}\n";
}
print "\n\t]\n";
print "}\n";
}
When I run it in Other machince, Date value is ok!
This machince: SunOS orchid 5.10 Generic_150400-13 sun4u sparc SUNW,Ultra-4
perl version: v5.8.4 built for sun4-solaris-64int
BIND 9.9.5-P1, But this dns has not view zone!
Input file: named.stats
+++ Statistics Dump +++ (1411352600)
++ Incoming Requests ++
331205 QUERY
++ Incoming Queries ++
174193 A
1045 NS
103 CNAME
760 SOA
103046 PTR
276 MX
18 TXT
41567 AAAA
49 SRV
286 A6
2 NSEC
9863 ANY
++ Outgoing Queries ++
[View: default]
190903 A
1443 NS
971 PTR
1225 AAAA
24 SRV
[View: _bind]
++ Name Server Statistics ++
331207 IPv4 requests received
177845 requests with EDNS(0) received
23 TCP requests received
38595 auth queries rejected
2468 recursive queries rejected
330359 responses sent
27 truncated responses sent
177847 responses with EDNS(0) sent
227691 queries resulted in successful answer
197399 queries resulted in authoritative answer
91628 queries resulted in non authoritative answer
41394 queries resulted in nxrrset
267 queries resulted in SERVFAIL
19942 queries resulted in NXDOMAIN
78029 queries caused recursion
851 duplicate queries received
41063 other query failures
++ Zone Maintenance Statistics ++
513 IPv4 SOA queries sent
++ Resolver Statistics ++
[Common]
[View: default]
194568 IPv4 queries sent
188556 IPv4 responses received
1113 NXDOMAIN received
91 SERVFAIL received
863 FORMERR received
30 other errors received
877 EDNS(0) query failures
274 truncated responses received
200 lame delegations received
16212 query retries
6142 query timeouts
28491 IPv4 NS address fetches
84 IPv4 NS address fetch failed
111 queries with RTT < 10ms
144059 queries with RTT 10-100ms
44047 queries with RTT 100-500ms
250 queries with RTT 500-800ms
3 queries with RTT 800-1600ms
[View: _bind]
++ Cache DB RRsets ++
[View: default]
1087 A
583 NS
191 CNAME
1 PTR
174 AAAA
21 DS
74 RRSIG
17 NSEC
1 !A
2 NXDOMAIN
[View: _bind (Cache: _bind)]
++ Socket I/O Statistics ++
194826 UDP/IPv4 sockets opened
277 TCP/IPv4 sockets opened
194826 UDP/IPv4 sockets closed
298 TCP/IPv4 sockets closed
19 UDP/IPv4 socket bind failures
194291 UDP/IPv4 connections established
48 TCP/IPv4 connections established
25 TCP/IPv4 connections accepted
87 UDP/IPv4 recv errors
++ Per Zone Query Statistics ++
--- Statistics Dump --- (1411352600)
Output file: /tmp/zabbix_named.stats.txt
date: 1411352600 Mon Sep 22 10:23:20 2014
Cache_DB_RRsets_View_default_A: 1087
Cache_DB_RRsets_View_default_AAAA: 174
Cache_DB_RRsets_View_default_CNAME: 191
Cache_DB_RRsets_View_default_DS: 21
Cache_DB_RRsets_View_default_NS: 583
Cache_DB_RRsets_View_default_NSEC: 17
Cache_DB_RRsets_View_default_NXDOMAIN: 2
Cache_DB_RRsets_View_default_PTR: 1
Cache_DB_RRsets_View_default_RRSIG: 74
Cache_DB_RRsets_View_default__A: 1
Incoming_Queries_A: 174193
Incoming_Queries_A6: 286
Incoming_Queries_AAAA: 41567
Incoming_Queries_ANY: 9863
Incoming_Queries_CNAME: 103
Incoming_Queries_MX: 276
Incoming_Queries_NS: 1045
Incoming_Queries_NSEC: 2
Incoming_Queries_PTR: 103046
Incoming_Queries_SOA: 760
Incoming_Queries_SRV: 49
Incoming_Queries_TXT: 18
Incoming_Requests_QUERY: 331205
Name_Server_Statistics_IPv4_requests_received: 331207
Name_Server_Statistics_TCP_requests_received: 23
Name_Server_Statistics_auth_queries_rejected: 38595
Name_Server_Statistics_duplicate_queries_received: 851
Name_Server_Statistics_other_query_failures: 41063
Name_Server_Statistics_queries_caused_recursion: 78029
Name_Server_Statistics_queries_resulted_in_NXDOMAIN: 19942
Name_Server_Statistics_queries_resulted_in_SERVFAIL: 267
Name_Server_Statistics_queries_resulted_in_authoritative_answer: 197399
Name_Server_Statistics_queries_resulted_in_non_authoritative_answer: 91628
Name_Server_Statistics_queries_resulted_in_nxrrset: 41394
Name_Server_Statistics_queries_resulted_in_successful_answer: 227691
Name_Server_Statistics_recursive_queries_rejected: 2468
Name_Server_Statistics_requests_with_EDNS_0__received: 177845
Name_Server_Statistics_responses_sent: 330359
Name_Server_Statistics_responses_with_EDNS_0__sent: 177847
Name_Server_Statistics_truncated_responses_sent: 27
Outgoing_Queries_View_default_A: 190903
Outgoing_Queries_View_default_AAAA: 1225
Outgoing_Queries_View_default_NS: 1443
Outgoing_Queries_View_default_PTR: 971
Outgoing_Queries_View_default_SRV: 24
Resolver_Statistics_View_default_EDNS_0__query_failures: 877
Resolver_Statistics_View_default_FORMERR_received: 863
Resolver_Statistics_View_default_IPv4_NS_address_fetch_failed: 84
Resolver_Statistics_View_default_IPv4_NS_address_fetches: 28491
Resolver_Statistics_View_default_IPv4_queries_sent: 194568
Resolver_Statistics_View_default_IPv4_responses_received: 188556
Resolver_Statistics_View_default_NXDOMAIN_received: 1113
Resolver_Statistics_View_default_SERVFAIL_received: 91
Resolver_Statistics_View_default_lame_delegations_received: 200
Resolver_Statistics_View_default_other_errors_received: 30
Resolver_Statistics_View_default_queries_with_RTT_10-100ms: 144059
Resolver_Statistics_View_default_queries_with_RTT_100-500ms: 44047
Resolver_Statistics_View_default_queries_with_RTT_500-800ms: 250
Resolver_Statistics_View_default_queries_with_RTT_800-1600ms: 3
Resolver_Statistics_View_default_queries_with_RTT___10ms: 111
Resolver_Statistics_View_default_query_retries: 16212
Resolver_Statistics_View_default_query_timeouts: 6142
Resolver_Statistics_View_default_truncated_responses_received: 274
Socket_I_O_Statistics_TCP_IPv4_connections_accepted: 25
Socket_I_O_Statistics_TCP_IPv4_connections_established: 48
Socket_I_O_Statistics_TCP_IPv4_sockets_closed: 298
Socket_I_O_Statistics_TCP_IPv4_sockets_opened: 277
Socket_I_O_Statistics_UDP_IPv4_connections_established: 194291
Socket_I_O_Statistics_UDP_IPv4_recv_errors: 87
Socket_I_O_Statistics_UDP_IPv4_socket_bind_failures: 19
Socket_I_O_Statistics_UDP_IPv4_sockets_closed: 194826
Socket_I_O_Statistics_UDP_IPv4_sockets_opened: 194826
Zone_Maintenance_Statistics_IPv4_SOA_queries_sent: 513
The date in the output file is set to 0 initially, and then gets parsed from named.stats in this line of the script:
if (/^\+{3} Statistics Dump \+{3}\s+\((\d+)\)/) { $date = $1; $flag = 1; %RESULT = (); }
The date and time are recorded in named.stats in Unix time, the number of seconds after Jan 1st 1970.
If, for some reason, that line of the stats file does not match this expression, the date will not get set, and the script will assume that the date/time is 0, i.e. that it's Jan 1st 1970.
You will need to work out why the script is not finding the date correctly. Was named.stats available when the script ran? Did the script give any errors? Has your system clock stopped working so it thinks it's Jan 1st 1970 all the time? Etc.
If you add use strict; use warnings; to the top of the script (under the first line), this will enable warnings which will make it easier to track down errors.
Author of the script answer my question in zabbix forum:
that size оf one statistics sample < $data in Byte.
my $data=10000
I set to my $data > size оf named.stats.
It works fine.
thinks!

Hung processes resume if attached to strace

I have a network program written in C using TCP sockets. Sometimes the client program hangs forever expecting input from server. Specifically, the client hangs on select() call set on an fd intended to read characters sent by server.
I am using strace to know where the process got stuck. However, sometimes when I attach the hung client process to strace, it immediately resumes it's execution and properly exits. Not all hung processes exhibit this behavior, some processes stuck in the select() even if I attach them to strace. But most of the processes resume their execution when attached to strace.
I am curious what causing the processes resume when attached to strace. It might give me clues to know why client processes are getting hung.
Any ideas? what causes a hung process to resume it's execution when attached to strace?
Update:
Here's the output of strace on hung processes.
> sudo strace -p 25645
Process 25645 attached - interrupt to quit
--- SIGSTOP (Stopped (signal)) # 0 (0) ---
--- SIGSTOP (Stopped (signal)) # 0 (0) ---
[ Process PID=25645 runs in 32 bit mode. ]
select(6, [3 5], NULL, NULL, NULL) = 2 (in [3 5])
read(5, "\0", 8192) = 1
write(2, "", 0) = 0
read(3, "====Setup set_oldtempbehaio"..., 8192) = 555
write(1, "====Setup set_oldtempbehaio"..., 555) = 555
select(6, [3 5], NULL, NULL, NULL) = 2 (in [3 5])
read(5, "", 8192) = 0
read(3, "", 8192) = 0
close(5) = 0
kill(25652, SIGKILL) = 0
exit_group(0) = ?
Process 25645 detached
_
> sudo strace -p 14462
Process 14462 attached - interrupt to quit
[ Process PID=14462 runs in 32 bit mode. ]
read(0, 0xff85fdbc, 8192) = -1 EIO (Input/output error)
shutdown(3, 1 /* send */) = 0
exit_group(0) = ?
_
> sudo strace -p 7517
Process 7517 attached - interrupt to quit
--- SIGSTOP (Stopped (signal)) # 0 (0) ---
--- SIGSTOP (Stopped (signal)) # 0 (0) ---
[ Process PID=7517 runs in 32 bit mode. ]
connect(3, {sa_family=AF_INET, sin_port=htons(300), sin_addr=inet_addr("100.64.220.98")}, 16) = -1 ETIMEDOUT (Connection timed out)
close(3) = 0
dup(2) = 3
fcntl64(3, F_GETFL) = 0x1 (flags O_WRONLY)
close(3) = 0
write(2, "dsd13: Connection timed out\n", 30) = 30
write(2, "Error code : 110\n", 17) = 17
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
exit_group(1) = ?
Process 7517 detached
Not just select(), but the processes(of same program) are stuck in various system calls before I attach them to strace. They suddenly resume after attaching to strace. If I don't attach them to strace, they just hang there forever.
Update 2:
I learned that strace could start a process which was previously stopped (process in T sate). Now I am trying to understand why did these processes go to 'T' state, what's the cause. Here's the /proc//status information:
> cat /proc/12554/status
Name: someone
State: T (stopped)
SleepAVG: 88%
Tgid: 12554
Pid: 12554
PPid: 9754
TracerPid: 0
Uid: 5000 5000 5000 5000
Gid: 48986 48986 48986 48986
FDSize: 256
Groups: 9149 48986
VmPeak: 1992 kB
VmSize: 1964 kB
VmLck: 0 kB
VmHWM: 608 kB
VmRSS: 608 kB
VmData: 156 kB
VmStk: 20 kB
VmExe: 16 kB
VmLib: 1744 kB
VmPTE: 20 kB
Threads: 1
SigQ: 54/73728
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000006
SigCgt: 0000000000004000
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
Cpus_allowed: 00000000,00000000,00000000,0000000f
Mems_allowed: 00000000,00000001
strace uses ptrace. The ptrace man page has this:
Since attaching sends SIGSTOP and the tracer usually suppresses it,
this may cause a stray EINTR return from the currently executing system
call in the tracee, as described in the "Signal injection and
suppression" section.
Are you seeing select return EINTR?

uwsgi long timeouts

I am using ubuntu 12, nginx, uwsgi 1.9 with socket, django 1.5.
Config:
[uwsgi]
base_path = /home/someuser/web/
module = server.manage_uwsgi
uid = www-data
gid = www-data
virtualenv = /home/someuser
master = true
vacuum = true
harakiri = 20
harakiri-verbose = true
log-x-forwarded-for = true
profiler = true
no-orphans = true
max-requests = 10000
cpu-affinity = 1
workers = 4
reload-on-as = 512
listen = 3000
Client tests from Windows7:
C:\Users\user>C:\AppServ\Apache2.2\bin\ab.exe -c 255 -n 5000 http://www.someweb.com/about/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.someweb.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Finished 5000 requests
Server Software: nginx
Server Hostname: www.someweb.com
Server Port: 80
Document Path: /about/
Document Length: 1881 bytes
Concurrency Level: 255
Time taken for tests: 66.669814 seconds
Complete requests: 5000
Failed requests: 1
(Connect: 1, Length: 0, Exceptions: 0)
Write errors: 0
Total transferred: 10285000 bytes
HTML transferred: 9405000 bytes
Requests per second: 75.00 [#/sec] (mean)
Time per request: 3400.161 [ms] (mean)
Time per request: 13.334 [ms] (mean, across all concurrent requests)
Transfer rate: 150.64 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 8 207.8 1 9007
Processing: 10 3380 11480.5 440 54421
Waiting: 6 1060 3396.5 271 48424
Total: 11 3389 11498.5 441 54423
Percentage of the requests served within a certain time (ms)
50% 441
66% 466
75% 499
80% 519
90% 3415
95% 36440
98% 54407
99% 54413
100% 54423 (longest request)
I have set following options too:
echo 3000 > /proc/sys/net/core/netdev_max_backlog
echo 3000 > /proc/sys/net/core/somaxconn
So,
1) I make first 3000 requests super fast. I see progress in ab and in uwsgi requests logs -
[pid: 5056|app: 0|req: 518/4997] 80.114.157.139 () {30 vars in 378 bytes} [Thu Mar 21 12:37:31 2013] GET /about/ => generated 1881 bytes in 4 msecs (HTTP/1.0 200) 3 headers in 105 bytes (1 switches on core 0)
[pid: 5052|app: 0|req: 512/4998] 80.114.157.139 () {30 vars in 378 bytes} [Thu Mar 21 12:37:31 2013] GET /about/ => generated 1881 bytes in 4 msecs (HTTP/1.0 200) 3 headers in 105 bytes (1 switches on core 0)
[pid: 5054|app: 0|req: 353/4999] 80.114.157.139 () {30 vars in 378 bytes} [Thu Mar 21 12:37:31 2013] GET /about/ => generated 1881 bytes in 4 msecs (HTTP/1.0 200) 3 headers in 105 bytes (1 switches on core 0)
I dont have any broken pipes or worker respawns.
2) Next requests are running very slow or with some timeout. Looks like that some buffer becomes full and I am waiting before it becomes empty.
3) Some buffer becomes empty.
4) ~500 requests are processed super fast.
5) Some timeout.
6) see Nr. 4
7) see Nr. 5
8) see Nr. 4
9) see Nr. 5
....
....
Need your help
check with netstat and dmesg. You have probably exhausted ephemeral ports or filled the conntrack table.