mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
systemd_mem: add env option to monitor all services
This commit is contained in:
parent
b44d8093b9
commit
b21206c68c
1 changed files with 20 additions and 4 deletions
|
@ -15,13 +15,20 @@ Example:
|
|||
|
||||
env.services defaults to "munin-node".
|
||||
|
||||
As an alternative you can use all_services to display memory for all running systemd services
|
||||
[systemd_mem]
|
||||
env.all_services true
|
||||
|
||||
all_services shows memory for all running units of type service.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.0
|
||||
1.1
|
||||
|
||||
=head1 AUTHOR
|
||||
=head1 AUTHORS
|
||||
|
||||
Paul Alexandrow <paul@alexandrow.org>
|
||||
Andreas Perhab <a.perhab@wtioit.at>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
|
@ -51,13 +58,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SO
|
|||
|
||||
. "$MUNIN_LIBDIR/plugins/plugin.sh"
|
||||
|
||||
for_services() {
|
||||
if [ "$all_services" != "" ]; then
|
||||
systemctl --type=service --state=running --no-pager --no-legend --output=short-precise \
|
||||
| awk '{sub(".service$", "", $1); print $1}'
|
||||
else
|
||||
echo ${services:-"munin-node"}
|
||||
fi
|
||||
}
|
||||
|
||||
output_config() {
|
||||
echo "graph_title Systemd Service Memory Usage"
|
||||
echo "graph_info Memory usage for selected services as reported by systemctl"
|
||||
echo "graph_vlabel bytes"
|
||||
echo "graph_args --base 1024 --lower-limit 0"
|
||||
echo "graph_category memory"
|
||||
for service in ${services:-"munin-node"}; do
|
||||
for service in $(for_services); do
|
||||
clean_name="$(clean_fieldname "$service")"
|
||||
description=$(systemctl show "$service" --property=Description | cut -d '=' -f 2)
|
||||
warning=$(systemctl show "$service" --property=MemoryHigh | cut -d '=' -f 2)
|
||||
|
@ -77,7 +93,7 @@ output_config() {
|
|||
}
|
||||
|
||||
output_values() {
|
||||
for service in ${services:-"munin-node"}; do
|
||||
for service in $(for_services); do
|
||||
clean_name="$(clean_fieldname "$service")"
|
||||
usage=$(systemctl show "$service" --property=MemoryCurrent | cut -d '=' -f 2)
|
||||
if [ "$usage" = "[not set]" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue