use HTTP::Tiny to collect obsda.ms statistics

This commit is contained in:
mischa 2020-06-15 17:11:52 +02:00
parent 895549f155
commit e71569aace
2 changed files with 11 additions and 4 deletions

View File

@ -24,6 +24,7 @@ use strict;
use warnings;
use autodie;
use POSIX qw(strftime);
use HTTP::Tiny;
# Get function and function_variable (vmid) from arguments
my $function = $ARGV[0] || "empty";
@ -162,9 +163,15 @@ sub renewal {
my $year = strftime("%Y", localtime);
my $month = strftime("%m", localtime);
my $total_donated = qx(ftp -Vo- https://obsda.ms/index.html | grep "donated to OpenBSD" | awk -F';' '{print \$4}' | awk '{printf \$1}');
my $total_vms = qx(ftp -Vo- https://obsda.ms/index.html | grep "deployed" | awk -F '>' '{print \$3}' | awk '{printf \$1}');
my $total_hosts = qx(ftp -Vo- https://obsda.ms/servers.html | grep -c ">Server " | tr -d '\n');
#my $total_donated = qx(ftp -Vo- https://obsda.ms/index.html | grep "donated to OpenBSD" | awk -F';' '{print \$4}' | awk '{printf \$1}');
#my $total_vms = qx(ftp -Vo- https://obsda.ms/index.html | grep "deployed" | awk -F '>' '{print \$3}' | awk '{printf \$1}');
#my $total_hosts = qx(ftp -Vo- https://obsda.ms/servers.html | grep -c ">Server " | tr -d '\n');
my $response = HTTP::Tiny->new->get('https://openbsd.amsterdam/index.html');
my $total_donated = $1 if $response->{'content'} =~ /([0-9,]+) donated to OpenBSD/;
my $total_vms = $1 if $response->{'content'} =~ /([0-9,]+) VMs deployed/;
$response = HTTP::Tiny->new->get('https://openbsd.amsterdam/servers.html');
my $total_hosts = () = $response->{'content'} =~ /(\>Server )/g;
for my $vm_name (sort keys %vms) {
my $_date = $vms{$vm_name}{'date'};

View File

@ -2,7 +2,7 @@ mac="fe:e1:ab:dd:73:a4"
ip="192.168.1.1"
instance="superduper1"
owner="testuser1"
date="2018/05/02"
date="2018/06/02"
payment="70"
donated=""
name="Test1 User"