Добавить zbx_discovery_supervisor.sh
This commit is contained in:
parent
731512bc23
commit
37ac4c5e52
33
zbx_discovery_supervisor.sh
Normal file
33
zbx_discovery_supervisor.sh
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
|
||||||
|
# list all processes
|
||||||
|
PROCESSES=`sudo /usr/bin/supervisorctl status 2>/dev/null| grep -v 'supervisor.sock'|awk '{print $1}'`
|
||||||
|
|
||||||
|
|
||||||
|
# get processes array
|
||||||
|
INDEX=0
|
||||||
|
for PROCESS_NAME in $PROCESSES
|
||||||
|
do
|
||||||
|
PROCESS_NAME_NUM[$INDEX]=$PROCESS_NAME
|
||||||
|
let INDEX=INDEX+1
|
||||||
|
done
|
||||||
|
|
||||||
|
num=$(echo ${#PROCESS_NAME_NUM[@]})
|
||||||
|
|
||||||
|
# echo json
|
||||||
|
printf '{\n'
|
||||||
|
printf '\t"data":[\n'
|
||||||
|
for((i=0;i<${#PROCESS_NAME_NUM[@]};++i))
|
||||||
|
{
|
||||||
|
NUM=$(echo $((${#PROCESS_NAME_NUM[@]}-1)))
|
||||||
|
if [ "$i" != ${NUM} ];then
|
||||||
|
printf "\t\t{ \n"
|
||||||
|
printf "\t\t\t\"{#PROCESS_NAME}\":\"${PROCESS_NAME_NUM[$i]}\"},\n"
|
||||||
|
else
|
||||||
|
printf "\t\t{ \n"
|
||||||
|
printf "\t\t\t\"{#PROCESS_NAME}\":\"${PROCESS_NAME_NUM[$NUM]}\"}\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
printf ']}'
|
Loading…
Reference in New Issue
Block a user