2013-01-04 08:27:05 +00:00
#
# Monitorix - A lightweight system monitoring tool.
#
2020-02-21 09:36:35 +00:00
# Copyright (C) 2005-2020 by Jordi Sanfeliu <jordi@fibranet.cat>
2013-01-04 08:27:05 +00:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
package lighttpd ;
use strict ;
use warnings ;
use Monitorix ;
use RRDs ;
use LWP::UserAgent ;
use Exporter 'import' ;
our @ EXPORT = qw( lighttpd_init lighttpd_update lighttpd_cgi ) ;
sub lighttpd_init {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ lighttpd = $ config - > { lighttpd } ;
my $ info ;
my @ ds ;
2013-10-24 09:54:36 +01:00
my @ rra ;
2013-01-04 08:27:05 +00:00
my @ tmp ;
my $ n ;
2013-10-24 09:54:36 +01:00
my @ average ;
my @ min ;
my @ max ;
my @ last ;
2013-01-04 08:27:05 +00:00
if ( ! scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ) {
logger ( "$myself: ERROR: missing or not defined 'list' option." ) ;
return 0 ;
}
if ( - e $ rrd ) {
$ info = RRDs:: info ( $ rrd ) ;
for my $ key ( keys %$ info ) {
if ( index ( $ key , 'ds[' ) == 0 ) {
if ( index ( $ key , '.type' ) != - 1 ) {
push ( @ ds , substr ( $ key , 3 , index ( $ key , ']' ) - 3 ) ) ;
}
}
2013-10-24 09:54:36 +01:00
if ( index ( $ key , 'rra[' ) == 0 ) {
if ( index ( $ key , '.rows' ) != - 1 ) {
push ( @ rra , substr ( $ key , 4 , index ( $ key , ']' ) - 4 ) ) ;
}
}
2013-01-04 08:27:05 +00:00
}
if ( scalar ( @ ds ) / 9 != scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ) {
2013-10-24 09:54:36 +01:00
logger ( "$myself: Detected size mismatch between 'list' (" . scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) . ") and $rrd (" . scalar ( @ ds ) / 9 . "). Resizing it accordingly. All historical data will be lost. Backup file created." ) ;
rename ( $ rrd , "$rrd.bak" ) ;
}
2013-11-04 15:51:19 +00:00
if ( scalar ( @ rra ) < 12 + ( 4 * $ config - > { max_historic_years } ) ) {
2013-10-24 09:54:36 +01:00
logger ( "$myself: Detected size mismatch between 'max_historic_years' (" . $ config - > { max_historic_years } . ") and $rrd (" . ( ( scalar ( @ rra ) - 12 ) / 4 ) . "). Resizing it accordingly. All historical data will be lost. Backup file created." ) ;
2013-01-04 08:27:05 +00:00
rename ( $ rrd , "$rrd.bak" ) ;
}
}
if ( ! ( - e $ rrd ) ) {
logger ( "Creating '$rrd' file." ) ;
2013-10-24 09:54:36 +01:00
for ( $ n = 1 ; $ n <= $ config - > { max_historic_years } ; $ n + + ) {
push ( @ average , "RRA:AVERAGE:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ min , "RRA:MIN:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ max , "RRA:MAX:0.5:1440:" . ( 365 * $ n ) ) ;
push ( @ last , "RRA:LAST:0.5:1440:" . ( 365 * $ n ) ) ;
}
2013-01-04 08:27:05 +00:00
for ( $ n = 0 ; $ n < scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ; $ n + + ) {
push ( @ tmp , "DS:lighttpd" . $ n . "_acc:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_kb:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_busy:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_idle:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_val01:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_val02:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_val03:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_val04:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:lighttpd" . $ n . "_val05:GAUGE:120:0:U" ) ;
}
eval {
RRDs:: create ( $ rrd ,
"--step=60" ,
@ tmp ,
"RRA:AVERAGE:0.5:1:1440" ,
"RRA:AVERAGE:0.5:30:336" ,
"RRA:AVERAGE:0.5:60:744" ,
2013-10-24 09:54:36 +01:00
@ average ,
2013-01-04 08:27:05 +00:00
"RRA:MIN:0.5:1:1440" ,
"RRA:MIN:0.5:30:336" ,
"RRA:MIN:0.5:60:744" ,
2013-10-24 09:54:36 +01:00
@ min ,
2013-01-04 08:27:05 +00:00
"RRA:MAX:0.5:1:1440" ,
"RRA:MAX:0.5:30:336" ,
"RRA:MAX:0.5:60:744" ,
2013-10-24 09:54:36 +01:00
@ max ,
2013-01-04 08:27:05 +00:00
"RRA:LAST:0.5:1:1440" ,
"RRA:LAST:0.5:30:336" ,
"RRA:LAST:0.5:60:744" ,
2013-10-24 09:54:36 +01:00
@ last ,
2013-01-04 08:27:05 +00:00
) ;
} ;
my $ err = RRDs:: error ;
if ( $@ || $ err ) {
logger ( "$@" ) unless ! $@ ;
if ( $ err ) {
logger ( "ERROR: while creating $rrd: $err" ) ;
if ( $ err eq "RRDs::error" ) {
logger ( "... is the RRDtool Perl package installed?" ) ;
}
}
return ;
}
}
$ config - > { lighttpd_hist } = ( ) ;
push ( @ { $ config - > { func_update } } , $ package ) ;
logger ( "$myself: Ok" ) if $ debug ;
}
sub lighttpd_update {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ lighttpd = $ config - > { lighttpd } ;
my $ str ;
my $ rrdata = "N" ;
my $ n = 0 ;
foreach ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) {
2014-02-10 10:30:48 +00:00
my $ url = trim ( $ _ ) ;
2014-02-19 17:23:01 +00:00
my $ ssl = "" ;
2014-01-29 17:22:51 +00:00
2014-02-19 17:23:01 +00:00
$ ssl = "ssl_opts => {verify_hostname => 0}"
2014-01-29 17:22:51 +00:00
if lc ( $ config - > { accept_selfsigned_certs } ) eq "y" ;
2014-02-19 17:23:01 +00:00
my $ ua = LWP::UserAgent - > new ( timeout = > 30 , $ ssl ) ;
2016-03-17 08:48:38 +00:00
$ ua - > agent ( $ config - > { user_agent_id } ) if $ config - > { user_agent_id } || "" ;
2013-01-04 08:27:05 +00:00
my $ response = $ ua - > request ( HTTP::Request - > new ( 'GET' , $ url ) ) ;
2013-02-20 14:58:55 +00:00
if ( ! $ response - > is_success ) {
logger ( "$myself: ERROR: Unable to connect to '$url'." ) ;
2020-07-02 11:06:36 +01:00
logger ( "$myself: " . $ response - > status_line ) ;
2013-02-20 14:58:55 +00:00
}
2013-01-04 08:27:05 +00:00
my $ acc = 0 ;
my $ kb = 0 ;
my $ busy = 0 ;
my $ idle = 0 ;
foreach ( split ( '\n' , $ response - > content ) ) {
if ( /^Total Accesses:\s+(\d+)$/ ) {
$ str = $ n . "acc" ;
$ acc = $ 1 - ( $ config - > { lighttpd_hist } - > { $ str } || 0 ) ;
$ acc = 0 unless $ acc != $ 1 ;
$ acc /= 60 ;
$ config - > { lighttpd_hist } - > { $ str } = $ 1 ;
next ;
}
if ( /^Total kBytes:\s+(\d+)$/ ) {
$ str = $ n . "kb" ;
$ kb = $ 1 - ( $ config - > { lighttpd_hist } - > { $ str } || 0 ) ;
$ kb = 0 unless $ kb != $ 1 ;
$ config - > { lighttpd_hist } - > { $ str } = $ 1 ;
next ;
}
if ( /^BusyServers:\s+(\d+)/ ) {
$ busy = int ( $ 1 ) ;
next ;
}
if ( /^IdleServers:\s+(\d+)/ ) {
$ idle = int ( $ 1 ) ;
last ;
}
}
$ rrdata . = ":$acc:$kb:$busy:$idle:0:0:0:0:0" ;
$ n + + ;
}
RRDs:: update ( $ rrd , $ rrdata ) ;
logger ( "$myself: $rrdata" ) if $ debug ;
my $ err = RRDs:: error ;
logger ( "ERROR: while updating $rrd: $err" ) if $ err ;
}
sub lighttpd_cgi {
my ( $ package , $ config , $ cgi ) = @ _ ;
2017-07-31 10:31:06 +01:00
my @ output ;
2013-01-04 08:27:05 +00:00
my $ lighttpd = $ config - > { lighttpd } ;
2014-06-19 10:39:36 +01:00
my @ rigid = split ( ',' , ( $ lighttpd - > { rigid } || "" ) ) ;
my @ limit = split ( ',' , ( $ lighttpd - > { limit } || "" ) ) ;
2013-01-04 08:27:05 +00:00
my $ tf = $ cgi - > { tf } ;
my $ colors = $ cgi - > { colors } ;
my $ graph = $ cgi - > { graph } ;
my $ silent = $ cgi - > { silent } ;
2013-07-29 17:03:13 +01:00
my $ zoom = "--zoom=" . $ config - > { global_zoom } ;
2015-01-26 17:09:39 +00:00
my % rrd = (
'new' = > \ & RRDs:: graphv ,
'old' = > \ & RRDs:: graph ,
) ;
my $ version = "new" ;
my $ pic ;
my $ picz ;
my $ picz_width ;
my $ picz_height ;
2013-01-04 08:27:05 +00:00
my $ u = "" ;
my $ width ;
my $ height ;
2019-05-08 11:54:03 +01:00
my @ extra ;
2013-01-04 08:27:05 +00:00
my @ riglim ;
2016-01-25 17:35:30 +00:00
my @ IMG ;
my @ IMGz ;
2013-01-04 08:27:05 +00:00
my @ tmp ;
my @ tmpz ;
my @ CDEF ;
my $ vlabel = "bytes/s" ;
my $ e ;
my $ e2 ;
my $ n ;
my $ n2 ;
my $ str ;
my $ err ;
2015-01-26 17:09:39 +00:00
$ version = "old" if $ RRDs:: VERSION < 1.3 ;
2013-01-04 08:27:05 +00:00
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ title = $ config - > { graph_title } - > { $ package } ;
2016-01-25 17:35:30 +00:00
my $ IMG_DIR = $ config - > { base_dir } . "/" . $ config - > { imgs_dir } ;
my $ imgfmt_uc = uc ( $ config - > { image_format } ) ;
my $ imgfmt_lc = lc ( $ config - > { image_format } ) ;
2019-05-08 11:54:03 +01:00
foreach my $ i ( split ( ',' , $ config - > { rrdtool_extra_options } || "" ) ) {
push ( @ extra , trim ( $ i ) ) if trim ( $ i ) ;
}
2013-01-04 08:27:05 +00:00
$ title = ! $ silent ? $ title : "" ;
if ( lc ( $ config - > { netstats_in_bps } ) eq "y" ) {
$ vlabel = "bits/s" ;
}
# text mode
#
if ( lc ( $ config - > { iface_mode } ) eq "text" ) {
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , main:: graph_header ( $ title , 2 ) ) ;
push ( @ output , " <tr>\n" ) ;
2020-12-03 08:42:17 +00:00
push ( @ output , " <td>\n" ) ;
2013-01-04 08:27:05 +00:00
}
my ( undef , undef , undef , $ data ) = RRDs:: fetch ( "$rrd" ,
2019-11-22 07:46:02 +00:00
"--resolution=$tf->{res}" ,
2013-01-04 08:27:05 +00:00
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2019-11-22 07:46:02 +00:00
"AVERAGE" ) ;
2013-01-04 08:27:05 +00:00
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while fetching $rrd: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
my $ line1 ;
my $ line2 ;
my $ line3 ;
2017-07-31 10:31:06 +01:00
push ( @ output , " <pre style='font-size: 12px; color: $colors->{fg_color}';>\n" ) ;
push ( @ output , " " ) ;
2013-01-04 08:27:05 +00:00
for ( $ n = 0 ; $ n < scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ; $ n + + ) {
$ line1 = " " ;
$ line2 . = " Acceses k$vlabel Busy Idle" ;
$ line3 . = "------------------------------------" ;
if ( $ line1 ) {
my $ i = length ( $ line1 ) ;
2017-07-31 10:31:06 +01:00
push ( @ output , sprintf ( sprintf ( "%${i}s" , sprintf ( "%s" , trim ( $ ll [ $ n ] ) ) ) ) ) ;
2013-01-04 08:27:05 +00:00
}
}
2017-07-31 10:31:06 +01:00
push ( @ output , "\n" ) ;
push ( @ output , "Time$line2\n" ) ;
push ( @ output , "----$line3 \n" ) ;
2013-01-04 08:27:05 +00:00
my $ line ;
my @ row ;
my $ time ;
my $ n2 ;
my $ from ;
my $ to ;
for ( $ n = 0 , $ time = $ tf - > { tb } ; $ n < ( $ tf - > { tb } * $ tf - > { ts } ) ; $ n + + ) {
$ line = @$ data [ $ n ] ;
$ time = $ time - ( 1 / $ tf - > { ts } ) ;
2017-07-31 10:31:06 +01:00
push ( @ output , sprintf ( " %2d$tf->{tc}" , $ time ) ) ;
2013-01-04 08:27:05 +00:00
for ( $ n2 = 0 ; $ n2 < scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ; $ n2 + + ) {
undef ( @ row ) ;
$ from = $ n2 * 9 ;
$ to = $ from + 9 ;
push ( @ row , @$ line [ $ from .. $ to ] ) ;
2017-07-31 10:31:06 +01:00
push ( @ output , sprintf ( " %7d %9d %3d %3d" , @ row ) ) ;
2013-01-04 08:27:05 +00:00
}
2017-07-31 10:31:06 +01:00
push ( @ output , "\n" ) ;
2013-01-04 08:27:05 +00:00
}
2017-07-31 10:31:06 +01:00
push ( @ output , " </pre>\n" ) ;
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2013-01-04 08:27:05 +00:00
}
2017-07-31 10:31:06 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2013-01-04 08:27:05 +00:00
}
# graph mode
#
if ( $ silent eq "yes" || $ silent eq "imagetag" ) {
$ colors - > { fg_color } = "#000000" ; # visible color for text mode
$ u = "_" ;
}
if ( $ silent eq "imagetagbig" ) {
$ colors - > { fg_color } = "#000000" ; # visible color for text mode
$ u = "" ;
}
for ( $ n = 0 ; $ n < scalar ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) ; $ n + + ) {
for ( $ n2 = 1 ; $ n2 <= 3 ; $ n2 + + ) {
2016-01-25 17:35:30 +00:00
$ str = $ u . $ package . $ n . $ n2 . "." . $ tf - > { when } . ".$imgfmt_lc" ;
push ( @ IMG , $ str ) ;
unlink ( "$IMG_DIR" . $ str ) ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
2016-01-25 17:35:30 +00:00
$ str = $ u . $ package . $ n . $ n2 . "z." . $ tf - > { when } . ".$imgfmt_lc" ;
push ( @ IMGz , $ str ) ;
unlink ( "$IMG_DIR" . $ str ) ;
2013-01-04 08:27:05 +00:00
}
}
}
$ e = 0 ;
foreach my $ url ( my @ ll = split ( ',' , $ lighttpd - > { list } ) ) {
if ( $ e ) {
2017-07-31 10:31:06 +01:00
push ( @ output , " <br>\n" ) ;
2013-01-04 08:27:05 +00:00
}
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , main:: graph_header ( $ title , 2 ) ) ;
2013-01-04 08:27:05 +00:00
}
2014-06-19 10:39:36 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 0 ] , $ limit [ 0 ] ) } ;
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , " <tr>\n" ) ;
2020-12-03 08:42:17 +00:00
push ( @ output , " <td>\n" ) ;
2013-01-04 08:27:05 +00:00
}
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 16:00:45 +01:00
undef ( @ CDEF ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:lighttpd" . $ e . "_idle#4444EE:Idle" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_idle:LAST: Current\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_idle:AVERAGE: Average\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_idle:MIN: Min\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_idle:MAX: Max\\: %3.0lf\\n" ) ;
push ( @ tmp , "AREA:lighttpd" . $ e . "_busy#44EEEE:Busy" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_busy:LAST: Current\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_busy:AVERAGE: Average\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_busy:MIN: Min\\: %3.0lf" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_busy:MAX: Max\\: %3.0lf\\n" ) ;
push ( @ tmp , "LINE1:lighttpd" . $ e . "_idle#0000EE" ) ;
push ( @ tmp , "LINE1:lighttpd" . $ e . "_busy#00EEEE" ) ;
push ( @ tmp , "LINE1:lighttpd" . $ e . "_tot#EE0000" ) ;
push ( @ tmpz , "AREA:lighttpd" . $ e . "_idle#4444EE:Idle" ) ;
push ( @ tmpz , "AREA:lighttpd" . $ e . "_busy#44EEEE:Busy" ) ;
push ( @ tmpz , "LINE2:lighttpd" . $ e . "_idle#0000EE" ) ;
push ( @ tmpz , "LINE2:lighttpd" . $ e . "_busy#00EEEE" ) ;
push ( @ tmpz , "LINE2:lighttpd" . $ e . "_tot#EE0000" ) ;
2013-07-02 16:00:45 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 3]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Workers" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_busy=$rrd:lighttpd" . $ e . "_busy:AVERAGE" ,
"DEF:lighttpd" . $ e . "_idle=$rrd:lighttpd" . $ e . "_idle:AVERAGE" ,
"CDEF:lighttpd" . $ e . "_tot=lighttpd" . $ e . "_busy,lighttpd" . $ e . "_idle,+" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_busy,lighttpd" . $ e . "_idle,lighttpd" . $ e . "_tot,+,+" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
"COMMENT: \\n" ,
@ tmp ,
"COMMENT: \\n" ,
"COMMENT: \\n" ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 3]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 3]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Workers" ,
"--width=$width" ,
"--height=$height" ,
2021-12-21 23:08:14 +00:00
"--full-size-mode" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-26 17:09:39 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_busy=$rrd:lighttpd" . $ e . "_busy:AVERAGE" ,
"DEF:lighttpd" . $ e . "_idle=$rrd:lighttpd" . $ e . "_idle:AVERAGE" ,
"CDEF:lighttpd" . $ e . "_tot=lighttpd" . $ e . "_busy,lighttpd" . $ e . "_idle,+" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_busy,lighttpd" . $ e . "_idle,lighttpd" . $ e . "_tot,+,+" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 3]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
$ e2 = $ e + 1 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /lighttpd$e2/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_a_element ( config = > $ config , IMGz = > $ IMGz [ $ e * 3 ] , IMG = > $ IMG [ $ e * 3 ] ) . "\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-26 17:09:39 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_js_a_element ( width = > $ picz_width , height = > $ picz_height , config = > $ config , IMGz = > $ IMGz [ $ e * 3 ] , IMG = > $ IMG [ $ e * 3 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 3 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2013-01-04 09:40:31 +00:00
2013-01-04 08:27:05 +00:00
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , " </td>\n" ) ;
2020-12-03 08:42:17 +00:00
push ( @ output , " <td class='td-valign-top'>\n" ) ;
2013-01-04 08:27:05 +00:00
}
2014-06-19 10:39:36 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 1 ] , $ limit [ 1 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "AREA:Bytes#44AAEE:KBytes" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_kb:LAST: Current\\: %6.1lf\\n" ) ;
push ( @ tmp , "LINE1:lighttpd" . $ e . "_kb#00EEEE" ) ;
push ( @ tmpz , "AREA:Bytes#44AAEE:Bytes" ) ;
push ( @ tmpz , "LINE1:lighttpd" . $ e . "_kb#00EEEE" ) ;
if ( lc ( $ config - > { netstats_in_bps } ) eq "y" ) {
push ( @ CDEF , "CDEF:Bytes=lighttpd" . $ e . "_kb,8,*,1024,*" ) ;
} else {
push ( @ CDEF , "CDEF:Bytes=lighttpd" . $ e . "_kb,1024,*" ) ;
}
2013-07-02 16:00:45 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 3 + 1]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=$vlabel" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_kb=$rrd:lighttpd" . $ e . "_kb:AVERAGE" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_kb" ,
2013-01-04 08:27:05 +00:00
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 3 + 1]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 3 + 1]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=$vlabel" ,
"--width=$width" ,
"--height=$height" ,
2021-12-21 23:08:14 +00:00
"--full-size-mode" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-26 17:09:39 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_kb=$rrd:lighttpd" . $ e . "_kb:AVERAGE" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_kb" ,
2013-01-04 08:27:05 +00:00
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 3 + 1]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
$ e2 = $ e + 2 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /lighttpd$e2/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_a_element ( config = > $ config , IMGz = > $ IMGz [ $ e * 3 + 1 ] , IMG = > $ IMG [ $ e * 3 + 1 ] ) . "\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-26 17:09:39 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_js_a_element ( width = > $ picz_width , height = > $ picz_height , config = > $ config , IMGz = > $ IMGz [ $ e * 3 + 1 ] , IMG = > $ IMG [ $ e * 3 + 1 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 3 + 1 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
2014-06-19 10:39:36 +01:00
@ riglim = @ { setup_riglim ( $ rigid [ 2 ] , $ limit [ 2 ] ) } ;
2013-01-04 08:27:05 +00:00
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
2013-07-02 16:00:45 +01:00
undef ( @ CDEF ) ;
2013-01-04 08:27:05 +00:00
push ( @ tmp , "AREA:lighttpd" . $ e . "_acc#44EE44:Accesses" ) ;
push ( @ tmp , "GPRINT:lighttpd" . $ e . "_acc:LAST: Current\\: %5.2lf\\n" ) ;
push ( @ tmp , "LINE1:lighttpd" . $ e . "_acc#00EE00" ) ;
push ( @ tmpz , "AREA:lighttpd" . $ e . "_acc#44EE44:Accesses" ) ;
push ( @ tmpz , "LINE1:lighttpd" . $ e . "_acc#00EE00" ) ;
2013-07-02 16:00:45 +01:00
if ( lc ( $ config - > { show_gaps } ) eq "y" ) {
push ( @ tmp , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ tmpz , "AREA:wrongdata#$colors->{gap}:" ) ;
push ( @ CDEF , "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF" ) ;
}
2013-01-04 08:27:05 +00:00
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { small } ) ;
if ( $ silent =~ /imagetag/ ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { remote } ) if $ silent eq "imagetag" ;
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { main } ) if $ silent eq "imagetagbig" ;
@ tmp = @ tmpz ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
push ( @ tmp , "COMMENT: \\n" ) ;
}
2016-01-25 17:35:30 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 3 + 2]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Accesses/s" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2013-07-29 17:03:13 +01:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_acc=$rrd:lighttpd" . $ e . "_acc:AVERAGE" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_acc" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 3 + 2]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2016-01-25 17:35:30 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 3 + 2]" ,
2013-01-04 08:27:05 +00:00
"--title=$config->{graphs}->{_lighttpd3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2016-01-25 17:35:30 +00:00
"--imgformat=$imgfmt_uc" ,
2013-01-04 08:27:05 +00:00
"--vertical-label=Accesses/s" ,
"--width=$width" ,
"--height=$height" ,
2021-12-21 23:08:14 +00:00
"--full-size-mode" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2013-01-04 08:27:05 +00:00
@ riglim ,
2015-01-26 17:09:39 +00:00
$ zoom ,
2013-01-04 08:27:05 +00:00
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:lighttpd" . $ e . "_acc=$rrd:lighttpd" . $ e . "_acc:AVERAGE" ,
2013-07-02 16:00:45 +01:00
"CDEF:allvalues=lighttpd" . $ e . "_acc" ,
@ CDEF ,
2013-01-04 08:27:05 +00:00
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-31 10:31:06 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 3 + 2]: $err\n" ) if $ err ;
2013-01-04 08:27:05 +00:00
}
$ e2 = $ e + 3 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /lighttpd$e2/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_a_element ( config = > $ config , IMGz = > $ IMGz [ $ e * 3 + 2 ] , IMG = > $ IMG [ $ e * 3 + 2 ] ) . "\n" ) ;
2015-02-12 15:27:03 +00:00
} else {
2015-01-26 17:09:39 +00:00
if ( $ version eq "new" ) {
$ picz_width = $ picz - > { image_width } * $ config - > { global_zoom } ;
$ picz_height = $ picz - > { image_height } * $ config - > { global_zoom } ;
} else {
$ picz_width = $ width + 115 ;
$ picz_height = $ height + 100 ;
}
2021-12-22 00:24:55 +00:00
push ( @ output , " " . picz_js_a_element ( width = > $ picz_width , height = > $ picz_height , config = > $ config , IMGz = > $ IMGz [ $ e * 3 + 2 ] , IMG = > $ IMG [ $ e * 3 + 2 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 3 + 2 ] ) . "\n" ) ;
2013-01-04 08:27:05 +00:00
}
}
if ( $ title ) {
2017-07-31 10:31:06 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , " <tr>\n" ) ;
push ( @ output , " <td bgcolor='$colors->{title_bg_color}' colspan='2'>\n" ) ;
push ( @ output , " <font face='Verdana, sans-serif' color='$colors->{title_fg_color}'>\n" ) ;
push ( @ output , " <font size='-1'>\n" ) ;
push ( @ output , " <b> <a href='" . trim ( $ url ) . "' style='color: " . $ colors - > { title_fg_color } . "'>" . trim ( $ url ) . "</a></b>\n" ) ;
push ( @ output , " </font></font>\n" ) ;
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2013-01-04 08:27:05 +00:00
}
$ e + + ;
}
2017-07-31 10:31:06 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2013-01-04 08:27:05 +00:00
}
1 ;