line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::GMOD::Admin::Monitor::mysqld; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Monitor and restart mysqld as necessary |
4
|
1
|
|
|
1
|
|
37411
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
5
|
use vars qw/@ISA/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
6
|
1
|
|
|
1
|
|
433
|
use Bio::GMOD::Admin::Monitor; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
5
|
use Bio::GMOD::Util::Rearrange; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
397
|
use DBI; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw/Bio::GMOD::Admin::Monitor/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub check_status { |
13
|
|
|
|
|
|
|
my ($self,@p) = @_; |
14
|
|
|
|
|
|
|
my ($testdb) = rearrange([qw/TESTDB/],@p); |
15
|
|
|
|
|
|
|
$testdb ||= 'test'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$self->{testing} = 'mysqld'; |
18
|
|
|
|
|
|
|
$self->{tested_at} = $self->fetch_date; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $db = DBI->connect("dbi:mysql:$testdb",'nobody'); |
21
|
|
|
|
|
|
|
$self->set_status(-timing => 'initial', |
22
|
|
|
|
|
|
|
-msg => 'Testing mysqld', |
23
|
|
|
|
|
|
|
-status => ($db) ? 'up' : 'down'); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub restart { |
28
|
|
|
|
|
|
|
my ($self,@p) = @_; |
29
|
|
|
|
|
|
|
my ($mysqld,$initd,$testdb) = rearrange([qw/MYSQLD_SAFE MYSQL_INITD TESTDB/],@p); |
30
|
|
|
|
|
|
|
my $flag; |
31
|
|
|
|
|
|
|
if ($initd && -e $initd) { |
32
|
|
|
|
|
|
|
system("$initd condrestart"); |
33
|
|
|
|
|
|
|
$flag++; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
if ($mysqld && -e $mysqld && !$flag) { |
37
|
|
|
|
|
|
|
# Make sure that we aren't already running... |
38
|
|
|
|
|
|
|
$self->check_status(); |
39
|
|
|
|
|
|
|
if ($self->is_down) { |
40
|
|
|
|
|
|
|
system("$mysqld --user=mysql &"); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$testdb ||= 'test'; |
45
|
|
|
|
|
|
|
my $db = DBI->connect("dbi:mysql:$testdb",'nobody'); |
46
|
|
|
|
|
|
|
my ($string,$status) = $self->set_status(-timing => 'final', |
47
|
|
|
|
|
|
|
-msg => "Restarting mysqld via " . ($mysqld ? $mysqld : $initd), |
48
|
|
|
|
|
|
|
-status => ($db) ? 'succeeded' : 'failed'); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Bio::GMOD::Admin::Monitor::mysqld - Monitor mysqld |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Check that mysqld is running |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Bio::GMOD::Admin::Monitor::mysqld; |
67
|
|
|
|
|
|
|
my $monitor = Bio::GMOD::Admin::Monitor::mysqld->new(); |
68
|
|
|
|
|
|
|
$monitor->check_status(-site => 'http://www.flybase.org'); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Typical values for initd systems might be something like: |
71
|
|
|
|
|
|
|
#$INITD = '/etc/rc.d/init.d/mysqld'; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# For non-init systems |
74
|
|
|
|
|
|
|
#$MYSQLD = '/usr/local/mysql/bin/mysqld_safe'; |
75
|
|
|
|
|
|
|
#$MYSQLD = '/usr/bin/safe_mysqld'; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Bio::GMOD::Admin::Monitor::httpd provides methods for monitoring and |
81
|
|
|
|
|
|
|
restarting httpd as necessary at a MOD. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item $gmod->check_status(-site => SITE) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Check the status of httpd at a specified site. This is done by |
90
|
|
|
|
|
|
|
fetching the top level URL, assuming that if it can be retrieved that |
91
|
|
|
|
|
|
|
httpd is up. Returns true if the provided site is up, false if it is |
92
|
|
|
|
|
|
|
down. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method also populates the object with a variety of status |
95
|
|
|
|
|
|
|
strings. See the "ACCESSOR METHODS" section of Bio::GMOD::Admin::Monitor for |
96
|
|
|
|
|
|
|
additional details. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If SITE is not provided, the URL for the live site (fetched from the |
99
|
|
|
|
|
|
|
adaptor for the appropriate MOD) will be used: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $monitor = Bio::GMOD::Admin::Monitor::httpd->new(-mod=>'WormBase'); |
102
|
|
|
|
|
|
|
$monitor->check_status(); # Checks the status of http://www.wormbase.org/ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item $monitor->restart(-apachectl => APACHECTL); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Restart httpd using the apachectl script. If not provided as an |
107
|
|
|
|
|
|
|
option, assumes that apachectl resides at |
108
|
|
|
|
|
|
|
/usr/local/apache/bin/apachectl. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns true if httpd is successfully restarted; otherwise returns |
111
|
|
|
|
|
|
|
false. Like check_status(), this method populates a number of status |
112
|
|
|
|
|
|
|
fields in the object. See the "ACCESSOR METHODS" section of |
113
|
|
|
|
|
|
|
Bio::GMOD::Admin::Monitor for additional details. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=back |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 BUGS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
None reported. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SEE ALSO |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L, L |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 AUTHOR |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Todd W. Harris Eharris@cshl.orgE. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (c) 2003-2005 Cold Spring Harbor Laboratory. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
132
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |