반응형
jmx remote 설정 외 jstat을 이용한 수집
1. zabbix_agentd.conf
UserParameter=jstat[*],/usr/local/etc/scripts/01.jstat.sh "$1" "$2"
2. 01.jstat.sh
#!/bin/sh
dir="/usr/local/java/bin"
dir2="/usr/local/etc/scripts/java_pid"
name="$1"
stat="$2"
if [ "$stat" = "name" ] ; then
pid=`$dir/jps -v | grep "$name" | awk '{print $1}'`
echo $pid > $dir2/$name
else
pid=`cat $dir2/$name`
fi
case "$stat" in
"heap_max")
result=`$dir/jstat -gccapacity $pid | awk '{print ($2+$8)}' | sed '1d'` 2>/dev/null
;;
"heap_commit")
result=`$dir/jstat -gccapacity $pid | awk '{print ($3+$9)}' | sed '1d'` 2>/dev/null
;;
"heap_used")
#result=`$dir/jstat -gc $pid 1s 3 | sed '1d' | awk '{sum+=($3+$4+$6+$8);num++} END {printf "%d",sum/num}'`
result=`$dir/jstat -gc $pid | awk '{print ($3+$4+$6+$8)}' | sed '1d'` 2>/dev/null
;;
"old_used")
result=`$dir/jstat -gcutil $pid | awk '{print $4}' | sed '1d'` 2>/dev/null
;;
"ygc")
result=`$dir/jstat -gcutil $pid | awk '{print $7}' | sed '1d'` 2>/dev/null
;;
"ygct")
result=`$dir/jstat -gcutil $pid | awk '{print $8}' | sed '1d'` 2>/dev/null
;;
"fgc")
result=`$dir/jstat -gcutil $pid | awk '{print $9}' | sed '1d'` 2>/dev/null
;;
"fgct")
result=`$dir/jstat -gcutil $pid | awk '{print $10}' | sed '1d'` 2>/dev/null
;;
"thread")
result=`ps -o nlwp $pid | sed '1d'`
;;
"cpu_pusage")
cpu_cnt=`nproc --all`
result=`ps -p $pid -o %cpu | grep -v "%CPU"`
result=`expr $result / $cpu_cnt`
;;
"mem_pusage")
result=`ps -p $pid -o %mem | grep -v "%MEM"`
;;
"fd_max")
result=`cat /proc/$pid/limits | grep "Max open files" | awk '{print $5}'`
;;
"fd_opened")
result=`ls /proc/$pid/fd/ | wc -l`
;;
"name")
if [[ "$pid" ]] ; then
result="$name"
fi
esac
echo $result | tr -d ' '
3. zabbix server template
반응형
'Monitoring Tools > Zabbix' 카테고리의 다른 글
10. [zabbix agent] bind (0) | 2021.03.17 |
---|---|
9. [zabbix agent] nginx http response code and request time (0) | 2021.03.17 |
7. [zabbix agent] varnish (0) | 2021.03.17 |
6. [zabbix agent] redis (0) | 2021.03.17 |
4. [오류수정] zabbix DB Replication error (0) | 2021.03.17 |