| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Xymon::Monitor::Informix; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
29352
|
use DBI; |
|
|
1
|
|
|
|
|
24811
|
|
|
|
1
|
|
|
|
|
79
|
|
|
5
|
1
|
|
|
1
|
|
653
|
use DBD::Informix; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Xymon::Client; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use strict; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
|
|
|
|
|
|
use Exporter (); |
|
12
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
15
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
|
16
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
17
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
|
18
|
|
|
|
|
|
|
%EXPORT_TAGS = (); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new |
|
26
|
|
|
|
|
|
|
{ |
|
27
|
|
|
|
|
|
|
my $class = shift; |
|
28
|
|
|
|
|
|
|
my $parm = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $self = bless ({}, ref ($class) || $class); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$ENV{INFORMIXCONTIME} = $parm->{CONTIME} || 5; |
|
35
|
|
|
|
|
|
|
$ENV{INFORMIXCONTRY}= $parm->{CONTRY} || 1; |
|
36
|
|
|
|
|
|
|
$ENV{INFORMIXDIR}= $parm->{INFORMIXDIR} || "/informix/"; |
|
37
|
|
|
|
|
|
|
$ENV{LD_LIBRARY_PATH} = $parm->{LD_LIBRARY_PATH} || "/informix/lib:/informix/lib/esql"; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->{home} = $parm->{HOBBITHOME} || '/home/hobbit/server/'; |
|
40
|
|
|
|
|
|
|
$self->{informixdir} = $parm->{INFORMIXDIR} || "/informix/"; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return $self; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub check { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $error; |
|
54
|
|
|
|
|
|
|
my $message; |
|
55
|
|
|
|
|
|
|
my $instance; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Get instances and hostnames from sqlhosts |
|
59
|
|
|
|
|
|
|
# |
|
60
|
|
|
|
|
|
|
# |
|
61
|
|
|
|
|
|
|
my $fh; |
|
62
|
|
|
|
|
|
|
open( $fh, "<", $self->{informixdir} . "/etc/sqlhosts"); |
|
63
|
|
|
|
|
|
|
while(<$fh>) { |
|
64
|
|
|
|
|
|
|
my ($server, $proto,$hostname) = split(/\s+/,$_); |
|
65
|
|
|
|
|
|
|
push @{$instance->{$hostname}}, $server; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
close($fh); |
|
69
|
|
|
|
|
|
|
# |
|
70
|
|
|
|
|
|
|
# Cycle through hosts |
|
71
|
|
|
|
|
|
|
# |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
foreach my $hostname (keys %$instance ) { |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $hostsuccess = 0; |
|
77
|
|
|
|
|
|
|
my $hostmsg = "Database Status\n"; |
|
78
|
|
|
|
|
|
|
my $color = "green"; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# |
|
81
|
|
|
|
|
|
|
# Now through instances |
|
82
|
|
|
|
|
|
|
# |
|
83
|
|
|
|
|
|
|
foreach my $dbserver (@{$instance->{$hostname}}) { |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $dbh = DBI->connect('dbi:Informix:sysmaster@'.$dbserver,"informix","kcgp.36", { AutoCommit => 0, PrintError => 1 }); |
|
87
|
|
|
|
|
|
|
if( $dbh ) { |
|
88
|
|
|
|
|
|
|
my @row_ary = $dbh->selectrow_array('select count(*) from systables;'); |
|
89
|
|
|
|
|
|
|
$hostmsg .= " $dbserver Connected OK\n"; |
|
90
|
|
|
|
|
|
|
} else { |
|
91
|
|
|
|
|
|
|
$hostmsg .= " $dbserver Failed Connection\n"; |
|
92
|
|
|
|
|
|
|
$hostsuccess = -1; |
|
93
|
|
|
|
|
|
|
$color = "red"; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# |
|
100
|
|
|
|
|
|
|
# Send to xymon server |
|
101
|
|
|
|
|
|
|
# |
|
102
|
|
|
|
|
|
|
my $xymon = Xymon::Client->new({home=>$self->{home}}); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$xymon->send_status({ |
|
105
|
|
|
|
|
|
|
server=>"$hostname", |
|
106
|
|
|
|
|
|
|
testname=>"database", |
|
107
|
|
|
|
|
|
|
color=>$color, |
|
108
|
|
|
|
|
|
|
msg=>$hostmsg, |
|
109
|
|
|
|
|
|
|
}); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Xymon::Monitor::Informix - Hobbit / Xymon Informix Database Monitor |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
use Xymon::Monitor::Informix; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# |
|
127
|
|
|
|
|
|
|
# All parameters ar optional and defaults are shown |
|
128
|
|
|
|
|
|
|
# |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $informix = Xymon::Monitor::Informix->new({ |
|
131
|
|
|
|
|
|
|
CONTIME => 5, |
|
132
|
|
|
|
|
|
|
CONTRY => 1, |
|
133
|
|
|
|
|
|
|
INFORMIXDIR => "/informix/", |
|
134
|
|
|
|
|
|
|
LD_LIBRARY_PATH => "/informix/lib:/informix/lib/esql/", |
|
135
|
|
|
|
|
|
|
HOBBITHOME => "/home/hobbit/client/" |
|
136
|
|
|
|
|
|
|
}); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# |
|
139
|
|
|
|
|
|
|
# |
|
140
|
|
|
|
|
|
|
$informix->check(); |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Tries to connect to all instances specified your sqlhosts file and |
|
146
|
|
|
|
|
|
|
sends the status to your Xymon/Hobbit Server. Each server will be sent a single |
|
147
|
|
|
|
|
|
|
test called database which is red if any single database is down. Status page |
|
148
|
|
|
|
|
|
|
shows status of all db instances on that host. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
You must install DBI and DBD::Informix for this module to work. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $informix = Xymon::Monitor::Informix->new({.....}); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
All parameters are optional and are listed below: |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
CONTIME - connection timeout (default 5) |
|
159
|
|
|
|
|
|
|
CONTRY - connection tries (default 1) |
|
160
|
|
|
|
|
|
|
INFORMIXDIR - informix directory ($INFORMIXDIR) (default /informix) |
|
161
|
|
|
|
|
|
|
LD_LIBRARY_PATH - default (/informix/lib:/informix/lib/esql/) |
|
162
|
|
|
|
|
|
|
HOBBITHOME - hobbit/xymon dir (default home/hobbit/client/) |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The script listed in the synopsis is all you need to send updates to Xymon/Hobbit, |
|
165
|
|
|
|
|
|
|
however you will also need to add the script to your hobbitlaunch.cfg file. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
A group of lines like the following should work. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
[informix] |
|
170
|
|
|
|
|
|
|
ENVFILE /home/hobbit/server/etc/hobbitserver.cfg |
|
171
|
|
|
|
|
|
|
NEEDS hobbitd |
|
172
|
|
|
|
|
|
|
CMD /home/hobbit/server/ext/ifxcheck.pl |
|
173
|
|
|
|
|
|
|
LOGFILE $BBSERVERLOGS/informix.log |
|
174
|
|
|
|
|
|
|
INTERVAL 30 |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The installation script asks you where you want to install the included test script. |
|
178
|
|
|
|
|
|
|
It should go in your hobbit ext directory. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 METHODS |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
check() - checks all found instances from sqlhosts and sends status |
|
183
|
|
|
|
|
|
|
to master hobbit server. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 AUTHOR |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
David Peters |
|
189
|
|
|
|
|
|
|
CPAN ID: DAVIDP |
|
190
|
|
|
|
|
|
|
davidp@electronf.com |
|
191
|
|
|
|
|
|
|
http://www.electronf.com |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
196
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
199
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
perl(1), Xymon::Client, www.xymon.com |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
1; |
|
212
|
|
|
|
|
|
|
# The preceding line will help the module return a true value |
|
213
|
|
|
|
|
|
|
|