1
0
mirror of https://github.com/limosek/zaf-plugins.git synced 2024-11-01 08:17:19 +01:00

process-info reworked

This commit is contained in:
Lukas Macura 2016-03-24 17:27:02 +01:00
parent 32cb8c651e
commit 9fdf433a6d
2 changed files with 19 additions and 4 deletions

View File

@ -1,16 +1,23 @@
Plugin: process-info Plugin: process-info
Plugin which will make deeper look to processess and their usage.
Maintainer: Lukas Macura <lukas@macura.cz> Maintainer: Lukas Macura <lukas@macura.cz>
Item: cpu[*] Item: cpu[*]
This item will return cpu usage of given process. In zabbix, it will be prefixed automaticaly by plugin name (processlist.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 Item: discovery
Discovery of runing processes 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 Install-bin: cpu-get.sh proc-discovery.sh

View File

@ -1,4 +1,12 @@
#!/bin/sh #!/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}'