aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/README15
-rwxr-xr-xexamples/dbload4
-rwxr-xr-xexamples/inspect4
-rwxr-xr-xexamples/ipadd4
-rwxr-xr-xexamples/ipdel4
-rw-r--r--examples/lib/LWP/Ping903.pm49
6 files changed, 11 insertions, 69 deletions
diff --git a/examples/README b/examples/README
index f5a1c50..df17f0c 100644
--- a/examples/README
+++ b/examples/README
@@ -5,6 +5,9 @@ facilities via REST API. You can use them as templates for writing
your own configuration system, or just run them as they are, if you
prefer.
+For a mature, advanced ping903 remote management system, please see
+<http://git.gnu.org.ua/cgit/ping903/mangemanche.git>.
+
* Programs
- inspect
@@ -20,18 +23,6 @@ prefer.
- dbload
Populates the list of monitored addresses from a SQL database.
-All these programs use the LWP::Ping903 module, which provides support
-for parsing the ".ping903.cred" file. The source file for the module is
-lib/LWP/Ping903.pm. To run the programs from the examples directory,
-define the following environment variable:
-
- export PERL5LIB=lib
-
-If you don't plan to use basic authorization, you can get rid of this
-dependency using the following command:
-
- sed -i 's/LWP::Ping903/LWP::UserAgent/' inspect ipadd ipdel dbload
-
* Documentation
Each example is self-documented. To access the description, run the
diff --git a/examples/dbload b/examples/dbload
index 245ace2..4502d55 100755
--- a/examples/dbload
+++ b/examples/dbload
@@ -179,7 +179,7 @@ L<DBI>.
use strict;
use warnings;
use JSON;
-use LWP::Ping903;
+use LWP::UserAgent;
use DBI;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use File::Spec;
@@ -253,7 +253,7 @@ my $json_text = JSON->new->encode({
'ip-list' => [ map { $_->[0] } @$res ]
});
-my $ua = new LWP::Ping903;
+my $ua = new LWP::UserAgent;
my $response = $ua->post("$baseurl/config/ip-list",
'Content-Type' => 'application/json',
diff --git a/examples/inspect b/examples/inspect
index af3d3de..0aa2fb5 100755
--- a/examples/inspect
+++ b/examples/inspect
@@ -73,7 +73,7 @@ L<DBI>.
use strict;
use warnings;
-use LWP::Ping903;
+use LWP::UserAgent;
use HTTP::Status qw(:constants);
use JSON;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
@@ -99,7 +99,7 @@ GetOptions(
) or exit(1);
die "too many arguments; try `$0 --help' for more info\n" if @ARGV;
-my $ua = new LWP::Ping903;
+my $ua = new LWP::UserAgent;
my $response = $ua->get("$baseurl/config");
unless ($response->is_success) {
diff --git a/examples/ipadd b/examples/ipadd
index d6195da..f001950 100755
--- a/examples/ipadd
+++ b/examples/ipadd
@@ -57,7 +57,7 @@ L<DBI>.
use strict;
use warnings;
-use LWP::Ping903;
+use LWP::UserAgent;
use JSON;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use Pod::Usage;
@@ -82,7 +82,7 @@ GetOptions(
my $ip = shift @ARGV or die "not enough arguments";
die "too many arguments; try `$0 --help' for more info\n" if @ARGV;
-my $ua = new LWP::Ping903;
+my $ua = new LWP::UserAgent;
my $response = $ua->put("$baseurl/config/ip-list/$ip");
unless ($response->is_success) {
print $response->status_line,"\n";
diff --git a/examples/ipdel b/examples/ipdel
index 8eed7eb..fa4cb8f 100755
--- a/examples/ipdel
+++ b/examples/ipdel
@@ -57,7 +57,7 @@ L<DBI>.
use strict;
use warnings;
-use LWP::Ping903;
+use LWP::UserAgent;
use JSON;
use Getopt::Long qw(:config gnu_getopt no_ignore_case);
use Pod::Usage;
@@ -83,7 +83,7 @@ my $ip = shift @ARGV or die "not enough arguments";
die "too many arguments; try `$0 --help' for more info\n" if @ARGV;
-my $ua = new LWP::Ping903;
+my $ua = new LWP::UserAgent;
my $response = $ua->delete("$baseurl/config/ip-list/$ip");
unless ($response->is_success) {
print $response->status_line,"\n";
diff --git a/examples/lib/LWP/Ping903.pm b/examples/lib/LWP/Ping903.pm
deleted file mode 100644
index 8fc398e..0000000
--- a/examples/lib/LWP/Ping903.pm
+++ /dev/null
@@ -1,49 +0,0 @@
-package LWP::Ping903;
-use parent 'LWP::UserAgent';
-use File::Spec;
-use HTTP::Status qw(:constants);
-use strict;
-use warnings;
-use Carp;
-
-my $VERSION = '0.3';
-
-sub new {
- my $class = shift;
- my $self = bless $class->SUPER::new(@_), $class;
- $self->agent("$class/$VERSION");
- return $self;
-}
-
-sub get_basic_credentials {
- my ($self, $realm, $uri, $isproxy) = @_;
- my $cf = File::Spec->catfile($ENV{HOME}, ".ping903.cred");
- if (open(my $fh, '<', $cf)) {
- while (<$fh>) {
- chomp;
- s/^\s+//;
- s/\s+$//;
- next if /^(#.*)?$/;
- my @words;
- while ($_) {
- no warnings 'uninitialized';
- if (s/^"(.*?)(?<!\\)"(?:\s+(.*))?$/$2/) {
- (my $s = $1) =~ s/\\([\\\"])/$1/g;
- push @words, $s;
- } else {
- s/^(.+?)(?:\s+(.+))?$/$2/;
- push @words, $1;
- }
- }
- if (@words == 4) {
- my($h,$p) = split /:/, $words[0], 2;
- if (($h eq '*' || $h eq $uri->host)
- && (!$p || $p eq '*' || $p eq $uri->port)
- && ($words[1] eq $realm || $words[1] eq '*')) {
- return @words[2..3];
- }
- }
- }
- }
- return ();
-}

Return to:

Send suggestions and report system problems to the System administrator.