3
# faimond-gui: graphical FAI monitor daemon
5
# This script is part of FAI (Fully Automatic Installation)
6
# Copyright (C) 2007 Thomas Lange, lange@informatik.uni-koeln.de
7
# Universitaet zu Koeln
9
#*********************************************************************
10
# This program is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation; either version 2 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful, but
16
# WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
# General Public License for more details.
20
# A copy of the GNU General Public License is available as
21
# '/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
22
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
23
# can also obtain it by writing to the Free Software Foundation, Inc.,
24
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#*********************************************************************
27
# TODO: Add support for TASKERROR
35
$icondir='/usr/share/fai/pixmaps';
37
#@tasklist = qw/hostname confdir defclass action partition mountdisks extrbase mirror debconf prepareapt instsoft configure chboot savelog faiend reboot/;
38
@tasklist = qw/hostname confdir defclass partition extrbase debconf instsoft configure savelog faiend reboot/;
39
$tasklist[0] = ' 'x15 . 'hostname'. ' 'x15;
42
%message = ( 'TASKBEGIN' => 'BEG', 'TASKEND' => 'END', 'REBOOT' => 'reboot');
44
# - - - - - - - - - - - - - - - - - -
48
return 0 if $line =~/^FAI monitoring daemon start/; # ignore start up messages from faimond
49
warn "INPUT received $line" if $debug;
53
# - - - - - - - - - - - - - - - - - -
59
$icon{'success'} = $top->Photo(-file=>"$icondir/ok.gif");
60
$icon{'fail'} = $top->Photo(-file=>"$icondir/fail.gif");
61
$icon{'minor'} = $top->Photo(-file=>"$icondir/minor.gif");
62
$icon{'warning'} = $top->Photo(-file=>"$icondir/warning.gif");
63
$icon{'fail'} = $top->Photo(-file=>"$icondir/fail.gif");
64
$icon{'begin'} = $top->Photo(-file=>"$icondir/begin.gif");
65
$icon{'host'} = $top->Photo(-file=>"$icondir/bar.gif");
67
$defstyle = $hlist->ItemStyle("imagetext",
68
-foreground => $forecolor,
69
-background => $backcolor,
73
$headerstyle = $hlist->ItemStyle("imagetext",
80
# $balloonstatus = $top->Balloon();
81
# $balloonstatus->attach($top,-msg=>"status",-balloonposition=>"mouse");
83
# - - - - - - - - - - - - - - - - - -
86
my ($host,$task,$iname) = @_;
88
$hlist->itemCreate($row{$host}, $task{$task}, -text=>'' ,-itemtype=>"imagetext",-image=>$icon{$iname});
89
$hlist->itemConfigure($row{$host}, $task{$task}, -itemtype=>"imagetext",-style=>$defstyle);
91
# - - - - - - - - - - - - - - - - - -
95
my ($host,$startstop,$task,$code) = split(/\s+/,$str);
97
warn "hostentry: $host $startstop $task $code\n" if $debug;
99
unless (exists $row{$host}) {
100
# add host, first column
101
$row{$host} = $rowcount++;
103
$hlist->add($row{$host},-state=>"disabled");
104
$hlist->itemCreate($row{$host}, 0,
105
-itemtype => "imagetext",
107
-style=>$headerstyle,
108
-image=>$icon{'host'});
111
# remove old information when doing an reinstallation
112
if ($startstop eq 'check') {
113
foreach (1 .. $#tasklist) {
114
warn "XXX $row{$host} X $_\n" if $debug;
115
$hlist->itemCreate($row{$host}, $_, -text => '');
120
warn "create: $row{$host} X $task{$task} X $startstop $message{$startstop} $code\n" if $debug;
121
unless (exists $task{$task}) {
122
# do not show unknown tasks
126
$message = ($startstop =~ /TASKEND/) ? $message="$message{$startstop} $code": $message{$startstop};
128
($message eq 'BEG') && icon($host,$task,'begin');
129
if ($message =~ /END (\d+)/) {
130
$ret = $1; # save error code
131
($ret == 0) && icon($host,$task,'success');
132
# here we can add different icons for different error codes
133
($ret != 0) && icon($host,$task,'fail');
137
# - - - - - - - - - - - - - - - - - -
140
open(INP, "<$ARGV[0]") or die "Can't open input file. $@";
142
$backcolor="#76716f";
143
$forecolor="#ffffff";
144
$headercolor="#ffffff";
147
$top = new MainWindow;
148
#$top->configure(-background=> $backcolor);
149
$hlist = $top->Scrolled("HList",
151
-columns => $#tasklist+1,
155
-selectbackground => $backcolor,
156
-background=> $backcolor,
157
-selectborderwidth=>0,
158
-selectmode=>'single',
159
-highlightthickness=>0,
162
)->pack(-expand => 1, -fill => 'both');
165
$top->fileevent(INP,'readable', [\&getinp]);
167
foreach (@tasklist) {
168
$hlist->header('create', $n++, -text => $_,
169
-headerbackground=>"#aabbcc",
172
$task{$_} = $tcounter++;