Module: check_mk
Branch: master
Commit: 895b546df9b38873465650e5195125f2f3e39061
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=895b546df9b388…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 5 10:30:13 2014 +0200
ps: added agent plugin for outputting CPU usage on Linux
The output of this plugin is not yet being used.
---
agents/plugins/lnx_psperf | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/agents/plugins/lnx_psperf b/agents/plugins/lnx_psperf
new file mode 100755
index 0000000..02a3813
--- /dev/null
+++ b/agents/plugins/lnx_psperf
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Needed to get read CPU usage of processes (and other data) on Linux, since
+# ps only outputs the cumulated CPU usage since the process start
+
+# Configuration: /etc/check_mk/psperf.cfg
+# Each line contains one pattern for pgrep. Arguments of pgrep are supported
+# Example:
+# cups
+# -u ntp
+# This will find processes with the name 'cups' and processes owned by the user
ntp.
+# The check ps will parse this additional information in order to compute
+# the current CPU utilization of a process.
+
+if [ -e "$MK_CONFDIR/psperf.cfg" ] ; then
+ echo '<<<ps>>>'
+ echo '[proc_stat]'
+ while read LINE
+ do
+ for pid in $(pgrep $LINE) ; do
+ cat /proc/$pid/stat
+ done
+ done < "$MK_CONFDIR/psperf.cfg"
+fi