2016-04-08 09:43:58 +01:00
#
# Monitorix - A lightweight system monitoring tool.
#
2022-01-12 09:26:58 +00:00
# Copyright (C) 2005-2022 by Jordi Sanfeliu <jordi@fibranet.cat>
2016-04-08 09:43:58 +01: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 chrony ;
use strict ;
use warnings ;
use Monitorix ;
use RRDs ;
use Exporter 'import' ;
our @ EXPORT = qw( chrony_init chrony_update chrony_cgi ) ;
sub chrony_init {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ chrony = $ config - > { chrony } ;
my $ info ;
my @ ds ;
my @ rra ;
my @ tmp ;
my $ n ;
my @ average ;
my @ min ;
my @ max ;
my @ last ;
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 ) ) ;
}
}
if ( index ( $ key , 'rra[' ) == 0 ) {
if ( index ( $ key , '.rows' ) != - 1 ) {
push ( @ rra , substr ( $ key , 4 , index ( $ key , ']' ) - 4 ) ) ;
}
}
}
if ( scalar ( @ ds ) / 14 != scalar ( my @ il = split ( ',' , $ chrony - > { list } ) ) ) {
logger ( "$myself: Detected size mismatch between 'list' (" . scalar ( my @ il = split ( ',' , $ chrony - > { list } ) ) . ") and $rrd (" . scalar ( @ ds ) / 14 . "). Resizing it accordingly. All historical data will be lost. Backup file created." ) ;
rename ( $ rrd , "$rrd.bak" ) ;
}
if ( scalar ( @ rra ) < 12 + ( 4 * $ config - > { max_historic_years } ) ) {
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." ) ;
rename ( $ rrd , "$rrd.bak" ) ;
}
}
if ( ! ( - e $ rrd ) ) {
logger ( "Creating '$rrd' file." ) ;
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 ) ) ;
}
for ( $ n = 0 ; $ n < scalar ( my @ il = split ( ',' , $ chrony - > { list } ) ) ; $ n + + ) {
push ( @ tmp , "DS:chrony" . $ n . "_stratum:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_loffset:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_rmsoffs:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_freq:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_rfreq:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_skew:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_rootdel:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_rootdis:GAUGE:120:U:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_upintvl:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_val01:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_val02:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_val03:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ n . "_val04:GAUGE:120:0:U" ) ;
push ( @ tmp , "DS:chrony" . $ 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" ,
@ average ,
"RRA:MIN:0.5:1:1440" ,
"RRA:MIN:0.5:30:336" ,
"RRA:MIN:0.5:60:744" ,
@ min ,
"RRA:MAX:0.5:1:1440" ,
"RRA:MAX:0.5:30:336" ,
"RRA:MAX:0.5:60:744" ,
@ max ,
"RRA:LAST:0.5:1:1440" ,
"RRA:LAST:0.5:30:336" ,
"RRA:LAST:0.5:60:744" ,
@ last ,
) ;
} ;
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 ;
}
}
push ( @ { $ config - > { func_update } } , $ package ) ;
logger ( "$myself: Ok" ) if $ debug ;
}
sub chrony_update {
my $ myself = ( caller ( 0 ) ) [ 3 ] ;
my ( $ package , $ config , $ debug ) = @ _ ;
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ chrony = $ config - > { chrony } ;
my $ n ;
my $ rrdata = "N" ;
my $ e = 0 ;
foreach ( my @ cl = split ( ',' , $ chrony - > { list } ) ) {
my $ stratum = 0 ;
my $ loffset = 0 ;
my $ rmsoffs = 0 ;
my $ freq = 0 ;
my $ rfreq = 0 ;
my $ skew = 0 ;
my $ rootdel = 0 ;
my $ rootdis = 0 ;
my $ upintvl = 0 ;
my $ val01 = 0 ;
my $ val02 = 0 ;
my $ val03 = 0 ;
my $ val04 = 0 ;
my $ val05 = 0 ;
my $ data ;
my ( $ host , $ port ) = split ( ':' , $ cl [ $ e ] || "" ) ;
$ port = "" if ! $ port ;
$ port = "-p $port" if $ port ;
my $ cmd = "chronyc -n -h $host $port tracking" ;
if ( open ( EXEC , "$cmd |" ) ) {
while ( <EXEC> ) { $ data . = $ _ ; }
close ( EXEC ) ;
}
if ( ! $ data ) {
logger ( "$myself: unable to execute '" . $ cmd . "' command or invalid connection." ) ;
$ rrdata . = ":$stratum:$loffset:$rmsoffs:$freq:$rfreq:$skew:$rootdel:$rootdis:$upintvl:0:0:0:0:0" ;
next ;
}
foreach ( my @ l = split ( '\n' , $ data ) ) {
if ( /^Stratum\s*:\s*(\d+)$/ ) {
$ stratum = $ 1 ;
}
if ( /^Last offset\s*:\s*(-?\d+\.\d+)\s+/ ) {
$ loffset = $ 1 ;
}
if ( /^RMS offset\s*:\s*(-?\d+\.\d+)\s+/ ) {
$ rmsoffs = $ 1 ;
}
if ( /^Frequency\s*:\s*(-?\d+\.\d+)\s+/ ) {
$ freq = $ 1 ;
}
if ( /^Residual freq\s*:\s*(-?\d+\.\d+)\s+/ ) {
$ rfreq = $ 1 ;
}
if ( /^Skew\s*:\s*(-?\d+\.\d+)\s+/ ) {
$ skew = $ 1 ;
}
if ( /^Root delay\s*:\s*(\d+\.\d+)\s+/ ) {
$ rootdel = $ 1 ;
}
if ( /^Root dispersion\s*:\s*(\d+\.\d+)\s+/ ) {
$ rootdis = $ 1 ;
}
if ( /^Update interval\s*:\s*(\d+\.\d+)\s+/ ) {
$ upintvl = $ 1 ;
}
}
$ rrdata . = ":$stratum:$loffset:$rmsoffs:$freq:$rfreq:$skew:$rootdel:$rootdis:$upintvl:0:0:0:0:0" ;
$ e + + ;
}
RRDs:: update ( $ rrd , $ rrdata ) ;
logger ( "$myself: $rrdata" ) if $ debug ;
my $ err = RRDs:: error ;
logger ( "ERROR: while updating $rrd: $err" ) if $ err ;
}
sub chrony_cgi {
my ( $ package , $ config , $ cgi ) = @ _ ;
2017-07-24 11:05:02 +01:00
my @ output ;
2016-04-08 09:43:58 +01:00
my $ chrony = $ config - > { chrony } ;
my @ rigid = split ( ',' , ( $ chrony - > { rigid } || "" ) ) ;
my @ limit = split ( ',' , ( $ chrony - > { limit } || "" ) ) ;
my $ tf = $ cgi - > { tf } ;
my $ colors = $ cgi - > { colors } ;
my $ graph = $ cgi - > { graph } ;
my $ silent = $ cgi - > { silent } ;
my $ zoom = "--zoom=" . $ config - > { global_zoom } ;
my % rrd = (
'new' = > \ & RRDs:: graphv ,
'old' = > \ & RRDs:: graph ,
) ;
my $ version = "new" ;
2022-01-12 09:26:58 +00:00
my @ full_size_mode ;
2016-04-08 09:43:58 +01:00
my $ pic ;
my $ picz ;
my $ picz_width ;
my $ picz_height ;
my $ u = "" ;
my $ width ;
my $ height ;
2019-05-08 11:54:03 +01:00
my @ extra ;
2016-04-08 09:43:58 +01:00
my @ riglim ;
my @ IMG ;
my @ IMGz ;
my @ tmp ;
my @ tmpz ;
my @ CDEF ;
my $ e ;
my $ e2 ;
my $ n ;
my $ n2 ;
my $ str ;
my $ err ;
$ version = "old" if $ RRDs:: VERSION < 1.3 ;
2022-01-12 09:26:58 +00:00
push ( @ full_size_mode , "--full-size-mode" ) if $ RRDs:: VERSION > 1.3 ;
2016-04-08 09:43:58 +01:00
my $ rrd = $ config - > { base_lib } . $ package . ".rrd" ;
my $ title = $ config - > { graph_title } - > { $ package } ;
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 ) ;
}
2016-04-08 09:43:58 +01:00
$ title = ! $ silent ? $ title : "" ;
# text mode
#
if ( lc ( $ config - > { iface_mode } ) eq "text" ) {
if ( $ title ) {
2017-07-24 11:05:02 +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" ) ;
2016-04-08 09:43:58 +01:00
}
my ( undef , undef , undef , $ data ) = RRDs:: fetch ( "$rrd" ,
2019-11-22 07:46:02 +00:00
"--resolution=$tf->{res}" ,
2016-04-08 09:43:58 +01:00
"--start=-$tf->{nwhen}$tf->{twhen}" ,
2019-11-22 07:46:02 +00:00
"AVERAGE" ) ;
2016-04-08 09:43:58 +01:00
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while fetching $rrd: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
my $ line1 ;
my $ line2 ;
2017-07-24 11:05:02 +01:00
push ( @ output , " <pre style='font-size: 12px; color: $colors->{fg_color}';>\n" ) ;
push ( @ output , " " ) ;
2016-04-08 09:43:58 +01:00
for ( $ n = 0 ; $ n < scalar ( my @ pl = split ( ',' , $ chrony - > { list } ) ) ; $ n + + ) {
$ line1 . = " LastOffset RMS_Offset Root_Delay RootDisper Stra Frequency Skew UpIntvl" ;
$ line2 . = "------------------------------------------------------------------------------------" ;
if ( $ line2 ) {
my $ i = length ( $ line2 ) ;
2017-07-24 11:05:02 +01:00
push ( @ output , sprintf ( sprintf ( "%${i}s" , sprintf ( "%s" , trim ( $ pl [ $ n ] ) ) ) ) ) ;
2016-04-08 09:43:58 +01:00
}
}
2017-07-24 11:05:02 +01:00
push ( @ output , "\n" ) ;
push ( @ output , "Time$line1\n" ) ;
push ( @ output , "----$line2 \n" ) ;
2016-04-08 09:43:58 +01: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-24 11:05:02 +01:00
push ( @ output , sprintf ( " %2d$tf->{tc}" , $ time ) ) ;
2016-04-08 09:43:58 +01:00
for ( $ n2 = 0 ; $ n2 < scalar ( my @ pl = split ( ',' , $ chrony - > { list } ) ) ; $ n2 + + ) {
undef ( @ row ) ;
2021-01-07 09:59:37 +00:00
$ from = $ n2 * 14 ;
$ to = $ from + 14 ;
2016-04-08 09:43:58 +01:00
my ( $ stratum , $ loffset , $ rmsoffs , $ freq , $ rfreq , $ skew , $ rootdel , $ rootdis , $ upintvl ) = @$ line [ $ from .. $ to ] ;
2017-07-24 11:05:02 +01:00
push ( @ output , sprintf ( " % 9.8f %9.8f %8.6f %8.6f %2.0f %6.3f %5.3f %7.1f" , $ loffset || 0 , $ rmsoffs || 0 , $ rootdel || 0 , $ rootdis || 0 , $ stratum || 0 , $ freq || 0 , $ skew || 0 , $ upintvl || 0 ) ) ;
2016-04-08 09:43:58 +01:00
}
2017-07-24 11:05:02 +01:00
push ( @ output , "\n" ) ;
2016-04-08 09:43:58 +01:00
}
2017-07-24 11:05:02 +01:00
push ( @ output , " </pre>\n" ) ;
2016-04-08 09:43:58 +01:00
if ( $ title ) {
2017-07-24 11:05:02 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2016-04-08 09:43:58 +01:00
}
2017-07-24 11:05:02 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2016-04-08 09:43:58 +01: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 @ cl = split ( ',' , $ chrony - > { list } ) ) ; $ n + + ) {
for ( $ n2 = 1 ; $ n2 <= 6 ; $ n2 + + ) {
$ str = $ u . $ package . $ n . $ n2 . "." . $ tf - > { when } . ".$imgfmt_lc" ;
push ( @ IMG , $ str ) ;
unlink ( "$IMG_DIR" . $ str ) ;
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
$ str = $ u . $ package . $ n . $ n2 . "z." . $ tf - > { when } . ".$imgfmt_lc" ;
push ( @ IMGz , $ str ) ;
unlink ( "$IMG_DIR" . $ str ) ;
}
}
}
2022-02-28 16:13:20 +00:00
$ e = $ e2 = 0 ;
2016-04-08 09:43:58 +01:00
foreach my $ url ( my @ cl = split ( ',' , $ chrony - > { list } ) ) {
my $ data ;
my ( $ host , $ port ) = split ( ':' , $ cl [ $ e ] || "" ) ;
$ port = "" if ! $ port ;
$ port = "-p $port" if $ port ;
my $ cmd = "chronyc -n -h $host $port tracking" ;
if ( open ( EXEC , "$cmd |" ) ) {
while ( <EXEC> ) { $ data . = $ _ ; }
close ( EXEC ) ;
}
next if ! $ data ;
my $ freq_status = "" ;
my $ leap_status = "" ;
foreach ( my @ l = split ( '\n' , $ data ) ) {
if ( /^Frequency\s*:\s*-?\d+\.\d+\s+ppm\s+(.*?)$/ ) {
$ freq_status = trim ( $ 1 ) ;
next ;
}
if ( /^Leap status\s*:\s*(.*?)$/ ) {
$ leap_status = trim ( $ 1 ) ;
next ;
}
}
if ( $ RRDs:: VERSION > 1.2 ) {
$ leap_status = "COMMENT: Leap status\\: $leap_status\\c" ,
} else {
$ leap_status = "COMMENT: Leap status: $leap_status\\c" ,
}
my $ driver = "" ;
my $ timeleft = "" ;
my $ temp_scale = "" ;
if ( $ e ) {
2017-07-24 11:05:02 +01:00
push ( @ output , " <br>\n" ) ;
2016-04-08 09:43:58 +01:00
}
if ( $ title ) {
2017-07-24 11:05:02 +01:00
push ( @ output , main:: graph_header ( $ title , 2 ) ) ;
2016-04-08 09:43:58 +01:00
}
@ riglim = @ { setup_riglim ( $ rigid [ 0 ] , $ limit [ 0 ] ) } ;
if ( $ title ) {
2017-07-24 11:05:02 +01:00
push ( @ output , " <tr>\n" ) ;
2020-12-03 08:42:17 +00:00
push ( @ output , " <td class='td-valign-top'>\n" ) ;
2016-04-08 09:43:58 +01:00
}
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:loffset#44EEEE:Last offset" ) ;
2016-04-11 09:44:04 +01:00
push ( @ tmp , "GPRINT:loffset:LAST:Cur\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:loffset:AVERAGE:Avg\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:loffset:MIN:Min\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:loffset:MAX:Max\\:% 9.8lf\\n" ) ;
2016-04-08 09:43:58 +01:00
push ( @ tmp , "LINE2:rmsoffs#44EE44:RMS offset" ) ;
2016-04-11 09:44:04 +01:00
push ( @ tmp , "GPRINT:rmsoffs:LAST: Cur\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:rmsoffs:AVERAGE:Avg\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:rmsoffs:MIN:Min\\:% 9.8lf" ) ;
push ( @ tmp , "GPRINT:rmsoffs:MAX:Max\\:% 9.8lf\\n" ) ;
2016-04-08 09:43:58 +01:00
push ( @ tmpz , "LINE2:loffset#44EEEE:Last offset" ) ;
push ( @ tmpz , "LINE2:rmsoffs#44EE44:RMS offset" ) ;
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" ) ;
}
( $ 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 ;
}
2022-02-28 16:13:20 +00:00
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6]" ,
2016-04-08 09:43:58 +01:00
"--title=$config->{graphs}->{_chrony1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:loffset=$rrd:chrony" . $ e . "_loffset:AVERAGE" ,
"DEF:rmsoffs=$rrd:chrony" . $ e . "_rmsoffs:AVERAGE" ,
"CDEF:allvalues=loffset,rmsoffs,+" ,
@ CDEF ,
"COMMENT: \\n" ,
@ tmp ,
"COMMENT: \\n" ,
$ leap_status ,
"COMMENT: \\n" ) ;
$ err = RRDs:: error ;
2022-02-28 16:13:20 +00:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
2022-02-28 16:13:20 +00:00
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6]" ,
2016-04-08 09:43:58 +01:00
"--title=$config->{graphs}->{_chrony1} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:loffset=$rrd:chrony" . $ e . "_loffset:AVERAGE" ,
"DEF:rmsoffs=$rrd:chrony" . $ e . "_rmsoffs:AVERAGE" ,
"CDEF:allvalues=loffset,rmsoffs,+" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2022-02-28 16:13:20 +00:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 1 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$e2/ ) ) {
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
if ( lc ( $ config - > { disable_javascript_void } ) eq "y" ) {
2022-02-28 16:13:20 +00:00
push ( @ output , " " . picz_a_element ( config = > $ config , IMGz = > $ IMGz [ $ e * 6 ] , IMG = > $ IMG [ $ e * 6 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 ;
}
2022-02-28 16:13:20 +00:00
push ( @ output , " " . picz_js_a_element ( width = > $ picz_width , height = > $ picz_height , config = > $ config , IMGz = > $ IMGz [ $ e * 6 ] , IMG = > $ IMG [ $ e * 6 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2022-02-28 16:13:20 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
@ riglim = @ { setup_riglim ( $ rigid [ 1 ] , $ limit [ 1 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:rootdel#4444EE:Root delay" ) ;
2016-04-11 09:44:04 +01:00
push ( @ tmp , "GPRINT:rootdel:LAST: Cur\\: %8.6lf" ) ;
2016-04-08 09:43:58 +01:00
push ( @ tmp , "GPRINT:rootdel:AVERAGE: Avg\\: %8.6lf" ) ;
push ( @ tmp , "GPRINT:rootdel:MIN: Min\\: %8.6lf" ) ;
push ( @ tmp , "GPRINT:rootdel:MAX: Max\\: %8.6lf\\n" ) ;
push ( @ tmp , "LINE2:rootdis#44EEEE:Root dispersion" ) ;
2016-04-11 09:44:04 +01:00
push ( @ tmp , "GPRINT:rootdis:LAST:Cur\\: %8.6lf" ) ;
2016-04-08 09:43:58 +01:00
push ( @ tmp , "GPRINT:rootdis:AVERAGE: Avg\\: %8.6lf" ) ;
push ( @ tmp , "GPRINT:rootdis:MIN: Min\\: %8.6lf" ) ;
push ( @ tmp , "GPRINT:rootdis:MAX: Max\\: %8.6lf\\n" ) ;
push ( @ tmp , "LINE2:rootdel#4444EE" ) ;
push ( @ tmp , "LINE2:rootdis#44EEEE" ) ;
push ( @ tmpz , "LINE2:rootdel#4444EE:Root delay" ) ;
push ( @ tmpz , "LINE2:rootdis#44EEEE:Root dispersion" ) ;
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" ) ;
}
( $ 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 ;
}
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6 + 1]" ,
"--title=$config->{graphs}->{_chrony2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:rootdel=$rrd:chrony" . $ e . "_rootdel:AVERAGE" ,
"DEF:rootdis=$rrd:chrony" . $ e . "_rootdis:AVERAGE" ,
"CDEF:allvalues=rootdel,rootdis,+" ,
@ CDEF ,
"COMMENT: \\n" ,
@ tmp ,
"COMMENT: \\n" ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 1]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6 + 1]" ,
"--title=$config->{graphs}->{_chrony2} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:rootdel=$rrd:chrony" . $ e . "_rootdel:AVERAGE" ,
"DEF:rootdis=$rrd:chrony" . $ e . "_rootdis:AVERAGE" ,
"CDEF:allvalues=rootdel,rootdis,+" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 1]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 2 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$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 * 6 + 1 ] , IMG = > $ IMG [ $ e * 6 + 1 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 * 6 + 1 ] , IMG = > $ IMG [ $ e * 6 + 1 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 + 1 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
if ( $ title ) {
2017-07-24 11:05:02 +01:00
push ( @ output , " </td>\n" ) ;
2020-12-03 08:42:17 +00:00
push ( @ output , " <td class='td-valign-top'>\n" ) ;
2016-04-08 09:43:58 +01:00
}
@ riglim = @ { setup_riglim ( $ rigid [ 2 ] , $ limit [ 2 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:stratum#44EEEE:Stratum" ) ;
push ( @ tmp , "GPRINT:stratum:LAST: Current\\: %2.0lf\\n" ) ;
push ( @ tmpz , "LINE2:stratum#44EEEE:Stratum" ) ;
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" ) ;
}
( $ 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" ) ;
}
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6 + 2]" ,
"--title=$config->{graphs}->{_chrony3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Level" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:stratum=$rrd:chrony" . $ e . "_stratum:AVERAGE" ,
"CDEF:allvalues=stratum" ,
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 2]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6 + 2]" ,
"--title=$config->{graphs}->{_chrony3} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Level" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:stratum=$rrd:chrony" . $ e . "_stratum:AVERAGE" ,
"CDEF:allvalues=stratum" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 2]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 3 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$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 * 6 + 2 ] , IMG = > $ IMG [ $ e * 6 + 2 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 * 6 + 2 ] , IMG = > $ IMG [ $ e * 6 + 2 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 + 2 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
@ riglim = @ { setup_riglim ( $ rigid [ 3 ] , $ limit [ 3 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:freq#EE44EE:Frequency" ) ;
push ( @ tmp , "GPRINT:freq:LAST: Current\\: %5.3lf\\n" ) ;
push ( @ tmp , "GPRINT:freq_s:LAST: %3.1lf s/day ($freq_status)\\n" ) ;
push ( @ tmpz , "LINE2:freq#EE44EE:Frequency" ) ;
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" ) ;
}
( $ 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" ) ;
}
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6 + 3]" ,
"--title=$config->{graphs}->{_chrony4} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=PPM" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:freq=$rrd:chrony" . $ e . "_freq:AVERAGE" ,
"CDEF:freq_s=freq,86400,*,1000000,/" ,
"CDEF:allvalues=freq" ,
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 3]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6 + 3]" ,
"--title=$config->{graphs}->{_chrony4} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=PPM" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:freq=$rrd:chrony" . $ e . "_freq:AVERAGE" ,
"CDEF:freq_s=freq,86400,*,1000000,/" ,
"CDEF:allvalues=freq" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 3]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 4 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$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 * 6 + 3 ] , IMG = > $ IMG [ $ e * 6 + 3 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 * 6 + 3 ] , IMG = > $ IMG [ $ e * 6 + 3 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 + 3 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
@ riglim = @ { setup_riglim ( $ rigid [ 4 ] , $ limit [ 4 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:skew#963C74:Skew" ) ;
push ( @ tmp , "GPRINT:skew:LAST: Current\\: %5.3lf\\n" ) ;
push ( @ tmpz , "LINE2:skew#963C74:Skew" ) ;
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" ) ;
}
( $ 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" ) ;
}
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6 + 4]" ,
"--title=$config->{graphs}->{_chrony5} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=PPM" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:skew=$rrd:chrony" . $ e . "_skew:AVERAGE" ,
"CDEF:allvalues=skew" ,
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 4]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6 + 4]" ,
"--title=$config->{graphs}->{_chrony5} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=PPM" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:skew=$rrd:chrony" . $ e . "_skew:AVERAGE" ,
"CDEF:allvalues=skew" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 4]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 5 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$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 * 6 + 4 ] , IMG = > $ IMG [ $ e * 6 + 4 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 * 6 + 4 ] , IMG = > $ IMG [ $ e * 6 + 4 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 + 4 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
@ riglim = @ { setup_riglim ( $ rigid [ 5 ] , $ limit [ 5 ] ) } ;
undef ( @ tmp ) ;
undef ( @ tmpz ) ;
undef ( @ CDEF ) ;
push ( @ tmp , "LINE2:upintvl#EEEE44:Update interval" ) ;
push ( @ tmp , "GPRINT:upintvl:LAST: Current\\: %6.1lf\\n" ) ;
push ( @ tmpz , "LINE2:upintvl#EEEE44:Update interval" ) ;
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" ) ;
}
( $ 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" ) ;
}
$ pic = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMG[$e * 6 + 5]" ,
"--title=$config->{graphs}->{_chrony6} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:upintvl=$rrd:chrony" . $ e . "_upintvl:AVERAGE" ,
"CDEF:allvalues=upintvl" ,
@ CDEF ,
@ tmp ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMG[$e * 6 + 5]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
if ( lc ( $ config - > { enable_zoom } ) eq "y" ) {
( $ width , $ height ) = split ( 'x' , $ config - > { graph_size } - > { zoom } ) ;
$ picz = $ rrd { $ version } - > ( "$IMG_DIR" . "$IMGz[$e * 6 + 5]" ,
"--title=$config->{graphs}->{_chrony6} ($tf->{nwhen}$tf->{twhen})" ,
"--start=-$tf->{nwhen}$tf->{twhen}" ,
"--imgformat=$imgfmt_uc" ,
"--vertical-label=Seconds" ,
"--width=$width" ,
"--height=$height" ,
2022-01-12 09:26:58 +00:00
@ full_size_mode ,
2019-05-08 11:54:03 +01:00
@ extra ,
2016-04-08 09:43:58 +01:00
@ riglim ,
$ zoom ,
@ { $ cgi - > { version12 } } ,
@ { $ cgi - > { version12_small } } ,
@ { $ colors - > { graph_colors } } ,
"DEF:upintvl=$rrd:chrony" . $ e . "_upintvl:AVERAGE" ,
"CDEF:allvalues=upintvl" ,
@ CDEF ,
@ tmpz ) ;
$ err = RRDs:: error ;
2017-07-24 11:05:02 +01:00
push ( @ output , "ERROR: while graphing $IMG_DIR" . "$IMGz[$e * 6 + 5]: $err\n" ) if $ err ;
2016-04-08 09:43:58 +01:00
}
$ e2 = $ e + 6 ;
if ( $ title || ( $ silent =~ /imagetag/ && $ graph =~ /chrony$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 * 6 + 5 ] , IMG = > $ IMG [ $ e * 6 + 5 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
} else {
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 * 6 + 5 ] , IMG = > $ IMG [ $ e * 6 + 5 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
} else {
2021-12-22 00:24:55 +00:00
push ( @ output , " " . img_element ( config = > $ config , IMG = > $ IMG [ $ e * 6 + 5 ] ) . "\n" ) ;
2016-04-08 09:43:58 +01:00
}
}
if ( $ title ) {
2017-07-24 11:05:02 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , " <tr>\n" ) ;
2022-02-24 09:10:01 +00:00
push ( @ output , " <td class='td-title' colspan='2'>\n" ) ;
2017-07-24 11:05:02 +01:00
push ( @ output , " <font size='-1'>\n" ) ;
2022-02-24 09:10:01 +00:00
push ( @ output , " <b> " . trim ( $ url ) . "</b>\n" ) ;
push ( @ output , " </font>\n" ) ;
2017-07-24 11:05:02 +01:00
push ( @ output , " </td>\n" ) ;
push ( @ output , " </tr>\n" ) ;
push ( @ output , main:: graph_footer ( ) ) ;
2016-04-08 09:43:58 +01:00
}
$ e + + ;
}
2017-07-24 11:05:02 +01:00
push ( @ output , " <br>\n" ) ;
return @ output ;
2016-04-08 09:43:58 +01:00
}
1 ;