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 fs' ;
'require form' ;
2020-04-03 08:00:06 +00:00
return baseclass . extend ( {
2020-02-08 21:12:17 +00:00
title : _ ( 'IRQ Plugin Configuration' ) ,
description : _ ( 'The irq plugin will monitor the rate of issues per second for each selected interrupt. If no interrupt is selected then all interrupts are monitored.' ) ,
addFormOptions : function ( s ) {
var o ;
o = s . option ( form . Flag , 'enable' , _ ( 'Enable this plugin' ) ) ;
o = s . option ( form . DynamicList , 'Irqs' , _ ( 'Monitor interrupts' ) ) ;
o . optional = true ;
o . multiple = true ;
o . depends ( 'enable' , '1' ) ;
o . load = function ( section _id ) {
return fs . trimmed ( '/proc/interrupts' ) . then ( L . bind ( function ( str ) {
var lines = str . split ( /\n/ ) ,
cpus = L . toArray ( lines [ 0 ] ) ;
for ( var i = 1 ; i < lines . length ; i ++ ) {
var line = lines [ i ] ,
m = lines [ i ] . match ( /^\s*([^\s:]+):/ ) ;
if ( ! m )
continue ;
line = line . replace ( /^[^:]+:\s+/ , '' ) ;
for ( var j = 0 ; j < cpus . length ; j ++ )
line = line . replace ( /^\d+\s*/ , '' ) ;
var desc = line . split ( / {2,}/ ) . join ( ', ' ) ;
this . value ( m [ 1 ] , '%s (%s)' . format ( m [ 1 ] , desc || '-' ) ) ;
}
2020-03-29 12:17:55 +00:00
return this . super ( 'load' , [ section _id ] ) ;
2020-02-08 21:12:17 +00:00
} , this ) ) ;
} ;
o = s . option ( form . Flag , 'IgnoreSelected' , _ ( 'Monitor all except specified' ) ) ;
o . depends ( 'enable' , '1' ) ;
} ,
configSummary : function ( section ) {
var irqs = L . toArray ( section . Irqs ) ,
invert = section . IgnoreSelected == '1' ;
if ( irqs . length == 0 )
return _ ( 'Monitoring all interrupts' ) ;
else if ( invert )
return N _ ( irqs . length , 'Monitoring all but one interrupt' , 'Monitoring all but %d interrupts' ) . format ( irqs . length ) ;
else
return N _ ( irqs . length , 'Monitoring one interrupt' , 'Monitoring %d interrupts' ) . format ( irqs . length ) ;
}
} ) ;