Created
January 30, 2017 08:07
-
-
Save oprietop/c14b2f79b2981a791a98be8779994cb7 to your computer and use it in GitHub Desktop.
Getting stats from aqmetrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use JSON; | |
use LWP::UserAgent; | |
use HTTP::Request::Common; | |
use HTTP::Cookies; | |
use Term::ANSIColor qw(:constants); | |
$Term::ANSIColor::AUTORESET = 1; | |
my $user = "xxxxxxx"; | |
my $pass = "xxxxxxx"; | |
# Set UA with cookies | |
my $ua = LWP::UserAgent->new( cookie_jar => HTTP::Cookies->new( autosave => 1 ) ); | |
# Login | |
my $resp = $ua->request( POST 'https://www.aqmetrix.com/signin/php/procesarLoginDual.php', [ usuario => $user , pass => $pass ] ); | |
$resp->is_success or die RED $resp->headers_as_string; | |
# Get Metrics | |
$resp = $ua->request( POST 'https://www.aqmetrix.com/signin/php/webservice.php' , [ service => 'datosResumen' , periodo => 'D' ] ); | |
$resp->is_success or die RED $resp->headers_as_string; | |
# Parse and print json | |
my $ref = decode_json($resp->decoded_content); | |
foreach my $item (@{ $ref }) { | |
print BOLD WHITE "$item->{nom_area_corto}"; | |
print YELLOW " Total: $item->{MaxTmpTarea}"; | |
print BOLD BLUE " $item->{HO}: $item->{Tmp_HO}"; | |
print GREEN " $item->{AU}: $item->{Tmp_AU}"; | |
print BLUE " $item->{T1}: $item->{Tmp_T1}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment