forked from pierdom/atlas-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudm-status.pl
executable file
·111 lines (73 loc) · 2.13 KB
/
udm-status.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/perl
# Print status of a RIPE Atlas measurement
# Author: Pierdomenico Fiadino <[email protected]>
## modules ##
use warnings;
use strict;
use diagnostics;
use JSON;
use LWP::Simple;
use Getopt::Long;
use Data::Dumper;
use Pod::Usage;
## variables ##
my $help;
my $api_key;
my $udm_id;
## read options ##
my $rc = GetOptions (
"help" =>\$help,
"api-key=s"=>\$api_key,
"udm-id=i" =>\$udm_id
) or die "Syntax error";
## print help ##
if($help) {
pod2usage(1);
}
## check arguments ##
unless($udm_id) {
die "Missing argument: --udm-id is mandatory"
}
## retrieve measurement status ##
my $udm_url = "https://atlas.ripe.net/api/v1/measurement/$udm_id/";
if($api_key) {
$udm_url.="?key=$api_key";
}
my $status_content = get $udm_url or die "Unable to download JSON";
my $status_hash = from_json $status_content or die "Unable to convert JSON";
$Data::Dumper::Varname = "UDM";
print Dumper($status_hash);
## exit
exit 1;
__END__
=pod
=head1 NAME
udm-status - retrieve status of a RIPE Atlas measurement
=head1 VERSION
1.0
=head1 DESCRIPTION
A simple script to retrieve the status of a RIPE Atlas measurement
using RIPE'S REST APIs.
A suitable API key might be required depending on the measurement
permissions.
=head1 SYNOPSIS
Usage: udm-status --udm=<ID> (--api=<KEY>)
API key is optional
=head1 LICENSE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
=head1 ACKNOWLEDGEMENT
This work has been partially funded by the European Commission
funded mPlane ICT-318627 project (www.ict-mplane.eu).
=head1 AUTHOR
Pierdomenico Fiadino <[email protected]>
Vienna - May, 2014
=cut