Package: apache-manager
Theapache-managerpackage helps to collect monitoringmetricsabout theApache web serverand kill worker processes that exceed resource thresholds.
It works by parsing the plain text and HTML status pages generated by Apache’smod_statusmodule. It’s currently tested on cPython 2.7, 3.5, 3.6, 3.7, 3.8
and PyPy. It was developed for and expects to be run on Linux systems.StatusInstallationUsageCommand lineContactLicenseStatusOn the one hand theapache-managerpackage was developed based on quite a few
years of experience interfacing with (and monitoring) theApache web serverusing the interfaces provided by Apache itself (mod_status) as well as the
Linux operating system interfaces (/proc).On the other hand the Python package itself is quite new: it was developed
between June and September of 2015.Then again, I’m religious about test coverage, so there’s that :-).Despite the complete package being covered by automated tests I’m not (yet)
committing to backwards compatibility because I first want to run this package
in a production (like) environment for some time, to get a feeling for how
robust it is. I also need to evaluate how easy it is to integrate the current
solution into monitoring systems (that was a goal, but I don’t always achieve
my goals on the first attempt :-).InstallationTheapache-managerpackage is available onPyPIwhich means installation
should be as simple as:$pipinstallapache-managerThere’s actually a multitude of ways to install Python packages (e.g. theper
user site-packages directory,virtual environmentsor just installing
system wide) and I have no intention of getting into that discussion here, so
if this intimidates you then read up on your options before returning to these
instructions ;-).UsageThere are two ways to use theapache-managerpackage: As the command line
programapache-managerand as a Python API. For details about the Python
API please refer to the API documentation available onRead the Docs. The
command line interface is described below.Command lineUsage:apache-manager [OPTIONS]Command line interface to monitor the Apache web server and kill worker
processes that exceed resource thresholds. When no options are given the
server metrics and memory usage of workers are printed to the terminal.Supported options:OptionDescription-c,--collect-metricsCollect monitoring metrics and store them in a text file to be read
by a monitoring system like Zabbix. See also the--data-fileoption.-k,--kill-workersKill Apache workers exceeding the thresholds given by--max-memory-active,--max-memory-idleand--max-time. These thresholds can also be defined in
configuration files, please refer to the online documentation for details.
See also the--dry-runoption.-w,--watchThis option causes the Apache manager to redraw the collected metrics once
every 10 seconds in a “top” like interface until interrupted using “q” (for
quite) or Control-C.-a,--max-memory-active=SIZEKill active Apache workers that are using more memory than specified by theSIZEargument.SIZEis expected to be a human readable memory size like 50K
(50 kilobytes), 42M (42 megabytes), 2G (2 gigabytes), etc.-i,--max-memory-idle=SIZEKill Apache workers that are using more memory than specified by theSIZEargument (see--max-memory-activefor acceptable values ofSIZE).-t,--max-ss,--max-time=TIMESPANKill Apache workers whose “time since the beginning of the most recent
request” is greater than specified by theTIMESPANargument.TIMESPANis
expected to be a human readable timespan like 2s (2 seconds), 3m (3
minutes), 5h (5 hours), 2d (2 days), etc.-T,--hanging-worker-threshold=TIMESPANChange the number of seconds before an active worker is considered hanging
toTIMESPAN(see--max-timefor acceptable values ofTIMESPAN).-f,--data-file=PATHChange the pathname of the file where the Apache manager stores monitoring
metrics after every run. Defaults to “/tmp/apache-manager.txt”.-z,--zabbix-discoveryGenerate a JSON fragment that’s compatible with the low-level discovery
support in the Zabbix monitoring system. With the right template in place
this enables the Zabbix server to discover the names of the WSGI process
groups that are active on any given server. This makes it possible to
collect and analyze the memory usage of specific WSGI process groups.-n,--dry-run,--simulateDon’t actually kill any Apache workers.-v,--verboseIncrease verbosity (can be repeated).-q,--quietDecrease verbosity (can be repeated).-h,--helpShow this message and exit.ContactThe latest version ofapache-manageris available onPyPIandGitHub. The
documentation is hosted onRead the Docsand includes achangelog. For bug
reports please create an issue onGitHub. If you have questions, suggestions,
etc. feel free to send me an e-mail atpeter@peterodding.com.LicenseThis software is licensed under theMIT license.© 2020 Peter Odding.