2020-02-08 21:12:17 +00:00
'use strict' ;
2020-04-03 08:00:06 +00:00
'require baseclass' ;
2020-02-08 21:12:17 +00:00
'require form' ;
2020-04-03 08:00:06 +00:00
return baseclass . extend ( {
2020-02-08 21:12:17 +00:00
title : _ ( 'RRDTool Plugin Configuration' ) ,
description : _ ( 'The rrdtool plugin stores the collected data in rrd database files, the foundation of the diagrams.<br /><br /><strong>Warning: Setting the wrong values will result in a very high memory consumption in the temporary directory. This can render the device unusable!</strong>' ) ,
addFormOptions : function ( s ) {
var o ;
o = s . option ( form . Flag , 'enable' , _ ( 'Enable this plugin' ) ) ;
o = s . option ( form . Value , 'DataDir' , _ ( 'Storage directory' ) ,
_ ( 'Note: as pages are rendered by user \'nobody\', the *.rrd files, the storage directory and all its parent directories need to be world readable.' ) ) ;
2020-02-22 22:26:49 +00:00
o . default = '/tmp/rrd' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o = s . option ( form . Value , 'StepSize' , _ ( 'RRD step interval' ) , _ ( 'Seconds' ) ) ;
o . placeholder = '30' ;
o . datatype = 'uinteger' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o = s . option ( form . Value , 'HeartBeat' , _ ( 'RRD heart beat interval' ) , _ ( 'Seconds' ) ) ;
o . placeholder = '60' ;
o . datatype = 'uinteger' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o = s . option ( form . Flag , 'RRASingle' , _ ( 'Only create average RRAs' ) , _ ( 'reduces rrd size' ) ) ;
o . default = '1' ;
o . rmempty = false ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
o = s . option ( form . Flag , 'RRAMax' , _ ( 'Show max values instead of averages' ) ,
_ ( 'Max values for a period can be used instead of averages when not using \'only average RRAs\'' ) ) ;
o . depends ( 'RRASingle' , '0' ) ;
2020-12-13 09:47:35 +00:00
o = s . option ( form . DynamicList , 'RRATimespans' , _ ( 'Stored timespans' ) ,
_ ( 'List of time spans to be stored in RRD database. E.g. "1hour 1day 14day". Allowed timespan types: min, h, hour(s), d, day(s), w, week(s), m, month(s), y, year(s)' ) ) ;
2020-12-13 09:09:33 +00:00
o . default = '1hour 1day 1week 1month 1year' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
o . validate = function ( section _id , value ) {
if ( value == '' )
return true ;
if ( value . match ( /^[0-9]+(?:y|m|w|d|h|min|years?|months?|weeks?|days?|hours?)?$/ ) )
return true ;
return _ ( 'Expecting valid time range' ) ;
} ;
o = s . option ( form . Value , 'RRARows' , _ ( 'Rows per RRA' ) ) ;
2020-12-13 09:09:33 +00:00
o . default = '144' ;
2020-02-22 22:26:49 +00:00
o . datatype = 'min(1)' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
o = s . option ( form . Value , 'XFF' , _ ( 'RRD XFiles Factor' ) ) ;
2020-02-22 22:26:49 +00:00
o . placeholder = '0.1' ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o . validate = function ( section _id , value ) {
if ( value == '' )
return true ;
if ( value . match ( /^[0-9]+(?:\.[0-9]+)?$/ ) && + value >= 0 && + value < 1 )
return true ;
2020-02-08 21:12:17 +00:00
2020-02-22 22:26:49 +00:00
return _ ( 'Expecting decimal value lower than one' ) ;
} ;
o = s . option ( form . Value , 'CacheTimeout' , _ ( 'Cache collected data for' ) , _ ( 'Seconds' ) ) ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o . datatype = 'uinteger' ;
o . placeholder = '0' ;
o . validate = function ( section _id , value ) {
var flushinp = this . map . findElement ( 'id' , 'widget.cbid.luci_statistics.collectd_rrdtool.CacheFlush' ) ;
if ( value != '' && ! isNaN ( value ) && + value > 0 ) {
flushinp . placeholder = 10 * + value ;
flushinp . disabled = false ;
}
else {
flushinp . value = '' ;
flushinp . placeholder = '0' ;
flushinp . disabled = true ;
}
return true ;
} ;
2020-02-08 21:12:17 +00:00
2020-02-22 22:26:49 +00:00
o = s . option ( form . Value , 'CacheFlush' , _ ( 'Flush cache after' ) , _ ( 'Seconds' ) ) ;
2020-02-08 21:12:17 +00:00
o . depends ( 'enable' , '1' ) ;
2020-02-22 22:26:49 +00:00
o . datatype = 'uinteger' ;
2020-02-08 21:12:17 +00:00
} ,
configSummary : function ( section ) {
if ( section . DataDir )
return _ ( 'Writing *.rrd files to %s' ) . format ( section . DataDir ) ;
}
} ) ;