|
|
|
@ -6,20 +6,22 @@ use JSON; |
|
|
|
|
use Getopt::Long; |
|
|
|
|
use LWP::UserAgent; |
|
|
|
|
use HTTP::Cookies; |
|
|
|
|
use URI; |
|
|
|
|
use Data::Dumper; |
|
|
|
|
|
|
|
|
|
umask 077; |
|
|
|
|
|
|
|
|
|
my $user = 'zabbix'; |
|
|
|
|
my $pass = 'secret'; |
|
|
|
|
my $site = 'default'; |
|
|
|
|
my $url = 'https://localhost:8443'; |
|
|
|
|
my $user = 'zabbix'; |
|
|
|
|
my $pass = 'secret'; |
|
|
|
|
my $site = 'default'; |
|
|
|
|
my $url = 'https://localhost:8443'; |
|
|
|
|
my $certcheck = 1; |
|
|
|
|
my $unifi; |
|
|
|
|
my $dev; |
|
|
|
|
my $station; |
|
|
|
|
my $net; |
|
|
|
|
my $wlan; |
|
|
|
|
my $pretty = 0; |
|
|
|
|
my $pretty = 0; |
|
|
|
|
|
|
|
|
|
my $json = {}; |
|
|
|
|
my $site_id; |
|
|
|
@ -29,6 +31,7 @@ GetOptions ( |
|
|
|
|
'password|p=s' => \$pass, |
|
|
|
|
'site=s' => \$site, |
|
|
|
|
'url=s' => \$url, |
|
|
|
|
'cert-check!' => \$certcheck, |
|
|
|
|
'unifi' => \$unifi, |
|
|
|
|
'dev=s' => \$dev, |
|
|
|
|
'station=s' => \$station, |
|
|
|
@ -37,6 +40,12 @@ GetOptions ( |
|
|
|
|
'pretty' => \$pretty |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
# If connecting to localhost, no need to check certificate |
|
|
|
|
my $uri = URI->new($url); |
|
|
|
|
if ($uri->host =~ m/^localhost|127\.0\.0/){ |
|
|
|
|
$certcheck = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
my @radio_proto = qw/a b g na ng ac/; |
|
|
|
|
my $resp; |
|
|
|
|
my $username = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<); |
|
|
|
@ -45,8 +54,13 @@ my $cj = HTTP::Cookies->new( |
|
|
|
|
autosave => 1, |
|
|
|
|
ignore_discard => 1 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
my $sslopts = {}; |
|
|
|
|
if (not $certcheck){ |
|
|
|
|
$sslopts = { verify_hostname => 0, SSL_verify_mode => 0 } |
|
|
|
|
} |
|
|
|
|
my $ua = LWP::UserAgent->new( |
|
|
|
|
ssl_opts => { verify_hostname => 0 }, |
|
|
|
|
ssl_opts => $sslopts, |
|
|
|
|
cookie_jar => $cj |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|