[Date Prev]   [Date Next] [Thread Prev]   [Thread Next] [Date Index]   [Thread Index]

 

     Re: [nocol-users] genweb.pl & background color

Hi,

thanks for all tips about changing the background color.
The best solution (without to much work :-)) so far is John Stumles
patch for genweb.pl, it doesn't change the background color but it's
shows very clear when there is a problem. 


Regards Stefan Johansson


John Stumbles wrote:
> 
> On Wed, 8 Mar 2000, Stefan Johansson wrote:
> 
> > Hi,
> >
> > I would like to change the background color in the
> > warning|error|critical.html files
> > in case of a monitored deviced goes down ...
> 
>         this will only make any sense in the warning and error displays:
> in critical _everything_ will be red (or whatever colour you choose). This
> colour-state mapping feature would be more useful, IMO, for the info page,
> but that is not currently generated as a table and will be slightly more
> work to implement (and I'm supposed to be doing 101 other things right now
> :-)
> 
> > Have anyone done this ?
> > If you have, I would be very interested :-)
> 
> (On Friday I posted a rather unsatisfactory solution, in that
> the text colours were practically unreadable against the red background of
> critical devices.) Here is a replacement for sub print_row which sets
> both background and text colours according to device state. BTW my copy of
> genweb may be rather old: I'm running 4.2.2beta1
> 
> #------------------------------------------------------------
> ## Write out one row of data.
> #  Alternates the row colors. Also, if the event is new (less than 5 minutes
> #  old), it sets the button background to yellow.
> #  If $lvl is 'Info', then does not write out in table format so that the
> #  size of the data file is small.
> #
> sub print_row
> {
>     my  ($i, $lvl) = @_;
>     my  $ifnewbg = '';  # new background if new event
> 
>     my  $cnt = $cnt{$lvl};      # the row count
>     my  $RED    =   '#FF0000';
>     my  $ORANGE =   '#FF9900';
>     my  $YELLOW =   '#FFFF00';
>     my  $BLACK  =   '#000000';
>     my  $WHITE  =   '#FFFFFF';
>     my  $GREY   =   '#AAAAAA';
>     my  (@rowcolor) = (
>                 $RED,       #   1       critcal
>                 $ORANGE,        #       2       error
>                 $YELLOW,        #       3       warning
>         );      # row colours for different severities
>     my  (@textcolour) = (
>                 "$WHITE",       #       1       critcal
>                 "$BLACK",       #       2       error
>                 "$BLACK",       #       3       warning
>         );      # row colours for different severities
> 
>     my  $thispage   = "${baseurl}${lvl}.html";
>     my  $action     = $levels[$ilevels{$lvl}];
>     my  $ADMINMODE  = ($lvl eq "User") ? 0 : 1;  # No href links for userPage
> 
>     # the data is already clean since the new nocollib.pl uses 'A' to unpack
>     # which strips out all the nulls.
>     # &clean_data($i);  # delete unwanted characters (not needed anymore)
> 
>     my  $update = ($updates{"$sitename{$i}:$siteaddr{$i}:$varname{$i}"} or '') ;
>     #if ($update eq "") {$update = $updates{"$sitename{$i}:$siteaddr{i}"}; }
>     #if ($update eq "") {$update = $updates{"$sitename{$i}"}; }
> 
>     # hide if Critical display
>     return if $update =~ /^\(H\)/ && $action eq 'Critical';
> 
>     my  $siteHREF = qq(<A HREF="$processor?displaylevel=$action);
>     $siteHREF .= "&sitename=$sitename{$i}&siteaddr=$siteaddr{$i}";
>     $siteHREF .= "&variable=$varname{$i}&sender=$sender{$i}";
>     $siteHREF .= qq(&command=Updates&return=$thispage">);
> 
>     if ($compactInfo && ($lvl eq "Info"))
>     {
>         # need to put the href in front of the sitename, but we dont want
>         # the sitename to be prepended with underlined blanks. i.e. convert
>         #   '<a href="xx">   site</a>'  INTO  '  <a href="xx">site</a>'
>         my  $site   = sprintf "%14.14s", $sitename{$i}; # printing size
>         $site =~ s|(\S+)|$siteHREF$1| ;
>         $site .= "</a>";
>         printf "%3d %1.1s  %s %-15.15s  %12.12s= %-8lu %02d/%02d %02d:%02d %s\n",
>             $cnt, $levels[$severity{$i}], $site,
>             $siteaddr{$i}, $varname{$i}, $varvalue{$i},
>             $mon{$i},$day{$i},$hour{$i},$z1[$min{$i}], $update;
>         return;
>     }
> 
>     ## see if this is a recent event (less than 5 minutes old)
>     if ($mon == $mon{$i} && $mday == $day{$i} &&
>       (($hour * 60) + $min) - (($hour{$i} * 60) + $min{$i}) < $neweventAge)
>     {
>         ++$newevents{$lvl};                     # total displayed in Messages
>         $ifnewbg = "bgcolor=yellow";    # background of the little button
>     }
> 
>     # construct a <font face=... size=... color=...> tag, with colour to contrast with row colour for this severity level
>     my  $font_tag   = sprintf qq (<font face="arial,helvetica" size="%s" color="%s">), $tfontsize, $textcolour[$severity{$i}-1] ;
> 
>     my  $tdstart    = qq(<td nowrap align="left">$font_tag &nbsp;) ,
> 
>     my  $tdend  = qq(</font> </td>
> <td bgcolor="$GREY" width=1><img src="${emptyimg}" alt="&nbsp;"></td>\n);
> 
>     ## begin the row of data
>     #   ser-no  severity  sitename  address  variable+value
> 
>     print qq(<TR bgcolor="$rowcolor[$severity{$i}-1]">\n);
> 
>     print "<td $ifnewbg><font>";
>     if ($ADMINMODE) { print "$siteHREF"; }
>     print qq(<img src="$level_imgs[$severity{$i}]" alt="" border="0">);
>     if ($ADMINMODE) { print "</a>"; }
>     print $tdend;
> 
>     my  $siteName   = $sitename{$i};
>     if ($ADMINMODE)
>     {
>         $siteHREF =~ s/command\=Updates/command\=SiteHelp/;  # change the command
> #        $siteName = "sprintf qq(%s<font color="%s">%s</font></a>), $siteHREF, $tfontcolour ,$sitename{$i} ;
>         $siteName = $siteHREF . $font_tag . $sitename{$i} . '</font></a>' ;
>     }
> 
>     print <<EoRow ;
> $tdstart $cnt $tdend
> $tdstart $levels[$severity{$i}]  $tdend
> $tdstart $siteName $tdend
> $tdstart $siteaddr{$i} $tdend
> <td nowrap align=right>$font_tag
> &nbsp; $varname{$i}= $varvalue{$i} &nbsp;
> $tdend
> <td nowrap align=right $ifnewbg>$font_tag
> $mon{$i}/$day{$i} $hour{$i}:$z1[$min{$i}]  $tdend
> EoRow
> 
>     if ($ADMINMODE || $userViewUpdates) {print "$tdstart $update $tdend"; }
>     print "</tr>";      # end of row
> }       # printline()
> 
> regards,
> 
> --
> John Stumbles                                      j.d.stumbles@reading.ac.uk
> I.T. Services Centre,   University of Reading  http://www.rdg.ac.uk/~visstmbl
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>           Press any key to continue or any other key to quit.

--
Stefan Johansson                 Net Insight AB
stefan.johansson@netinsight.net  Box 42093, SE-126 14 STOCKHOLM, SWEDEN
Phone:  +46-8-685 04 81          Visiting address: Västberga Allé 9
Fax:    +46-8-685 04 20          http://www.netinsight.net