NCPA 설치
rpm -Uvh https://repo.nagios.com/nagios/8/nagios-repo-8-1.el8.noarch.rpm
yum update
yum install epel-release -y
yum config-manager --enable powertools
yum install ncpa -y
cd /tmp
wget https://assets.nagios.com/downloads/ncpa/check_ncpa.tar.gz
tar xvf check_ncpa.tar.gz
chown nagios:nagios check_ncpa.py
chmod 775 check_ncpa.py
mv check_ncpa.py /usr/local/nagios/libexec
파이썬 설치
yum install gcc openssl-devel bzip2-devel libffi-devel wget
wget https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tgz
tar xzf Python-3.9.4.tgz
cd Python-3.9.4
./configure --enable-optimizations
make altinstall
ls -la /usr/local/bin
Python3.9 확인
vi /etc/shells
/usr/local/bin/python3.9 //추가
vi /root/.bashrc
alias python="/usr/local/bin/python3.9" //추가
source /root/.bashrc
python3.6 -V
Python 3.9.8 //버전 확인
cd /usr/local/nagios/libexec/
vi check_ncpa.py
첫 번째 라인 #!/usr/local/bin/python3.9로 변경
저장 후 ./check_ncpa.py 작동확인
Nagios 적용
vi /usr/local/nagios/etc/resource.cfg
$USER10$=1234 // 임의 토큰 인수 추가
cd /usr/local/nagios/libexec
./check_ncpa.py -H 172.30.85.204 -t 1234 -M cpu/percent -q aggregate=avg -w 90 -c 95 // 작동 확인
※ -H 호스트명,주소 -t 토큰 -M 매트릭 -w 경고 -c 위험
vi /usr/local/nagios/etc/nrpe.cfg
command[check_ncpa_cpu]=/usr/local/nagios/libexec/check_ncpa.py -H $HOSTADDRESS$ -t $USER10$ -M cpu/percent -w 20 -c 40 -u G
vi /usr/local/nagios/etc/objects/commands.cfg
define command {
command_name check_ncpa_cpu
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ -t $USER10$ -P 5693 -M cpu/percent -w 20 -c 40 -q aggregate=avg
}
서버적용
vi /usr/local/nagios/etc/objects/localhost.cfg
define service{
use local-service
host_name localhost
service_description CPU Usage
check_command check_ncpa_cpu
}
호스트적용
vi /usr/local/nagios/etc/objects/test.cfg
define service{
use local-service
host_name test
service_description CPU Usage
check_command check_ncpa_cpu
}
systemctl restart ncpa_listener
systemctl restart nagios
'OS > Linux' 카테고리의 다른 글
Redis 모니터링 정책 및 가이드 (0) | 2021.10.18 |
---|---|
Redmine 재시작 (0) | 2021.10.18 |
LINKDING - docker로 github 소스 받아오기 (node.js 12, php7.3 설치하기) (0) | 2021.08.24 |
[Centos 8] Nagios Core - Windows 설정 (0) | 2021.06.02 |
[Centos] Bookmark manager 구축 하기 (0) | 2021.06.02 |