| 1 | package Lemonldap::Cluster::Statuslemonldap; | ||
| 2 | #Copyright (C) 2005 by Eric German, <germanlinux@yahoo.fr> | ||
| 3 | # FILE Statuslemonlda.pm | ||
| 4 | # Lemonldap originaly written by Eric German who decided to publish him in | ||
| 5 | # 2003 under the terms of the GNU General Public License version 2. | ||
| 6 | ######## | ||
| 7 | |||
| 8 | use Lemonldap::Cluster::Status; | ||
| 9 | use Lemonldap::Config::Parameters; | ||
| 10 | |||
| 11 | use Apache::Constants qw (:common) ; | ||
| 12 | sub handler { | ||
| 13 | my $CONF; | ||
| 14 | my $FILE; | ||
| 15 | my $GLUE; | ||
| 16 | |||
| 17 | my $r = shift; | ||
| 18 | my $p; | ||
| 19 | my %param; | ||
| 20 | $p=$r->args if $r->args ; | ||
| 21 | if ($p) { | ||
| 22 | my @parax = split "&" , $p ; | ||
| 23 | my @pr; | ||
| 24 | foreach (@parax) { | ||
| 25 | (my $cle,my $val) = split "=" , $_; | ||
| 26 | push @pr ,$cle; | ||
| 27 | push @pr, $val; | ||
| 28 | } | ||
| 29 | %param = @pr ; | ||
| 30 | |||
| 31 | } | ||
| 32 | $FILE = $r->dir_config('LemonldapConfig'); | ||
| 33 | $GLUE = $r->dir_config('LemonldapConfigIpcKey'); | ||
| 34 | $GLUE = $r->dir_config('LemonldapConfigdbpath') unless $GLUE; | ||
| 35 | $CONF= Lemonldap::Config::Parameters->new ( | ||
| 36 | file => $FILE , | ||
| 37 | cache => $GLUE ); | ||
| 38 | my $config=$CONF->getAllConfig(); | ||
| 39 | ######## | ||
| 40 | # test the present of one parameter cluster | ||
| 41 | ### | ||
| 42 | my $cluster = $param{'cluster'}; | ||
| 43 | my $clu =$config->{cluster} ; | ||
| 44 | unless ($cluster) { | ||
| 45 | #I don't find cluster i' ll take the first | ||
| 46 | # | ||
| 47 | my @t =keys %$clu; | ||
| 48 | $cluster= $t[0]; | ||
| 49 | } | ||
| 50 | my $cl =$config->{cluster}->{$cluster}; | ||
| 51 | return OK unless $cl; | ||
| 52 | my %machine; | ||
| 53 | |||
| 54 | $machine{ADMIN} =$cluster; | ||
| 55 | my $cc = $cl->{node}; | ||
| 56 | foreach (keys %$cc) { | ||
| 57 | $machine{$_} = $cc->{$_}{address}; | ||
| 58 | } | ||
| 59 | |||
| 60 | my $re = Lemonldap::Cluster::Status->new ( %machine); | ||
| 61 | $re->analyze; | ||
| 62 | my $a=$re->PrintHtml; | ||
| 63 | if ($param{refresh}) { | ||
| 64 | my $t =$param{refresh}; | ||
| 65 | $r->header_out('refresh',$t); | ||
| 66 | |||
| 67 | } | ||
| 68 | $r->content_type('text/html'); | ||
| 69 | $r->send_http_header; | ||
| 70 | $r->print($a); | ||
| 71 | return OK; | ||
| 72 | |||
| 73 | } | ||
| 74 | 1; | ||
| 75 | |||
| 76 |