㈠ linux下的mrtg使用
對於Mrtg就不多說了,在網上很容易就找到其各方面的詳細資料,也可以上http://www.mrtg.org 查看官方文檔。下面我就說說我的安裝過程:
在安裝過程中用到的軟體:
libpng-1.2.8.tar.gz2
zlib-1.2.3.tar.gz
jpegsrc.v6b.tar.gz
freetype-2.1.10.tar.gz
fontconfig-2.3.0.tar.gz
gd-2.0.33.tar.gz
mrtg-2.12.2.tar.gz
我的環境是RedHat 9.0,先來准備安裝GD庫
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure
你可以在輸出的信息中看見如下面的字樣:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: yes
Support for pthreads: yes
如果你的都是yes的話,那麼就可以直接make && make install,然後安裝mrtg了。如果有no的話,那麼還需要安裝相應的支持軟體。因為我的系統在安裝的時候只選擇安裝了kernel devlopment tools,所以我需要安裝上述的支持軟體。
首先升級我的zlib庫
******************************************
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
******************************************
然後安裝libpng庫
*******************************************
tar -jxvf libpng-1.2.8.tar.gz2
cd libpng-1.2.8
cp scripts/makefile.std makefile
make
make install
*******************************************
Ok,Wait for a moment...接下來安裝JPEG庫
*******************************************
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --enable-static --enable-shared --prefix=/usr
make
make install
*******************************************
安裝Freetype
*******************************************
tar -zxvf freetype-2.1.10
cd freetype-2.1.10
./configure
make
make install
*******************************************
安裝Fontconfig
*******************************************
tar -zxvf fontconfig-2.3.0
cd fontconfig-2.3.0
./configure
make
make install
*******************************************
Xpm library在安裝X Window的時候就安裝好了,但是我在安裝獨立的Xpm庫的時候會提示錯誤。索幸我就沒有安裝了,暫時還沒有發現未安裝此庫會有什麼影響。
好了,進入gd-2.0.33,輸入./configure,輸出結果為:
** Configuration summary for gd 2.0.33:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: no
Support for pthreads: yes
嗯,接著當然就是
make && make install
Ok,GD庫安裝完成,下來才是我們真正觀注的了
tar -zxvf mrtg-2.12.2.tar.gz
cd mrtg-2.12.2
./configure --prefix=/usr/local/mrtg --with-gd=/usr/include --with-gd-lib=/usr/lib --with-gd-inc=/usr/include --with-png=/usr/include --with-png-lib=/usr/lib --with-zlib=/usr/include --with-zlib-lib=/usr/lib
make
make install
到這里Mrtg已被成功的安裝到你的系統,
假設我們要監控的交換機IP為:192.168.1.10 ,我的Apache主目錄是/var/www/html
首先來生成cfg文件
/usr/local/mrtg/bin/cfgmaker public at 192 dot 168.1.10 > /var/www/html/mrtg.cfg
打開mrtg.cfg
更改WorkDir為/var/www/html
去掉Options[_]: growright, bits前面的#
並加入Language:Chinese使之支持中文
保存並退出
接著運行/usr/local/mrtg/bin/mrtg /var/www/html/mrtg.cfg (如需在命令前加env LANG=C 在執行的時候系統會給出提示)
連續執行三次以上直到不再顯示錯誤為止
後執行/usr/local/mrtg/bin/indexmaker --output=/var/www/html/index.html --title=標題 /var/www/html/mrtg.cfg 生成頁面文件
啟動你的Apache,訪問看看吧~!哈哈,成功的感覺來啦
為了讓數據自動刷新,還需要讓程序在後台定時運行,
crontab -e
在其中輸入 */5 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /var/www/html/mrtg/mrtg.cfg (註:如之前未加env LANG=C的話,則這里也不用加)
該句表示讓系統在後台每五分鍾執行一次env LANG=C /usr/local/mrtg/bin/mrtg /var/www/html/mrtg/mrtg.cfg
即每5分鍾刷新一次
另外還可以在mrtg.cfg中加入腳本,用於監控CPU,MEM,SWAP的使用情況
㈡ 在Linux安裝以.tar.gz安裝MRTG,在make是出錯
先make
dep
或執行make
clean避免錯誤,然後./configure
./configure
--prefix=/usr/local/mrtg-2
//這個在你裝了所有的庫文件的前提下,
然後沒有報錯,那就make
㈢ linux下監控伺服器有哪些
linux下監控軟體有很多啊 一般常用的是以下三種
mrtg----》》》 監控流量,cup負載,tcp連接數,磁碟空間等等 一般用來做流量監控,配置簡單
nagios--->>>> 用來監控主機與服務存活狀態,也可以監控負載與磁碟空間等等,帶郵件 與簡訊告警,配置稍微復雜點。
cacti----》》》強大的繪圖功能,十分漂亮,插件無數,可監控幾乎所有內容,缺點是安裝配置復雜,但現在有一鍵安裝盤,方便的很。
另外還有一個在國外用的很多的監控軟體:zabbix 這個也是非常強大的,沒裝過,你可以試試。
㈣ 關於LINUX下安裝SNMP時出現的錯誤
無數LINUX技術
你看看http://www.computersky.com/main/html/lists/25.htm
㈤ Linux下用MRTG監控區域網流量
對
但是現在幾乎99%的交換機和路由器都支持,其實就是rfc1213
㈥ linux下MRTG安裝(詳細步驟)以及需要的軟體包和關聯軟體包
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
學習linux的話最好還是練練英文,因為你會用到很多英文文檔,這是一個長期自發學習的過程,不是幾個shell命令就可以通行的,軟體的官方文檔是你最應該留意的資料!
㈦ linux 伺服器需要監控哪些
linux下監控軟體有很多啊 一般常用的是以下三種
mrtg----》》》 監控流量,cup負載,tcp連接數,磁碟空間等等 一般用來做流量監控,配置簡單
nagios--->>>> 用來監控主機與服務存活狀態,也可以監控負載與磁碟空間等等,帶郵件 與簡訊告警,配置稍微復雜點。
cacti----》》》強大的繪圖功能,十分漂亮,插件無數,可監控幾乎所有內容,缺點是安裝配置復雜,但現在有一鍵安裝盤,方便的很。
另外還有一個在國外用的很多的監控軟體:zabbix 這個也是非常強大的,沒裝過,你可以試試。
㈧ linux mrtg 頁面在哪個文件夾
MRTG最早的版本是在1995年春天所推出,以Perl所寫成,因此可以跨平台使用,它利用了SNMP送出帶有物件識別碼(OIDs)的請求給要查詢的網路設備,因此設備本身需支援SNMP。MRTG再以所收集到的資料產生HTML檔案並以GIF或PNG格式繪制出圖形,並可以日、周、月等單位分別繪出。它也可產生出最大值最小值的資料供統計用。
㈨ linux中安裝了一個插件,這個插件裝完後正常的情況在終端輸入./phpxujh -p pid可查看當前PID的運行情況,
目錄
開始之前
系統環境
監控內容
所需軟體包
CentOS7重要變化
配置開發環境
同步時間
關閉Selinux
使用CRT上傳軟體包
安裝郵件服務
監控主機安裝
常用到的命令
安裝nagios所需要的運行環境
增加用戶
安裝nagios
配置許可權
安裝插件
安裝nrpe
遠程主機安裝
常用到的命令
配置運行環境
安裝nagios-plugin
安裝nrpe
啟動nrpe
監控主機安裝PNP
配置開發環境
安裝pnp4nagios (版本號為0.6)
配置pnp4nagios
圖表展示
問題集合
在首次配置了nagios監控端後,在瀏覽器輸入地址後連接不上
啟動nrpe後卻不能互相通信
安裝pnp4nagios後出現The requested URL /pnp4nagios/graph was not found on this server.
出現「CHECK_NRPE: Error - Could not complete SSL handshake.」的錯誤
執行 ./configure時報錯:configure error cannot find ssl headers
解壓./configure 後,在nagios-4.0.8進行make all報錯
安裝nrpe時執行.configure出錯
錯誤:perfdata directory "/usr/local/pnp4nagios/var/perfdata/" is empty
開始之前
聲明:本文中的命令都經過了測試,但難免有所紕漏,如果你發現命令粘貼後運行有錯,可能是由於符號的格式(尤其是破折號)導致的,此時你應該自己手打一遍命令。對於本文中發現的錯誤和建議,請發送郵件給我:
[email protected],請在郵件主題里註明「關於nagios的問題(建議)」。
--------------------------------------分割線 --------------------------------------
在Ubuntu下配置Mrtg監控Nginx和伺服器系統資源 http://www.linuxidc.com/Linux/2013-08/88417.htm
使用 snmp+Mrtg 監控 Linux 系統 http://www.linuxidc.com/Linux/2012-11/73561.htm
Mrtg伺服器搭建(監控網路流量) http://www.linuxidc.com/Linux/2012-07/64315.htm
網路監控器Nagios全攻略 http://www.linuxidc.com/Linux/2013-07/87067.htm
Nagios搭建與配置詳解 http://www.linuxidc.com/Linux/2013-05/84848.htm
Nginx環境下構建Nagios監控平台 http://www.linuxidc.com/Linux/2011-07/38112.htm
在RHEL5.3上配置基本的Nagios系統(使用Nagios-3.1.2) http://www.linuxidc.com/Linux/2011-07/38129.htm
CentOS 5.5+Nginx+Nagios監控端和被控端安裝配置指南 http://www.linuxidc.com/Linux/2011-09/44018.htm
Ubuntu 13.10 Server 安裝 Nagios Core 網路監控運用 http://www.linuxidc.com/Linux/2013-11/93047.htm
--------------------------------------分割線 --------------------------------------
系統環境
一共3台機器,全都按照CentOS7最小化模式安裝系統
系統版本號
[root@localhost ~]# cat /etc/RedHat-release
CentOS Linux release 7.0.1406 (Core)
監控主機
(一台)
IP地址:192.168.1.204
主機名稱:nagios_server_204
遠程主機
(兩台)
IP地址:192.168.1.112
主機名稱:nagios_slave_112
IP地址:192.168.1.113
主機名稱:nagios_slave_113
分區情況
安裝時使用默認分區(使用 df 命令來查看)
[root@localhost ~]# df -h
監控內容
要監控的服務
監控命令
cpu負載
(check_linux_state.pl -C)
當前用戶登錄數量
(check_users)
磁碟使用情況
(check_disk)
總進程數
(check_procs)
內存使用情況
(check_linux_stats.pl -M)
負載均衡
(check_load)
磁碟IO
(check_linux_stats.pl -I)
網路流量
(check_linux_stats.pl -N)
打開的文件數量
(check_linux_stats.pl -F)
socket連接數
(check_linux_stats.pl -S)
進程使用的內存和CPU
(check_linux_stats.pl -T)
指定的網站是否可連接
(check_http)
系統在線時長
(check_uptime)
所需軟體包
監控主機
軟體包
下載地址
nagios-4.0.8.tar.gz
請到我的github地址里下載:
https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_server
註明:我的github項目install_nagios_automatically是一個一鍵自動化安裝nagios的項目(能運行,但還在完善中)
nagios-plugins-2.0.3.tar.gz
nrpe-2.15.tar.gz
pnp4nagios-0.6.25.tar.gz
Sys-Statistics-Linux-0.66.tar.gz
libxml2-2.7.1.tar.gz
遠程主機
軟體包
下載地址
nagios-plugins-2.0.3.tar.gz
請到我的github地址里下載:
https://github.com/Kylinlin/install_nagios_automatically/tree/master/nagios_tools_for_client
nrpe-2.15.tar.gz
Sys-Statistics-Linux-0.66.tar.gz
Centos7重要變化
Centos7相比較以前的Centos有一些涉及到常用命令的變化,如果不事先了解,會在使用命令的時候造成巨大的困擾
Centos7默認沒有ifconfig和netstat兩個命令了,ip addr命令代替了ifconfig,只要安裝上net-tools包就可以繼續使用ifconfig和netstat兩個命令了
systemctl命令的出現(systemctl可以看作是service和chkconfig的組合),雖然仍然可以使用以前的命令,但是會重定向到新的命令中,下面以http服務為例
job
以前的系統
CentOS7
服務開機啟動
chkconfig --level 3 httpd on
systemctl enable httpd.service
服務不開機啟動
chkconfig --level 3 httpd off
systemctl disable httpd
服務狀態
service httpd status
systemctl status httpd
所有服務的啟動狀態
chkconfig --list
systemctl
啟動服務
service httpd start
systemctl start httpd.service
停止服務
service httpd stop
systemctl stop httpd.service
重啟服務
service httpd restart
systemctl restart httpd.service
配置開發環境
同步時間
把監控系統里的所有機器都同步一次網路時間(非常重要)
[root@localhost ~]timedatectl #該命令用來檢查當前時間和時區
如果發現所有機器的時區不一致,此時就要使用命令
[root@localhost ~]timedatectl list-timezones #該命令列出了所有的時區
[root@localhost ~]timedatectl set-timezone Asia/Shanghai #該命令把時區設置為上海
ntpdate time.nist.gov #該命令同步網路當前的時間
如果提示沒有ntpdate命令,則安裝ntp,並且配置系統自動更新時間
[root@localhost ~]# yum install ntp -y
[root@localhost ~]# /usr/sbin/ntpdate time.nist.gov
[root@localhost ~]# echo '#time sync'>>/var/spool/cron/root
[root@localhost ~]# echo '*/10**** /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1'>>/var/spool/cron/root
關閉Selinux
不關閉selinux可能會導致一些難以察覺的錯誤,為了保險起見,首先關閉selinux:
[root@localhost ~]vi /etc/selinux/config
重啟機器
檢查selinux是否關閉:
[root@localhost ~]getenforce #如果顯示enforcing則沒有關閉
使用SecureCRT上傳軟體包
我在這里使用的SSH連接工具是SecureCRT7.2,通過這個工具上傳文件到Linux的步驟如下:
1. 首先在Linux中安裝傳送文件命令:
[root@localhost ~] yum install lrzsz -y
2. 然後在Linux中跳轉到/usr/local/src目錄下
[root@localhost ~] cd /usr/local/src
3. 運行CRT的傳送文件命令
安裝郵件服務
因為郵件報警服務需要安裝mail功能
[root@localhost ~]yum install –y mailx
[root@localhost ~]yum install –y sendmail
[root@localhost ~]systemctl restart sendmail.service
[root@localhost ~]mail –s Test [email protected](你的郵箱地址)
#此時進入輸入模式,輸入完郵件內容後按ctrl + d退出並且發送
監控主機安裝
常用到的命令
命令內容
命令格式
檢查nagios的配置文件是否有錯
/etc/init.d/nagios checkconfig
或者
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
啟動nagios
systemctl start nagios.service
或者
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
修改了nagios的配置文件後重新載入配置文件
/etc/init
安裝nagios所需要的運行環境
[root@localhost ~]# yum install gcc glibc glibc-common -y
[root@localhost ~]# yum install php php-gd perl -y
[root@localhost ~]# yum install httpd gd gd-devel openssl openssl-devel -y
[root@localhost ~]# systemctl enable httpd.service #設置CentOS開機啟動服務
增加用戶
[root@localhost ~]useradd -m nagios
並將nagios以及apache用戶加入到nagcmd組中
[root@localhost ~]groupadd nagcmd
[root@localhost ~]usermod -G nagcmd nagios
[root@localhost ~]usermod -a -G nagcmd apache #把apace用戶添加到與nagios的一個組(apache用戶會在安裝apache時自動創建)
安裝nagios
[root@localhost src]# tar -zxvf nagios-4.0.8.tar.gz
[root@localhost src]# cd nagios-4.0.8
首先初始化和建立編譯的環境
[root@localhost nagios-4.0.8]#./configure --with-command-group=nagcmd
如果能看到下面的基本配置信息則說明初始的環境已經成功配置完成:
之後按照提示執行命令來進行編譯:
[root@localhost nagios-4.0.8]# make all
[root@localhost nagios-4.0.8]# make install
[root@localhost nagios-4.0.8]# make install-init
[root@localhost nagios-4.0.8]# make install-config
[root@localhost nagios-4.0.8]# make install-commandmode
[root@localhost nagios-4.0.8]# make install-webconf
安裝完成之後,在/usr/local/nagios目錄下如果能夠看到這些目錄:
就表示Naigos安裝成功了。
Nagios的樣例配置文件默認安裝在/usr/local/nagios/etc目錄下,配置這些文件就可以使得nagios按要求運行(詳細的配置過程請參考我的另一篇博文:nagios服務配置詳解)
此時應該為email指定您想用來接收nagios警告信息的郵件地址,默認是本機的nagios用戶:
[root@localhost]# vi /usr/local/nagios/etc/objects/contacts.cfg
email nagios@localhost #把描紅的地方修改為你的email地址
創建一個登錄nagios web程序的用戶(用戶名配置為nagiosadmin則不需要配置許可權,設置為其他用戶名就要配置許可權),我在這里把用戶名設置為kylinlin,密碼為123456,這個用戶帳號在以後通過web登錄nagios認證時所用:
[root@localhost ~]# htpasswd -bc /usr/local/nagios/etc/htpasswd.users kylinlin 123456 #把描紅的地方修改為你的用戶名和密碼
配置許可權
如果在上面創建登陸nagios web程序的用戶名不是nagiosadmin(我在上面已經設置為kylinlin),在登陸nagios的web界面後(此時我們還不能登錄,但如果你忽略了這一小節的配置,那麼在後面的登陸中就會看到如下的界面),點擊Hosts或Services會顯示圖片紅色的錯誤提示
是因為nagios默認把全部的許可權給nagiosadmin,所以可以通過修改cgi.cfg文件賦予kylinlin許可權,切換到/usr/local/nagios/etc目錄下
[root@localhost etc]# sed -i 's#nagiosadmin#kylinlin#g' cgi.cfg #這條命令將nagiosadmin用戶名替換為kylinlin
[root@localhost etc]# grep kylinlin cgi.cfg #這條命令檢查是否修改成功
以上過程配置結束以後需要重新啟動httpd:
[root@localhost etc]# systemctl restart httpd.service
檢查其主配置文件的語法是否正確:
[root@localhost etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
或者使用下面這個命令來檢查語法
[root@localhost etc]# /etc/init.d/nagios checkconfig
顯示錯誤數為0才正確
配置成功
安裝插件
剛才已經提到Nagios主程序只是一個控制中心,而能夠起到服務監測和系統監測等功能的是眾多Nagios的插件,沒有插件的Nagios系統其實只是一個空殼。因此在安裝了Nagios平台之後我們還需要安裝插件。
Nagios插件同樣是在其官方網站下載,目前版本是1.4.15。我將下載的源碼包放到/usr/local目錄下,按照下面的步驟進行解壓,編譯和安裝:
[root@localhost src]# tar zxf nagios-plugins-2.0.3.tar.gz
[root@localhost src]# cd nagios-plugins-2.0.3
[root@localhost nagios-plugins-2.0.3]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@localhost nagios-plugins-2.0.3]#make
[root@localhost nagios-plugins-2.0.3]#make install
通過下面的命令查看安裝了多少個插件
[root@localhost nagios-plugins-2.0.3]#ls /usr/local/nagios/libexec/|wc -l
然後把Nagios加入到服務列表中以使之在系統啟動時自動啟動:
[root@localhost nagios-plugins-2.0.3]# chkconfig --add nagios
[root@localhost nagios-plugins-2.0.3]# chkconfig nagios on
執行下面的命令來驗證Nagios的樣例配置文件:
[root@localhost ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
㈩ 請高手指導一下在Linux下安裝MRTG。
chmod +x mrtg
試試看,
我不恨明白。