Forum Discussion
ltaylor510_5583
Nimbostratus
Sep 18, 2008Perl script to display All BigIP pool members
I have a Perl CGI application in apache that will need a perl script to display all the available elements in one script:
("poolname" "address" "port" "session_state" "priority_group")
preferably in a toggle script under the showPoolMembers() subroutine.
I see the get_priority() method is only listed as a java method. Is there a perl equivalent that could list all of these elements in one script?
thanks in advance for any help.
24 Replies
- ltaylor510_5583
Nimbostratus
Humphrey -
Thank you for the script - I like the abridged version of this.
very cool.
Larry - Thomas_LE_GENTI
Nimbostratus
Hi !
thanks a lot for the script, this is exactly what I was looking for.
Unfortunately, I don't manage to us it in Oreon.
I created a new command named check_F5,
and used the command :
/home/thomas/test_icontrol.pl $HOSTADDRESS$ user pass
what did I've done wrong ? cuz It works very well when I type it in the shell ...
Thanks a lot - hwidjaja_37598
Altostratus
is check_F5 a Perl script? is there any error message?
can u try to remove the dollar sign at the end of $HOSTADRESS$? - Thomas_LE_GENTI
Nimbostratus
Hi !
the other dollar sign is at the end of the variable in the other commands, so I let it so.
Yes it is a perl script.
the error message is (No output!)
++ - hwidjaja_37598
Altostratus
you can post it here so we might be able to see the error in the coding. - Thomas_LE_GENTI
Nimbostratus
Infact, the code is actually good, cuz i'm using it in a shell. But nagios is sending me back in /usr/local/nagios/var/nagios.log :
[1223640521] **ePN failed to compile /usr/local/nagios/libexec//check_F5.pl: "Global symbol "$LocalLBPool" requires explicit package name at (eval 84) line 10,
Global symbol "$LocalLBPoolMember" requires explicit package name at (eval 84) line 22.
Global symbol "$Soap" requires explicit package name at (eval 84) line 26.
do you want the source code ? (it is the one given above)
thanks ! - Thomas_LE_GENTI
Nimbostratus
ok I found why.
It seems that p1.pl is launching my code. So I have to use only local variables using 'my'.
So it is working.
here is my code :!/usr/bin/perl use SOAP::Lite; use lib "."; use iControlTypeCast; die ("Usage: $0 host uid pwd \n") if ($ARGV != 2); my ($sHost,$sUID,$sPWD) = @ARGV; my $LocalLBPool = SOAP::Lite -> uri('urn:iControl:LocalLB/Pool') -> proxy("https://$sUID:$sPWD\@$sHost/iControl/iControlPortal.cgi"); my $LocalLBPoolMember = SOAP::Lite -> uri('urn:iControl:LocalLB/PoolMember') -> proxy("https://$sUID:$sPWD\@$sHost/iControl/iControlPortal.cgi"); my $Soap = $LocalLBPool->get_list(); my $member; my %SessionStatus; foreach my $Pool (@{$Soap->result}) { $Soap = $LocalLBPoolMember->get_session_status (SOAP::Data->name(pool_names => [$Pool])); foreach $member (@{${$Soap->result}[0]}) { $SessionStatus{"$member->{'member'}->{'address'}:$member->{'member'}->{'port'}"} = $member->{'session_status'}; } $Soap = $LocalLBPoolMember->get_priority(SOAP::Data->name(pool_names => [$Pool])); foreach $member (@{${$Soap->result}[0]}) { print join (" ", $Pool, $member->{'member'}->{'address'}, $member->{'member'}->{'port'}, $SessionStatus{"$member->{'member'}->{'address'}:$member->{'member'}->{'port'}"}, $member->{'priority'} ,"\n" ); } }
Edit: it is {$Soap->result } [ 0 ]
and still have an error : "Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/iControlTypeCast.pm line 189
any Idea ?
Thks - hwidjaja_37598
Altostratus
I meant the source code for check_F5.pl and p1.pl.
It looks like nagios has this line "use strict;" so all variable needs to be declared using my/local/our.
You can try:
- comment out all "use strict;" in nagios, or
- check iControlTypeCast.pm line 189, you might need to modify it for not using uninitialized hash variable. - Thomas_LE_GENTI
Nimbostratus
the check_F5.pl was your code I've taken from the .txt file above.
but I gave up.
I use the big one given above
but I still have that problem seen on /usr/local/nagios/var/nagios.cfg:
INITIAL SERVICE STATE: XXXremovedXXX;check_F5;CRITICAL;HARD;1;(No output!)
What does it mean ? normally it sends me good data when i'm in a shell ...
What should I do ?
thx - hwidjaja_37598
Altostratus
Hmm... Sorry I'm not an expert in Nagios. It looks like you need to check with Nagios user.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects