diff --git a/notify.pl b/notify.pl index 0e0f859..8c39f2c 100755 --- a/notify.pl +++ b/notify.pl @@ -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'}; diff --git a/vms/vm01.txt b/vms/vm01.txt index 76ea860..f1e7ade 100644 --- a/vms/vm01.txt +++ b/vms/vm01.txt @@ -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"