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

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

基于nagios網(wǎng)絡(luò)監(jiān)控----腳本-創(chuàng)新互聯(lián)

一:寫bash腳本時候經(jīng)常用到的顏色代碼

10年積累的網(wǎng)站建設(shè)、成都做網(wǎng)站經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有大柴旦免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
COLOR_SUCCESS=$(echo -en "[url=file://\\033[1;32m]\\033[1;32m[/url]" )
COLOR_FAILURE=$(echo -en "[url=file://\\033[1;31m]\\033[1;31m[/url]" )
COLOR_WARNING=$(echo -en "[url=file://\\033[1;33m]\\033[1;33m[/url]")
COLOR_NORMAL=$(echo -en "[url=file://\\033[0;39m]\\033[0;39m[/url]")

二:自動化部署簡介

   由于服務(wù)器數(shù)量的不斷增加,面對數(shù)以千計的需要做Nagios 監(jiān)控的客戶端,自動化部署就會被提上日程了,自動化部署最簡單的是把安裝時的命令通過腳本組合在一起,再加上一些成功與否的判斷

Nagios server 端Nagios服務(wù)器自動安裝腳本部署腳本

#!/bin/sh
#====================================
# $Name:         nagios-server-install.sh
# $Revision:     1.0
# $Function:     install the nagios monitor
# $Author:       zangyunchao
# $organization: 洛陽理工&zzu
# $Create Date:  2013.05
#====================================
#顏色設(shè)置
COLOR_SUCCESS=$(echo -en "[url=file://\\033[1;32m]\\033[1;32m[/url]" )
COLOR_FAILURE=$(echo -en "[url=file://\\033[1;31m]\\033[1;31m[/url]" )
COLOR_WARNING=$(echo -en "[url=file://\\033[1;33m]\\033[1;33m[/url]")
COLOR_NORMAL=$(echo -en "[url=file://\\033[0;39m]\\033[0;39m[/url]")
yum -y install httpd gcc gcc-c++ glibc glibc-common gd gd-devel
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
cd /usr/local/src
wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar zxvf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure --with-command-group=nagcmd --prefix=/usr/local/nagios
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cd ../
tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
cd ../
tar zxvf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
htpasswd -bc /usr/local/nagios/etc/htpasswd.users xiaozang333
xiaozang333
#為nagios登錄名和密碼要牢記
echo "alias nagioscheck='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg' " >> /root/.bashrc
source /root/.bashrc
chkconfig nagios on
chkconfig httpd on
service httpd start
service nagios start
service sendmail start

Nagios Client 端《linux系統(tǒng)》部署腳本

腳本一

#!/bin/sh
#====================================
# $Name:         nagios-server-install.sh
# $Revision:     1.0
# $Function:     install the nagios monitor
# $Author:       zangyunchao
# $organization: 洛陽理工&zzu
# $Create Date:  2013.05
#====================================
useradd nagios
cd /usr/local/src
wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar zxvf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure
make
make install
chown nagios:nagios /usr/local/nagios
chown -R nagios:nagios /usr/local/nagios/libexec
cd ../
tar zxvf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
sed -i 's@allowed_hosts=127.0.0.1@allowed_hosts=114.112.11.11@' /usr/local/nagios/etc/nrpe.cfg
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local

nagios服務(wù)監(jiān)控端增加window主機腳本(windows系統(tǒng))

## script begins here
#! /bin/bash
echo "Enter Host Name"
read name
echo "Enter IP Address of $name"
read ip_add
echo "
define host{
use windows-server //使用的主機組名
host_name $name //主機名
alias $name //主機別名
}

nagios監(jiān)控系統(tǒng)內(nèi)存

