@@ -24,7 +24,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2424 STATE_UNKNOWN , STATE_WARN )
2525
2626__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
27- __version__ = '2025100601 '
27+ __version__ = '2026040801 '
2828
2929DESCRIPTION = 'Checks how well an Apache httpd server is performing.'
3030
@@ -44,7 +44,7 @@ def parse_args():
4444 parser .add_argument (
4545 '-V' , '--version' ,
4646 action = 'version' ,
47- version = '%(prog)s: v{} by {}' . format ( __version__ , __author__ )
47+ version = f '%(prog)s: v{ __version__ } by { __author__ } '
4848 )
4949
5050 parser .add_argument (
@@ -242,14 +242,14 @@ def main():
242242 # If ExtendedStatus is off:
243243 if 'Uptime' not in apache :
244244 # "ExtendedStatus off" just reports BusyWorkers, IdleWorkers and Scoreboard
245- msg = '{}/{} workers busy ({}%{}; {} "G"), {} idle, {} free' . format (
246- apache [' BusyWorkers' ],
247- apache [ 'TotalWorkers' ],
248- apache [' WorkerUsagePercentage' ],
249- lib .base .state2str (state , prefix = ' ' ),
250- workers [' finishing' ],
251- apache [' IdleWorkers' ],
252- workers [' free' ],
245+ msg = (
246+ f' { apache [" BusyWorkers" ] } / { apache [ "TotalWorkers" ] } '
247+ f' workers busy'
248+ f' ( { apache [" WorkerUsagePercentage" ] } %'
249+ f' { lib .base .state2str (state , prefix = " " ) } '
250+ f'; { workers [" finishing" ] } "G")'
251+ f', { apache [" IdleWorkers" ] } idle'
252+ f', { workers [" free" ] } free'
253253 )
254254
255255 # over and out
@@ -262,31 +262,31 @@ def main():
262262
263263 # get previous values
264264 prev_uptime = lib .cache .get (
265- 'apache-httpd-status-{}-uptime' . format ( args . URL ) ,
265+ f 'apache-httpd-status-{ args . URL } -uptime' ,
266266 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
267267 )
268268 prev_count = lib .cache .get (
269- 'apache-httpd-status-{}-total-accesses' . format ( args . URL ) ,
269+ f 'apache-httpd-status-{ args . URL } -total-accesses' ,
270270 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
271271 )
272272 prev_bcount = lib .cache .get (
273- 'apache-httpd-status-{}-total-bytes' . format ( args . URL ) ,
273+ f 'apache-httpd-status-{ args . URL } -total-bytes' ,
274274 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
275275 )
276276
277277 # save current values
278278 lib .cache .set (
279- 'apache-httpd-status-{}-uptime' . format ( args . URL ) ,
279+ f 'apache-httpd-status-{ args . URL } -uptime' ,
280280 apache ['Uptime' ],
281281 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
282282 )
283283 lib .cache .set (
284- 'apache-httpd-status-{}-total-accesses' . format ( args . URL ) ,
284+ f 'apache-httpd-status-{ args . URL } -total-accesses' ,
285285 apache ['Total Accesses' ],
286286 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
287287 )
288288 lib .cache .set (
289- 'apache-httpd-status-{}-total-bytes' . format ( args . URL ) ,
289+ f 'apache-httpd-status-{ args . URL } -total-bytes' ,
290290 apache ['Total Bytes' ],
291291 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
292292 )
@@ -306,17 +306,17 @@ def main():
306306 perfdata += lib .base .get_perfdata ('Uptime' , apache ['Uptime' ], 's' , None , None , 0 , None ) # pylint: disable=C0301
307307
308308 if 'Total Duration' not in apache :
309- msg = '{}/{} workers busy ({}%{}; {} "G"), {} idle, {} free; {} accesses, {} traffic; Up {}' . format (
310- apache [' BusyWorkers' ],
311- apache [ 'TotalWorkers' ],
312- apache [' WorkerUsagePercentage' ],
313- lib .base .state2str (state , prefix = ' ' ),
314- workers [' finishing' ],
315- apache [' IdleWorkers' ],
316- workers [' free' ],
317- lib .human .number2human (apache [' Total Accesses' ]),
318- lib .human .bytes2human (apache [' Total Bytes' ]),
319- lib .human .seconds2human (apache [' Uptime' ]),
309+ msg = (
310+ f' { apache [" BusyWorkers" ] } / { apache [ "TotalWorkers" ] } '
311+ f' workers busy'
312+ f' ( { apache [" WorkerUsagePercentage" ] } %'
313+ f' { lib .base .state2str (state , prefix = " " ) } '
314+ f'; { workers [" finishing" ] } "G")'
315+ f', { apache [" IdleWorkers" ] } idle'
316+ f', { workers [" free" ] } free'
317+ f'; { lib .human .number2human (apache [" Total Accesses" ]) } accesses'
318+ f', { lib .human .bytes2human (apache [" Total Bytes" ]) } traffic'
319+ f'; Up { lib .human .seconds2human (apache [" Uptime" ]) } '
320320 )
321321
322322 # over and out
@@ -327,11 +327,11 @@ def main():
327327 # Some more variables in newer versions of mod_status
328328
329329 prev_duration_global = lib .cache .get (
330- 'apache-httpd-status-{}-total-duration' . format ( args . URL ) ,
330+ f 'apache-httpd-status-{ args . URL } -total-duration' ,
331331 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
332332 )
333333 lib .cache .set (
334- 'apache-httpd-status-{}-total-duration' . format ( args . URL ) ,
334+ f 'apache-httpd-status-{ args . URL } -total-duration' ,
335335 apache ['Total Duration' ],
336336 filename = 'linuxfabrik-monitoring-plugins-apache-httpd-status.db' ,
337337 )
@@ -356,18 +356,18 @@ def main():
356356 perfdata += lib .base .get_perfdata ('Stopping' , apache ['Stopping' ], None , None , None , 0 , None ) if 'Stopping' in apache else '' # pylint: disable=C0301
357357 perfdata += lib .base .get_perfdata ('Total Duration' , duration_diff , 's' , None , None , 0 , None ) if 'Total Duration' in apache else '' # pylint: disable=C0301
358358
359- msg = '{}: {}/{} workers busy ({}%{}; {} "G"), {} idle, {} free; {} accesses, {} traffic; Up {}' . format (
360- apache [' ServerName' ],
361- apache [' BusyWorkers' ],
362- apache [ 'TotalWorkers' ],
363- apache [' WorkerUsagePercentage' ],
364- lib .base .state2str (state , prefix = ' ' ),
365- workers [' finishing' ],
366- apache [' IdleWorkers' ],
367- workers [' free' ],
368- lib .human .number2human (apache [' Total Accesses' ]),
369- lib .human .bytes2human (apache [' Total Bytes' ]),
370- lib .human .seconds2human (apache [' Uptime' ]),
359+ msg = (
360+ f' { apache [" ServerName" ] } :'
361+ f' { apache [" BusyWorkers" ] } / { apache [ "TotalWorkers" ] } '
362+ f' workers busy'
363+ f' ( { apache [" WorkerUsagePercentage" ] } %'
364+ f' { lib .base .state2str (state , prefix = " " ) } '
365+ f'; { workers [" finishing" ] } "G")'
366+ f', { apache [" IdleWorkers" ] } idle'
367+ f', { workers [" free" ] } free'
368+ f'; { lib .human .number2human (apache [" Total Accesses" ]) } accesses'
369+ f', { lib .human .bytes2human (apache [" Total Bytes" ]) } traffic'
370+ f'; Up { lib .human .seconds2human (apache [" Uptime" ]) } '
371371 )
372372
373373 table_values = []
0 commit comments