Forum Discussion
Christian_Laute
May 02, 2017Nimbostratus
Using variables in external Perl monitor
Gents, I currently use a external monitor to check the JSON output of some webservices. Now I try to make it a little bit more flexible.
For example I want to try to replace the string "UP" at if($status eq "UP") to if($status eq $statusmsg) but not sure how to do this.
Current script:
!/usr/bin/env perl
use LWP::Simple;
use JSON;
$URI = $ARGV[2];
$HOSTNAME = $ARGV[0];
$HOSTNAME =~ s/::ffff://;
$PORT=$ARGV[1];
$contents = get("http://$HOSTNAME:$PORT$URI");
$json = decode_json($contents);
$status = $json->{'status'};
if($status eq "UP") {
print $status;
}
Typing in the variable like below did not help. Also hard to find any documentations about it....
Maybe anyone of you can help me out? Many thanks
Try:
!/usr/bin/env perl use LWP::Simple; use JSON; $URI = $ARGV[2]; $HOSTNAME = $ARGV[0]; $HOSTNAME =~ s/::ffff://; $PORT=$ARGV[1]; $contents = get("http://$HOSTNAME:$PORT$URI"); $json = decode_json($contents); $status = $json->{'status'}; $statusmsg = $ENV{'statusmsg'}; if($status eq $statusmsg) { print $status; }
Also take a look at this:
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