Hi again. So I was able to install the module and I added the code to my script and got a few errors but also the same output as yours. Please find my code and output below. Is there something I must fix?
#!/usr/bin/perl -w
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
require HTTP::Cookies;
my $netloc = "xxx.xx.xx.xx:80";
my $realm = "Realm";
my $user = "username";
my $pass = "password";
my $auth_token = "token code";
my $ua = new LWP::UserAgent;
$ua->agent('Mozilla/5.0');
my $cookie_jar = HTTP::Cookies->new( file => 'cookies_lwp.txt', autosa
+ve => 1, ignore_discard => 1 );
$ua->cookie_jar($cookie_jar);
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
$ua->default_header( "Authorization" => "Bearer $auth_token");
$ua->default_header( "Accept" =>"application/json" );
$ua->default_header( "Content-Type" => "application/json");
$ua->credentials( $netloc, $realm, $user, $pass);
$ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => 0x00);
my $request = new HTTP::Request('GET','https://xxx.xx.xx.xx/api/v2/dev
+ices/00:04:56:22:51:32/performance/?start_time=2022-02-15T10:00:00&st
+op_time=2022-02-16T10:00:00');
my $response = $ua->request($request);
if ($response->is_success) {
my $output = $response->decoded_content;
#print $output."\n";
#Code from perlmonks
use JSON::PP;
my $data = join '', $output;
my $hashref = JSON::PP->new->decode($data);
use Data::Dump 'dd'; dd $hashref;
}
else {
print STDERR $response->status_line, "\n";
}
Output:
Subroutine main::encode_json redefined at /usr/local/share/perl5/Expor
+ter.pm line 66.
at ./wifi-api-get.pl line 33.
Subroutine main::decode_json redefined at /usr/local/share/perl5/Expor
+ter.pm line 66.
at ./wifi-api-get.pl line 33.
Prototype mismatch: sub main::decode_json ($) vs none at /usr/local/sh
+are/perl5/Exporter.pm line 66.
at ./wifi-api-get.pl line 33.
Subroutine main::from_json redefined at /usr/local/share/perl5/Exporte
+r.pm line 66.
at ./wifi-api-get.pl line 33.
Prototype mismatch: sub main::from_json ($@) vs ($) at /usr/local/shar
+e/perl5/Exporter.pm line 66.
at ./wifi-api-get.pl line 33.
Subroutine main::to_json redefined at /usr/local/share/perl5/Exporter.
+pm line 66.
at ./wifi-api-get.pl line 33.
Prototype mismatch: sub main::to_json ($@) vs ($) at /usr/local/share/
+perl5/Exporter.pm line 66.
at ./wifi-api-get.pl line 33.
{
data => [
{
mac => "00:04:56:22:51:32",
managed_account => "",
mode => "ap",
name => "Espat AP3",
network => "Belize City ePMP",
online_duration => 3600,
radio => {
dl_frame_utilization => 53.50833,
dl_kbits => 218936297,
dl_pkts => 24533891,
dl_retransmits_pct => 3.7125,
dl_throughput => 60611.05917,
ul_kbits => 11781720,
ul_pkts => 10095078,
ul_retransmits_pct => 1.7481,
ul_throughput => 3261.45,
},
sm_count => 45,
sm_drops => 1,
timestamp => "2022-02-15T04:00:00-06:00",
tower => "Espat Twr",
type => "epmp",
uptime => 3600,
},
{
mac => "00:04:56:22:51:32",
managed_account => "",
mode => "ap",
name => "Espat AP3",
network => "Belize City ePMP",
online_duration => 3600,
radio => {
dl_frame_utilization => 55.79167,
dl_kbits => 228622837,
dl_pkts => 25268171,
dl_retransmits_pct => 3.4875,
dl_throughput => 63241.6925,
ul_kbits => 11064503,
ul_pkts => 10404746,
ul_retransmits_pct => 1.6548,
ul_throughput => 3060.63917,
},
.
.
.
.
rest of the output similar to your output.
|