#!/bin/sh
#====================================
# $Name:         sysmem_check.sh
# $Revision:     1.0
# $Function:     This Nagios plugin can be check linux system memory status
# $Author:       zangyunchao cp from Shundong Zhao
# $organization: UnixHot
# $Create Date:  2010-06-10
#====================================
USAGE_Method="$(basename $0) [-w|--warning]  [-c|--critical] "
USAGE_Value="WARNING value must be large than CRITICAL value: `basename $0` $*"
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
#設(shè)置Nagios要求的狀態(tài)
if [ $# -lt 4 ];then
echo
echo "Usage: $USAGE_Method"
echo
exit 0
fi
while [ $# -gt 0 ];do
case "$1" in
-w|--warning)
shift
WARNING=$1
;;
-c|--critical)
shift
CRITICAL=$1
;;
esac
shift
done
if [[ $WARNING -eq $CRITICAL || $WARNING -lt $CRITICAL ]]
then
echo
echo "$USAGE_Value"
echo
echo "Usage: $USAGE_Method"
echo
exit 0
fi
FREE_MEM=$(free -m | grep - | awk -F ' ' '{print $4}')  #取當前未使用的內(nèi)存,注意是未使用!
TOTAL_MEM=$(free -m | grep Mem | awk -F ' ' '{print $2}') #取當前系統(tǒng)總內(nèi)存
PERCENT=$(bc <<< "scale=2;$FREE_MEM/$TOTAL_MEM" | tr '^.' ' ') #使用bc輸出百分比
if [ "$PERCENT" -le "$CRITICAL" ] #如果監(jiān)測百分比小于等于用戶設(shè)置的嚴重錯誤值,返回2
then
echo "CRITICAL - $FREE_MEM MB ($PERCENT%) Free Memory"
exit 2
fi
if [ "$PERCENT" -le  "$WARNING" ]  #如果百分比小于等于用戶設(shè)置的警告值就警告并返回1
then
echo "WARNING - $FREE_MEM MB ($PERCENT%) Free Memory"
exit 1
fi
if [ "$PERCENT" -gt "$WARNING" ] #如果百分比大于用戶設(shè)置的警告值就輸出OK返回0
then
echo "OK - $FREE_MEM MB ($PERCENT%) Free Memory"
exit 0
fi

nagios client 被監(jiān)控端-----for linux系統(tǒng)

#/bin/bash
clear
echo "========================================================================="
echo "Welcome to UnixHot Linux Monitor"
echo "zangyunchao graduation created"
echo ""
echo "UHLM v1.0 client by UnixHot "
echo "========================================================================="
echo ""
echo "For more information please visit http://www.unixhot.com/"
echo ""
SOFTWARE_PATH=/usr/local/src
PACKAGE1=gcc
PACKAGE2=glibc
PACKAGE3=xinetd
#PACKAGE4=gd
download(){
echo "==================Start download Nagios Client package==========="
cd $SOFTWARE_PATH
wget
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
chmod +x nagios-plugins-1.4.14.tar.gz
chmod +x nrpe-2.12.tar.gz
echo "Download packages finished!"
echo "================================================================="
}
nagios-plugins(){
echo "=======================install Nagios-plugins====================="
cd $SOFTWARE_PATH
useradd -s /sbin/nologin nagios
tar zxvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure
make && make install
}
nrpe(){
echo "=======================install nrpe================================"
cd $SOFTWARE_PATH
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure && make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
}
config(){
echo "=======================Config======================================"
sed -i 's/yes/no/g' /etc/xinetd.d/nrpe
sed -i 's/127.0.0.1/127.0.0.1 '$Nagios_Server'/g' /etc/xinetd.d/nrpe
echo "nrpe 5666/tcp #nrpe" >> /etc/services
chown -R nagios:nagios /usr/local/nagios
/etc/init.d/xinetd restart
sleep 5
netstat -na | grep 5666
echo "************************************************"
echo "If you look the LISTEN 5666 port,Congratulations, Nagios-Client Install are
successful"
echo "************************************************"
}
main(){
rpm -q $PACKAGE1 $PACKAGE2 $PACKAGE3 > /tmp/rpm.log
SOFTWARE_STATUS=`grep 'not installed' /tmp/rpm.log`
if [ -z "$SOFTWARE_STATUS" ];then
echo "Please input the Nagios Server IP Address"
read
echo "The Nagios server ip address is $REPLY"
Nagios_Server=$REPLY
download
nagios-plugins
nrpe
config
else
echo "Please install the following software first!"
echo ""
echo ""
grep 'not installed' /tmp/rpm.log
echo ""
fi
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


網(wǎng)站標題:基于nagios網(wǎng)絡(luò)監(jiān)控----腳本-創(chuàng)新互聯(lián)
本文來源:http://weahome.cn/article/eoppi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部