From 9fdf433a6d5a9e4effeb1d9cc315532798d9afdf Mon Sep 17 00:00:00 2001 From: Lukas Macura Date: Thu, 24 Mar 2016 17:27:02 +0100 Subject: [PATCH] process-info reworked --- process-info/control | 13 ++++++++++--- process-info/proc-discovery.sh | 10 +++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/process-info/control b/process-info/control index 0ac27f0..5155cb1 100644 --- a/process-info/control +++ b/process-info/control @@ -1,16 +1,23 @@ + Plugin: process-info + Plugin which will make deeper look to processess and their usage. Maintainer: Lukas Macura Item: cpu[*] This item will return cpu usage of given process. In zabbix, it will be prefixed automaticaly by plugin name (processlist.cpu) -Item-cmd-cpu[*]: {PLUGINDIR}/cpu-get.sh + +Item-cmd-cpu[*]: {ZAFLIB} {PLUGINDIR}/cpu-get.sh Item: discovery Discovery of runing processes -Item-cmd-discovery: {PLUGINDIR}/cpu-get.sh +Item-cmd-discovery: {ZAFLIB} {PLUGINDIR}/proc-discovery.sh -Binary-Depends: echo ps awk sort uniq sed +Binary-depends: echo ps awk sort uniq sed + +Dpkg-depends: sed + +Opkg-depends: busybox Install-bin: cpu-get.sh proc-discovery.sh diff --git a/process-info/proc-discovery.sh b/process-info/proc-discovery.sh index 80c6086..5cf72ec 100755 --- a/process-info/proc-discovery.sh +++ b/process-info/proc-discovery.sh @@ -1,4 +1,12 @@ #!/bin/sh -echo "{\n \"data\":[" ; /bin/ps --no-headers caux | /usr/bin/awk '{ print " { \"{#PSUSER}\":\"" $1 "\", \"{#PSNAME}\":\"" $11 "\" },"}' | /usr/bin/sort | /usr/bin/uniq | /bin/sed -e 's/\//\\\//g' -e '$s/.$//' ; echo " ]\n}" +if [ "${ZAF_PKG}" = "opkg" ]; then + AWK='{ print $2" "$5; }' + PS="w" +else + AWK='{ print $1" "$11; }' + PS="--no-headers caux" +fi + +ps $PS | awk "$AWK" | sort | uniq | sed -e 's/\//\\\//g' -e '$s/.$//' | zaf_discovery '{#PSNAME}' '{#PSUSER}'