Subject: | warnings given with inquire channel status |
Date: | Mon, 14 Dec 2009 20:54:31 -0500 |
To: | "bug-MQSeries [...] rt.cpan.org" <bug-MQSeries [...] rt.cpan.org> |
From: | "Frost, Mark {PBG}" <mark.frost1 [...] pepsi.com> |
Hello. Thanks for writing this module.
I was trying to write a Nagios check to count the number of channel instances on a particular channel. I've found that while I could successfully run the InquireChannelStatus command and get a result, I would get warnings if I used the "-w" flag. I could ignore those, but when turn through Nagios' embedded perl interpreter (epn), it forces -w on which causes the script to not work properly (unless I force epn off for the script which has other implications).
In any case, here's the simplest case I could whip up to demonstrate this. Substitute qmgr parameters as variables. Run with '-w' and get something like:
Use of uninitialized value in hash element at /usr/local/eam/perl5/x86_64-linux-thread-multi/MQSeries/Command/Base.pm line 444.
Use of uninitialized value in hash element at /usr/local/eam/perl5/x86_64-linux-thread-multi/MQSeries/Command/Base.pm line 444.
channel CLIENT.MQHTTP has 1 instances.
I'm using MQSeries 1.29 and MQ version 7.0.1 on Opensuse 11.2 Linux.
Here's my sample script:
#!/usr/bin/perl -w
# Check the number of connections on a channel (channel instances)
use lib qw( /usr/local/eam/perl5/x86_64-linux-thread-multi
/usr/local/eam/nagios/libexec
/usr/local/eam/perl5 );
use strict;
use warnings;
# force usage of the client libraries rather than letting MQSeries.pm "guess"
use MQClient::MQSeries;
use MQSeries::Command;
use vars qw(
$DEFAULT_CHANNEL $warning $critical
$QMGR $HOST $PORT $STATUS_CHANNEL
);
# qmgr to connect to
$QMGR = 'QMGR';
# hostname the qmgr lives on
$HOST = 'hostname';
# qmgr's port number
$PORT = 1422;
# channel to use for connection
$DEFAULT_CHANNEL = 'SYSTEM.ADMIN.SVRCONN';
# channel we want to count channel instances of
$STATUS_CHANNEL = 'CHANNEL';
# Instead of passing in a string that's the name of the queue manager,
# open a client connection using MQSeries::QueueManager and hand that
# object to MQSeries::Command->new
my $qmgr = MQSeries::QueueManager->new(
QueueManager => $QMGR,
ClientConn => {
'ChannelName' => $DEFAULT_CHANNEL,
'ConnectionName' => $HOST . '(' . $PORT . ')',
'TransportType' => 'TCP'
}
) or die "Unable to instantiate queue manager object";
my $command = MQSeries::Command->new(
QueueManager => $QMGR,
Type => 'PCF',
)
or die "Unable to instantiate command object" ;
my @attrs;
@attrs= $command->InquireChannelStatus (
ChannelName => $STATUS_CHANNEL,
ChannelInstanceType => 'Current',
ChannelInstanceAttrs => [ qw ( All ) ]
) or die "InquireChannelStatus(): " . MQReasonToText($command->Reason());
print "channel $STATUS_CHANNEL has ", $#attrs + 1, " instances.\n";
Thanks.
Mark Frost
PBG Enterprise Application Management (EAM)
Ofc: 914.767.6894