# DG_Template Linux Process Discovery
# Returns a list of monitorable processes in Zabbix LLD JSON format
UserParameter=dg.ps.discovery,echo "{ \"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 " ]}"
# Calculates CPU usage in % over multiple process threads
UserParameter=dg.proc.cpu[*],TOTALCPU=0; for PROC in `/bin/ps u -C $1 | /bin/grep -e '^$2' | /usr/bin/awk '{ print $$3 }'`; do TOTALCPU=`echo "$TOTALCPU $PROC" | /usr/bin/awk '{print $$1 + $$2}'` ; done; echo $TOTALCPU
# Calculates CPU usage in % over multiple process threads
UserParameter=dg.proc.mem[*],TOTALMEM=0; for PROC in `/bin/ps u -C $1 | /bin/grep -e '^$2' | /usr/bin/awk '{ print $$4 }'`; do TOTALMEM=`echo "$TOTALMEM $PROC" | /usr/bin/awk '{print $$1 + $$2}'` ; done; echo $TOTALMEM
