/[svn]/nagios/tags/monitoring.dennisonwilliams.com/libexec/BelkinF5D72304v8000.pm
ViewVC logotype

Contents of /nagios/tags/monitoring.dennisonwilliams.com/libexec/BelkinF5D72304v8000.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2138 - (show annotations)
Sat Apr 25 18:01:17 2009 UTC (10 years, 7 months ago) by evoltech
File size: 1674 byte(s)
Error occurred while calculating annotation data.
This directory must have gotten lost from the repo when frenzy did the rm -rf, adding it again
1 package BelkinF5D72304v8000;
2
3 #use lib "/usr/local/nagios/libexec", "/usr/local/nagios/libexec/Mechanize_experimental" ;
4 use lib "/usr/local/nagios/libexec" ;
5 use WWW::Mechanize;
6
7 sub new {
8 my ($class, $hostname) = @_;
9 my $self = {
10 'error' => 0,
11 'error_msg' => '',
12 'hostname' => '',
13 'mech' => ''
14 };
15
16 if (!defined($hostname)) {
17 die('A hostname is required.');
18 }
19 else {
20 $self->{hostname} = $hostname;
21 $self->{mech} = new WWW::Mechanize;
22 }
23
24 return bless($self, $class);
25 }
26
27 sub init {
28 my ($self) = @_;
29
30 if (!defined($self->{hostname})) {
31 die('A hostname is required.');
32 }
33 elsif (!defined($self->{mech})) {
34 die('Mech was never instantiated.');
35 }
36 else {
37 $self->{mech}->get('http://'. $self->{hostname});
38 $self->{gw} = $self->_init_gw();
39 $self->{wan_ip} = $self->_init_wan_ip();
40 $self->{dns} = $self->_init_dns();
41 }
42 }
43
44 sub _init_gw {
45 my ($self) = @_;
46 if ($self->{mech}->content =~
47 /i18.+?document\.write\(\'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/s)
48 {
49 return $1;
50 }
51 else {
52 $self->error = 1;
53 $self->error_msg .= "could not get the gw\n";
54 }
55 }
56
57 sub _init_wan_ip {
58 my ($self) = @_;
59 if ($self->{mech}->content =~
60 /i17.+?document\.write\(\'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/s)
61 {
62 return $1;
63 }
64 else {
65 $self->error = 1;
66 $self->error_msg .= "could not get the wan ip\n";
67 }
68 }
69
70 sub _init_dns {
71 my ($self) = @_;
72 if ($self->{mech}->content =~
73 /i19.+?document\.write\(\'([^\']+?)\'\)/s)
74 {
75 @addrs = split(/<br>/, $1);
76 return \@addrs;
77 }
78 else {
79 $self->error = 1;
80 $self->error_msg .= "could not get the dns addrs\n";
81 }
82 }
83
84 1;

Properties

Name Value
svn:executable

dennison.williams@gmail.com
ViewVC Help
Powered by ViewVC 1.1.5