創(chuàng)新互聯(lián)建站服務(wù)項(xiàng)目包括瀘水網(wǎng)站建設(shè)、瀘水網(wǎng)站制作、瀘水網(wǎng)頁(yè)制作以及瀘水網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃等。多年來(lái),我們專(zhuān)注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,瀘水網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶(hù)以成都為中心已經(jīng)輻射到瀘水省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶(hù)的支持與信任!
服務(wù)器端:
硬件環(huán)境:
虛擬機(jī)環(huán)境
軟件環(huán)境:
Centos-6.2x86-64
Lamp環(huán)境
Nagios-3.2.0版本
Nagios-plugins-1.4.13插件版本
Pnp-0.4.14版本
Rrdtool-1.2.14版本
Nrpe-2.12版本
客戶(hù)端:
硬件環(huán)境:
物理機(jī)和虛擬機(jī)
軟件環(huán)境:
Linux客戶(hù)端:
linux服務(wù)器端與linux客戶(hù)端監(jiān)控原理:
更多內(nèi)容:http://exchange.nagios.org/directory/p_w_picpath/93
Centos-6.X-x86-64
Nrpe-2.12版本
Windows客戶(hù)端:
Windows2008R2
Windows2003R2
需開(kāi)啟Snmp服務(wù)
服務(wù)器端安裝
一,安裝前準(zhǔn)備:
1,解決perl編譯問(wèn)題:
后面編譯的軟件有perl程序,這里要提前設(shè)置下環(huán)境變量。
批量執(zhí)行命令如下:
echo'export LC_ALL=C'>>/etc/profile
tail-1 /etc/profile
source/etc/profile
echo$LC_ALL
2,關(guān)閉防火墻,安裝完后啟動(dòng)防火墻。
/etc/init.d/iptablesstop
/etc/init.d/iptablesstart
2.1解決系統(tǒng)時(shí)間同步。
echo‘*/5* * * * /usr/sbin/ntpdate time.windows.com’ >>/var/spool/cron/root
[root@nagios~]# crontab -l
*/5* * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1
3,安裝nagios所需基礎(chǔ)軟件包
批量執(zhí)行命令如下:
yuminstall gcc glibc glibc-common -y
yuminstall gd gd-devel -y
yuminstall httpd php php-gd -y
3.1創(chuàng)建nagios需要的用戶(hù)及組
批量命令:
/usr/sbin/useradd-m nagios
/usr/sbin/useraddapache
/usr/sbin/groupaddnagcmd
/usr/sbin/usermod-a -G nagcmd nagios
/usr/sbin/usermod-a -G nagcmd apache
id-n -G nagios
id-n -G apache
groupsnagios
groupsapache
3.2下載軟件包
mkdir -p/server/soft
http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
二,安裝nagios
tarzxf nagios-3.2.0.tar.gz
cdnagios-3.2.0
./configure--with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
提示:如果是編譯安裝的httpd是,可以執(zhí)行./configure--with-command-group=nagcmd --with-httpd-conf=/usr/local/apache2/conf/extra 增加一個(gè)編譯參數(shù)即指定編譯nagios web配置的生產(chǎn)路徑。然后編輯vi/usr/local/apache2/conf/httpd.conf增加 Includeconf/extra/nagios.conf
1,創(chuàng)建nagios web監(jiān)控界面登入時(shí)需要的用戶(hù)名及密碼
htpasswd-c /usr/local/nagios/etc/htpasswd.users admin
輸入密碼即可
cat/usr/local/nagios/etc/htpasswd.users
提示:如果為單獨(dú)編譯的apache,則操作命令如下
/usr/local/apache2/bin/htpasswd-c /usr/local/nagios/etc/htpasswd.users admin
2,添加接收監(jiān)控報(bào)警的email地址
vi/usr/local/nagios/etc/objects/contacts.cfg +35
email nagios@localhost
改為:
email baochengcai@autohome.com.cn
快速命令:
sed-I 's#nagios@localhost#baochengcai@autohome.com.cn#'/usr/local/nagios/etc/objects/contacts.cfg
3,啟動(dòng)郵件服務(wù)。
/etc/init.d/sendmailstart
chkconfigsendmail on
chkconfig--list sendmail
如果sendmail啟動(dòng)比較緩慢,可以修改/etc/hosts
127.0.0.1 nagios localhost.localdomain localhost #增加主機(jī)名hostname
4,配置apache服務(wù)
啟動(dòng)apache并加入系統(tǒng)開(kāi)機(jī)自啟動(dòng):
/etc/init.d/httpdstart
chkconfighttpd on
5,安裝nagios插件軟件包
tarzxf nagios-plugins-1.4.13.tar.gz
cdnagios-plugins-1.4.13
./configure --with-nagios-user=nagios--with-nagios-group=nagios --enable-perl-modules
make
makeinstall
ls /usr/local/nagios/libexec/|wc -l
#編譯如遇到make:***[all] Error 2 則configure 加--with-MySQL=/usr/local/mysql解決
chkconfig nagios on
chkconfig--list nagios
6,驗(yàn)證nagios配置文件(檢查語(yǔ)法)
簡(jiǎn)單方法:/etc/init.d/nagioscheckconfig
[root@nagios~]# /etc/init.d/nagios checkconfig
Runningconfiguration check... OK.
/usr/local/nagios/bin/nagios-v /usr/local/nagios/etc/nagios.cfg
TotalWarnings: 0
TotalErrors: 0
Thingslook okay - No serious problems were detected during the pre-flight check
#Total Warnings:警告和Total Errors:錯(cuò)誤都為0,表示配置正常。
#Total Errors:如果不為0必須解決,否則nagios無(wú)法啟動(dòng)。
#Total Warnings:這個(gè)如果不為0可以啟動(dòng)nagios。
啟動(dòng)nagios服務(wù)
/etc/init.d/nagios start
檢查nagios進(jìn)程:
ps -ef|grep nagios |grep -v grep
檢查selinux是否關(guān)閉
setenforce0
sed-i ' s#SELINUX=enforcing#SELINUX=disabled# ' /etc/selinux/config
getenforce
7,安裝nrpe軟件:
tar zxf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
makeinstall-daemon-config
nagios服務(wù)器端安裝結(jié)束,后續(xù)需要調(diào)整參數(shù)。
**Nagios添加多賬戶(hù)管理
檢查當(dāng)前系統(tǒng)賬號(hào):
[root@nagios ~]# cat /usr/local/nagios/etc/htpasswd.users
admin:HMcYqU.5Bh5bk
xiaomin:$apr1$GFzBDndr$Rd6Qvbc58PCUTPXNjhs8E1
chenkaixiong:$apr1$M6RLaWz8$8Ghi27zHStHaSZ9W1DVgs/
添加系統(tǒng)登錄賬號(hào):
[root@nagios ~]# htpasswd -m/usr/local/nagios/etc/htpasswd.users chengcai
Newpassword:
Re-typenew password:
Addingpassword for user chengcai
[root@nagios etc]# cat /usr/local/nagios/etc/htpasswd.users
admin:HMcYqU.5Bh5bk
xiaomin:$apr1$GFzBDndr$Rd6Qvbc58PCUTPXNjhs8E1
chenkaixiong:$apr1$M6RLaWz8$8Ghi27zHStHaSZ9W1DVgs/
chengcai:$apr1$lXiSe1w4$HxIw6xSwjon5NshKfbbSx0
配置賬號(hào)權(quán)限:
[root@nagios etc]# egrep -v "^#|^$" cgi.cfg
main_config_file=/usr/local/nagios/etc/nagios.cfg
physical_html_path=/usr/local/nagios/share
url_html_path=/nagios
show_context_help=0
use_pending_states=1
use_authentication=1
use_ssl_authentication=0
authorized_for_system_information=nagiosadmin,admin
authorized_for_configuration_information=nagiosadmin,admin
authorized_for_system_commands=nagiosadmin,admin
authorized_for_all_services=nagiosadmin,admin
authorized_for_all_hosts=nagiosadmin,admin
authorized_for_all_service_commands=nagiosadmin,admin
authorized_for_all_host_commands=nagiosadmin,admin
authorized_for_read_only=xiaomin,chenkaixiong,chengcai
#注:只給chengcai賬號(hào)只讀權(quán)限,如果想給該賬號(hào)更多權(quán)限,可根據(jù)配置添加。
default_statusmap_layout=5
default_statuswrl_layout=4
ping_syntax=/bin/ping-n -U -c 5 $HOSTADDRESS$
refresh_rate=90
escape_html_tags=1
action_url_target=_blank
notes_url_target=_blank
lock_author_names=1
客戶(hù)端安裝:-linux:
1,解決perl編譯問(wèn)題:
后面編譯的軟件有perl程序,這里要提前設(shè)置下環(huán)境變量。
批量執(zhí)行命令如下:
yum-y install perl-devel perl
echo'export LC_ALL=C'>>/etc/profile
tail-1 /etc/profile
source/etc/profile
echo$LC_ALL
2,關(guān)閉防火墻,安裝完后啟動(dòng)防火墻。
/etc/init.d/iptables stop
/etc/init.d/iptablesstart
2.1解決系統(tǒng)時(shí)間同步。
echo‘*/5* * * * /usr/sbin/ntpdate time.windows.com’ >>/var/spool/cron/root
[root@nagios~]# crontab -l
*/5* * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2>&1
3,在nagios客戶(hù)端安裝插件
mkdir-p /server/soft
cd/server/soft
rz-y (oldboy_tracining_nagios_soft.zip)#老男孩提供的軟件包。
unzipoldboy_tracining_nagios_soft.zip
3.1安裝nagios-plugins-1.4.13.tar.gz
/usr/sbin/useraddnagios -M -s /sbin/nologin
tarzxf nagios-plugins-1.4.13.tar.gz
cdnagios-plugins-1.4.13
./configure --with-nagios-user=nagios--with-nagios-group=nagios --enable-perl-modules
make
makeinstall
ls /usr/local/nagios/libexec/|wc -l
#編譯如遇到make:***[all] Error 2 則configure 加--with-mysql=/usr/local/mysql解決
3.2,安裝nrpe軟件:
tarzxf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
makeinstall-daemon-config
3.3安裝其他相關(guān)的插件【iostat】
#-----------
tarzxf Params-Validate-0.91.tar.gz
cdParams-Validate-0.91
perlMakefile.PL
make
makeinstall
cd..
#-----------
tarzxf Class-Accessor-0.31.tar.gz
cdClass-Accessor-0.31
perlMakefile.PL
make
makeinstall
cd..
#------------
tarzxf Config-Tiny-2.12.tar.gz
cdConfig-Tiny-2.12
perlMakefile.PL
make
makeinstall
cd..
#-------------
tarzxf Math-Calc-Units-1.07.tar.gz
cdMath-Calc-Units-1.07
perlMakefile.PL
make
makeinstall
cd..
#-----------
tarzxf Regexp-Common-2010010201.tar.gz
cdRegexp-Common-2010010201
perlMakefile.PL
make
makeinstall
cd..
#---------------
tarzxf Nagios-Plugin-0.34.tar.gz
cdNagios-Plugin-0.34
perlMakefile.PL
make
makeinstall
cd..
#-------------
yuminstall sysstat -y
#這個(gè)命令式安裝系統(tǒng)性能分析工具,監(jiān)控系統(tǒng)性能時(shí)程序或腳步會(huì)調(diào)用這些工具。
3.4配置開(kāi)發(fā)的幾個(gè)基本腳本插件
cp /server/soft/nagios/check_memory.pl /usr/local/nagios/libexec/
cp /server/soft/nagios/check_iostat /usr/local/nagios/libexec
chmod 755/usr/local/nagios/libexec/check_memory.pl
chmod 755/usr/local/nagios/libexec/check_iostat
dos2unix/usr/local/nagios/libexec/check_memory.pl
dos2unix/usr/local/nagios/libexec/check_iostat
3.5配置nrpe
cd/usr/local/nagios/etc
vinrpe.cfg +79
加入可以監(jiān)控本機(jī)的nagios server端IP,如下:
allowed_hosts=10.168.0.217
#注:如果機(jī)器大于500臺(tái)做集群或分布式監(jiān)控時(shí),可以使用多個(gè)nagiosserver-,ip要用逗號(hào)隔開(kāi)。
#可用一條命令執(zhí)行?!?/p>
#perl -pi -e's/allowed_hosts=127.0.0.1/allowed_hosts=10.168.0.245/g'/usr/local/nagios/etc/nrpe.cfg
grep allowed_host/usr/local/nagios/etc/nrpe.cfg
更改nrpe配置文件信息。
cd /usr/local/nagios/etc
vi nrpe.cfg (shift+g切換到結(jié)尾)#注釋掉或者干脆刪除199-203行,同時(shí)在下面新添加要監(jiān)控的內(nèi)容。
command[check_load]=/usr/local/nagios/libexec/check_load-w 15,10,5 -c 30,25,20
command[check_mem]=/usr/local/nagios/libexec/check_memory.pl-w 10% -c 3%
command[check_disk]=/usr/local/nagios/libexec/check_disk-w 15% -c 7% -p /
command[check_swap]=/usr/local/nagios/libexec/check_swap-w 20% -c 10%
command[check_iostat]=/usr/local/nagios/libexec/check_iostat-w 6 -c 10
#-c為嚴(yán)重報(bào)警
啟動(dòng):nagios client
/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
ps-ef|grep nagios
netstat-lnt|grep 5666
lsof-I :5666
#重啟client端nagios nrpe服務(wù)的組合命令
pkill nrpe &&/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
客戶(hù)端安裝:-windows:
windows:
添加服務(wù):
添加完snmp服務(wù)后對(duì)服務(wù)進(jìn)行設(shè)置.
打開(kāi)本地服務(wù):
右鍵屬性,添加團(tuán)體名和監(jiān)控主機(jī)IP地址.
啟動(dòng)服務(wù)即可。