]>
git.ipfire.org Git - people/mfischer/ipfire-2.x.git/blob - src/wio/wio-graphs.pl
3 ###############################################################################
5 # IPFire.org - A linux based firewall #
6 # Copyright (C) 2017-2018 Stephan Feddersen <sfeddersen@ipfire.org> #
7 # All Rights Reserved. #
9 # This program is free software: you can redistribute it and/or modify #
10 # it under the terms of the GNU General Public License as published by #
11 # the Free Software Foundation, either version 3 of the License, or #
12 # (at your option) any later version. #
14 # This program is distributed in the hope that it will be useful, #
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17 # GNU General Public License for more details. #
19 # You should have received a copy of the GNU General Public License #
20 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
22 ###############################################################################
24 # Version: 2017/07/11 21:32:23
26 # This wio-graphs.pl is based on the Code from the IPCop WIO Addon
27 # and is extremly adapted to work with IPFire.
29 # Autor: Stephan Feddersen
30 # Co-Autor: Alexander Marx
37 # enable only the following on debugging purpose
42 require '/var/ipfire/general-functions.pl';
43 require '/var/ipfire/lang.pl';
45 my ( %mainsettings, %color ) = ();
47 &General
::readhash
('/var/ipfire/main/settings', \
%mainsettings);
48 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
58 push @rrd, @
{&header
($period, "$hostname ($Lang::tr{$period})")};
59 push @rrd, @
{&body
($hostid)};
63 my $error = RRDs
::error
;
64 print "Error in RRD::graph for Who Is Online: $error\n" if $error;
71 push @
$result, "DEF:mode=/var/log/rrd/wio/$hostid.rrd:mode:AVERAGE";
72 push @
$result, "CDEF:online=mode,UN,0,mode,IF,50,GT,100,0,IF";
73 push @
$result, "CDEF:offline=mode,UN,100,mode,IF,50,LT,100,0,IF";
74 push @
$result, "AREA:online".$color{"color12"}.":$Lang::tr{'wio up'}\\j";
75 push @
$result, "AREA:offline".$color{"color13"}.":$Lang::tr{'wio down'}\\j";
76 push @
$result, "COMMENT:\r<span size='smaller'>$Lang::tr{'wio_last_update'}\\: ". lastupdate
(scalar localtime()) ."</span>\\r";
84 return undef if not defined $text;
96 push @
$result, ("--title", "$title");
97 push @
$result, ("--start", "-1$period", "-aPNG", "-i", "-z");
98 push @
$result, ("--border", "0");
99 push @
$result, ("--full-size-mode");
100 push @
$result, ("--slope-mode");
101 push @
$result, ("--pango-markup");
102 push @
$result, ("--alt-y-grid", "-w 910", "-h 300");
103 if ( $period eq 'day' ) { push @
$result, ("--x-grid", "MINUTE:30:HOUR:1:HOUR:2:0:%H:%M"); }
104 push @
$result, ("--color", "SHADEA".$color{"color19"});
105 push @
$result, ("--color", "SHADEB".$color{"color19"});
106 push @
$result, ("--color", "BACK".$color{"color21"});
113 print "<table width='100%' cellspacing='0'>";
115 print "<td align='center' bgcolor='".$color{"color20"}."'><a href='".$_[0]."?".$_[1]."?hour?".$_[3]."' target='".$_[1]."box'><b>".$Lang::tr
{'hour'}."</b></a></td>";
116 print "<td align='center' bgcolor='".$color{"color20"}."'><a href='".$_[0]."?".$_[1]."?day?".$_[3]."' target='".$_[1]."box'><b>".$Lang::tr
{'day'}."</b></a></td>";
117 print "<td align='center' bgcolor='".$color{"color20"}."'><a href='".$_[0]."?".$_[1]."?week?".$_[3]."' target='".$_[1]."box'><b>".$Lang::tr
{'week'}."</b></a></td>";
118 print "<td align='center' bgcolor='".$color{"color20"}."'><a href='".$_[0]."?".$_[1]."?month?".$_[3]."' target='".$_[1]."box'><b>".$Lang::tr
{'month'}."</b></a></td>";
119 print "<td align='center' bgcolor='".$color{"color20"}."'><a href='".$_[0]."?".$_[1]."?year?".$_[3]."' target='".$_[1]."box'><b>".$Lang::tr
{'year'}."</b></a></td>";
122 print "<table width='100%' cellspacing='0'>";
123 print "<tr><td align='center' colspan='8'> </td></tr>";
124 print "<tr><td align='center' colspan='8'><iframe class='graph' src='".$_[0]."?".$_[1]."?".$_[2]."?".$_[3]."' scrolling='no' marginheight='0' frameborder='no' name='".$_[1]."box'></iframe></td></tr>";