njmon script add server running
【摘要】 njmon script initd script shell: shell njmon script initd===njmon = nmon + JSON format + real-time push to a stats database + instant graphing of “all the stats you can eat” (AIX and Linux) script...
njmon script initd
===
njmon = nmon + JSON format + real-time push to a stats database + instant graphing of “all the stats you can eat” (AIX and Linux)
script shell:
# ll /usr/bin/njmon
# chmod 755 /usr/bin/njmon
# chown root:root /usr/bin/njmon
# chown root:root /etc/logrotate.d/njmon
shell
#!/bin/bash
#
# /etc/init.d/nmon
#
# chkconfig: 345 70 55
# description: nmon init script
# Source function library.
. /etc/init.d/functions
NJMON=/usr/bin/njmon
LOGDIR=/var/log/njmon
PIDFILE=/var/run/njmon.pid
if [ ! -d $LOGDIR/old ]; then
# old for logrotated
mkdir -p $LOGDIR/old
chown root:root $LOGDIR
chmod -R 755 $LOGDIR
fi
if [ ! -e $NJMON ]; then
exit 5
fi
# collect NMON data every INTERVAL seconds
#INTERVAL=30
# assume /etc/logrotate.d/nmon will restart nmon once a day
# run for 1 day + 1 hour since anacron randomizes when logrotate runs
#COUNT=$(( (86400 + 3600) / $INTERVAL ))
#FILENAME=`hostname`.nmon
FILENAME=`hostname`.json
start() {
if [ -f $PIDFILE ]; then
action "Already running!" true
return 0;
else
#$NMON -F $FILENAME -T -s 30 -c $COUNT -m $LOGDIR -p > $PIDFILE
$NJMON -f $FILENAME -s 300 -c 288 -m $LOGDIR -k > $PIDFILE
# just assume nmon started ok; exectue true so the output is correct
action $"Starting njmon: " true
touch /var/lock/subsys/njmon
return 0
fi
}
stop() {
if [ -f $PIDFILE ]; then
action "Shutting down njmon: " kill -s USR2 `cat /var/run/njmon.pid` 2> /dev/null
else
action "Shutting down njmon: " killall -s USR2 $NJMON 2> /dev/null
fi
rm -f /var/lock/subsys/njmon
rm -f $PIDFILE
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status nmon
;;
*)
echo "Usage: nmon {start|stop|restart|status}"
exit 1
;;
esac
exit $?
# service njmon on
---
logrotate.d setting:
```bash
/var/log/njmon/*.json {
olddir old
daily
rotate 15
size 0
nocreate
nocopy
nomail
missingok
extension .json
sharedscripts
prerotate
service njmon stop
endscript
postrotate
service njmon start
endscript
}
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)