#!/bin/sh
#
# Plugin to monitor the number of star scheduler processes.
#
# (c) GPL Tomas Pospisek <tpo_deb@sourcepole.ch>
#
# Usage: copy or link into /etc/lrrd/client.d/
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by lrrd-config)
#
# Magic markers (optional - used by lrrd-config and some installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf

if [ "$1" = "autoconf" ]; then
	echo yes
	exit 0
fi

if [ "$1" = "config" ]; then
    echo 'graph_title Number of star scheduler processes'
    echo 'graph_args --base 1000 -l 0'
    echo 'graph_vlabel summ of processes'
    echo 'sserver.label sserver'
    echo 'sserver.draw LINE2'
    echo 'schdled.label schdled'
    echo 'schdled.draw STACK'
    echo 'shttpd.label shttpd'
    echo 'shttpd.draw STACK'
    echo 'sadmind.label sadmind'
    echo 'sadmind.draw STACK'
    echo 'slaunchd.label slaunchd'
    echo 'slaunchd.draw STACK'
    echo 'Xvfb.label Xvfb'
    echo 'Xvfb.draw STACK'
    exit 0
fi

echo -n 'sserver.value '
pgrep ssserver.bin | grep -v grep | wc -l
echo -n 'schdled.value '
pgrep schdled.bin  | grep -v grep | wc -l
echo -n 'shttpd.value '
pgrep shttpd.bin   | grep -v grep | wc -l
echo -n 'sadmind.value '
pgrep sadmind.bin  | grep -v grep | wc -l
echo -n 'slaunchd.value '
pgrep slaunchd.bin | grep -v grep | wc -l
echo -n 'Xvfb.value '
pgrep Xvfb         | grep -v grep | wc -l
