真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Nagios安裝設(shè)置

公司服務器越來越多了,本來用一個腳本去檢測了,現(xiàn)在改用Nagios

茶陵ssl適用于網(wǎng)站、小程序/APP、API接口等需要進行數(shù)據(jù)傳輸應用場景,ssl證書未來市場廣闊!成為成都創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場價格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:13518219792(備注:SSL證書合作)期待與您的合作!

ubuntu 客戶端安裝腳本

#!/bin/bash
tmp_dir=/tmp/nagios
nagios_ser="192.168.1.3"
groupadd nagios   
useradd -g nagios -s /sbin/nologin nagios
if [ ! -d $tmp_dir ]; then
    mkdir $tmp_dir
fi
cd $tmp_dir
wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.1.tar.gz
#---- install
for i in `ls -1`
    do tar xf $i
done
apt-get -y --force-yes install openssl ruby1.9.1 build-essential
apt-get -y --force-yes install libssl-dev lm-sensors
tar xvf nagios-plugins-2.0.1.tar.gz
cd nagios-plugins-2.0.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make    
make install
cd ../
tar xvf nrpe-2.15.tar.gz
cd ./nrpe-2.15
./configure --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all    
make install-plugin    
make install-daemon    
make install-daemon-config
#mv ./check_* /usr/local/nagios/libexec
#chmod 755 -R /usr/local/nagios/libexec
chown -R nagios:nagios /usr/local/nagios/
cat >/usr/local/nagios/etc/nrpe.cfg<> /etc/rc.local
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
rm -rf $tmp_dir

自己折騰的ruby腳本,

1:check_smart 磁盤狀態(tài)檢測

#!/usr/bin/env ruby
#0 ok; 1 warning; 2 critical; 3 unknown
#echo "nagios ALL=NOPASSWD:/usr/sbin/smartctl" >>/etc/sudoers
#CentOS sed -i "s:Defaults  requiretty:Defaults:nagios !requiretty:" /etc/sudoers
#調(diào)用 check_nrpe!check_smart
health = ""
`ls -1 /dev/sd[a-z]* | grep [a-z]$`.split.each do |hdd|
  status = `sudo /usr/sbin/smartctl -H #{hdd} | grep result | awk -F: '{print $2}'`
  if status.match(/PASSED/)
    health = health + hdd + "  OK\n"
  else
    health = health + hdd + "  Fail\n"
  end
end
if health.include? "Fail"
        puts health
        exit 2
end
puts health
exit 0

2:check_mdadm 軟陣列檢測

#!/usr/bin/env ruby
#0 ok; 1 warning; 2 critical; 3 unknown
status = `cat /proc/mdstat`
if status.scan('U').size == status.scan('md').size * 2
    puts "Soft Raid OK"
    exit 0
else
    puts "Soft Raid Fail"
    exit 2
end

3:check_drbd DRBD檢測

#!/usr/bin/ruby
#0 ok; 1 warning; 2 critical; 3 unknown
if `cat /proc/drbd`.scan("UpToDate").count == `ls -la /dev/ | grep ^b | grep drbd | wc -l`.to_i * 2
    puts "DRBD OK"
    exit 0
else
    puts "DRBD Critical"
    exit 2
end

4:check_alldisk 檢測磁盤空間

#!/usr/bin/env ruby
#ARGV[1] min ,ARGV[3] max
# -w 90 -c 95
#0 ok; 1 warning; 2 critical; 3 unknown
space = ''
status = `df -hl -x tmpfs -x devtmpfs | grep -v ^Filesystem`.split
if status.size < 6 #unkown
    puts "UNKOWN"
    exit 3
end
(status.size / 6).times do |x|
    current_use, min_use, max_use = status[4 + x * 6][0..-2].to_i, ARGV[1].to_i, ARGV[3].to_i
    if  current_use > max_use #critical
        space = space + status[x * 6] + "  " + status[4 + x * 6] +  "  " + status[5 + x * 6] +"  Critical\n"
    elsif current_use > min_use and current_use <= max_use #warning
        space = space + status[x * 6] + "  " + status[4 + x * 6] +  "  " + status[5 + x * 6] + "  Warning\n"
    elsif  current_use <= min_use #ok
        space = space + status[x * 6] + "  " + status[4 + x * 6] +  "  " + status[5 + x * 6] + "  OK\n"
    end
end
if space.include?("Crtitical")
    puts space
    exit 2
elsif space.include?("Warning")
    puts space
    exit 1
else
    puts space
    exit 0
end

服務器安裝參考


分享標題:Nagios安裝設(shè)置
路徑分享:http://weahome.cn/article/ggeesh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部