summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormischa <mischa@rx.high5.nl>2020-06-15 17:11:52 +0200
committermischa <mischa@rx.high5.nl>2020-06-15 17:11:52 +0200
commite71569aace7acacb403beb3825df635dd3496dab (patch)
tree88dc5a338d8e5337aa063b9249f28f2027b9e858
parent895549f155068b379a36ae6d577143510e930c23 (diff)
use HTTP::Tiny to collect obsda.ms statistics
-rwxr-xr-xnotify.pl13
-rw-r--r--vms/vm01.txt2
2 files changed, 11 insertions, 4 deletions
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"