1
0
mirror of https://github.com/limosek/zaf.git synced 2025-11-03 02:57:38 +01:00

Initial release

This commit is contained in:
Lukas Macura
2016-03-23 17:25:18 +01:00
parent 5e566a2046
commit 1e89b27028
6 changed files with 193 additions and 8 deletions

View File

@@ -4,12 +4,14 @@ Maintainer: Lukas Macura <lukas@macura.cz>
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[*]: TOTAL=0; for PROC in $(/bin/ps u -C $1 | /bin/grep -e '^$2' | /usr/bin/awk '{ print $$3 }'); do TOTAL=$(echo "$TOTAL $PROC" | /usr/bin/awk '{print $$1 + $$2}') ; done; echo $TOTAL
Item-cmd-cpu[*]: {PLUGINDIR}/cpu-get.sh
Item: discovery
Discovery of runing processes
Item-cmd-discovery: 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}"
Item-cmd-discovery: {PLUGINDIR}/cpu-get.sh
Binary-Depends: echo ps awk sort uniq sed
Install-bin: cpu-get.sh proc-discovery.sh

View File

@@ -0,0 +1,6 @@
#!/bin/sh
TOTAL=0
for PROC in $(/bin/ps u -C $1 | /bin/grep -e '^$2' | /usr/bin/awk '{ print $$3 }'); do TOTAL=$(echo "$TOTAL $PROC" | /usr/bin/awk '{print $$1 + $$2}') ; done;
echo $TOTAL

View File

@@ -0,0 +1,4 @@
#!/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}"