溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量

發(fā)布時(shí)間:2021-08-05 18:16:01 來源:億速云 閱讀:135 作者:chen 欄目:系統(tǒng)運(yùn)維

這篇文章主要講解了“怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量”吧!

Multi Router Traffic Grapher------MRTG是一個(gè)監(jiān)控網(wǎng)絡(luò)鏈路流量負(fù)載的工具軟件,通過snmp協(xié)議得到設(shè)備的流量信息,并將流量負(fù)載以包含PNG格式的圖形的HTML 文檔方式顯示給用戶,以非常直觀的形式顯示流量負(fù)載。
SNMP(imple Network Management Protocol,簡單網(wǎng)絡(luò)管理協(xié)議)的前身是簡單網(wǎng)關(guān)監(jiān)控協(xié)議(SGMP),用來對通信線路進(jìn)行管理。隨后,人們對SGMP進(jìn)行了很大的修改,特別是加入了符合Internet定義的SMI和MIB:體系結(jié)構(gòu),改進(jìn)后的協(xié)議就是著名的SNMP。SNMP的目標(biāo)是管理互聯(lián)網(wǎng)Internet上眾多廠家生產(chǎn)的軟硬件平臺(tái),因此SNMP受Internet標(biāo)準(zhǔn)網(wǎng)絡(luò)管理框架的影響也很大。現(xiàn)在SNMP已經(jīng)出到第三個(gè)版本的協(xié)議,其功能較以前已經(jīng)大大地加強(qiáng)和改進(jìn)了。

下面來看一下其在Linux系統(tǒng)上的安裝方法:

(1)必須安裝snmp

代碼如下:


rpm -qa|grep snmp* //查看是否安裝了snmp
yum -y install snmp* //安裝snmp
#vim /etc/snmp/snmpd.conf
rocommunity public  //配置snmpv1模式
disk / 13102744     //配置系統(tǒng)的大小
disk /data 41279536 //配置數(shù)據(jù)盤的大小
service snmpd start //配置開啟snmp
chkconfig snmpd on  //設(shè)置開機(jī)啟動(dòng)


(2) 安裝mrtg

代碼如下:


yum -y install mrtg*


(3)配置mrtg

代碼如下:


//配置就是一個(gè)模板,大家只要把IP修改成自己的 內(nèi)存修改成自己的大小就可以了 我是在本地測試的
HtmlDir:   /data/wwwroot/mrtg  //這里是你網(wǎng)站的html地址  默認(rèn)為 /var/www/mrtg
ImageDir:  /data/wwwroot/mrtg   //這里是存放地址  默認(rèn)為 /var/www/mrtg
LogDir:    /var/lib/mrtg
ThreshDir: /var/lib/mrtg
#
#[網(wǎng)絡(luò)流入流出圖]
#
Target[eth0_lan]: /118.244.182.176:public@localhost
Options[eth0_lan]:growright
Language:utf8
Directory[eth0_lan]:eth2
MaxBytes[eth0_lan]: 5000000
Title[eth0_lan]: eht0流入流出圖
Kmg[eth0_lan]:K,M,G
YLegend[eth0_lan]:Bytes per Second
ShortLegend[eth0_lan]:B/s
Legend1[eth0_lan]:每秒流入量
legend2[eth0_lan]:每秒流出量
legendI[eth0_lan]:流入
legendO[eth0_lan]:流出
PageTop[eth0_lan]: <H1>網(wǎng)卡流入流程圖</H1>
PageFoot[eth0_lan]:<a href="www.kemok4.com">jb51 Inc</a>
#
#[CPU的負(fù)載]
#
Target[cpuload]:.1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0:public@localhost:
Options[cpuload]:nopercent,growright
Language:utf8
Directory[cpuload]:cpu
MaxBytes[cpuload]:100
Unscaled[cpuload]:dwym
Ylegend[cpuload]:CPU Utilization
Shortlegend[cpuload]:%
legend1[cpuload]:CPU用戶負(fù)載(%)
legend2[cpuload]:CPU閑置(%)
legendI[cpuload]:用戶
legendO[cpuload]:閑置
Title[cpuload]:CPU負(fù)載
PageTop[cpuload]:<h2>Cpu負(fù)載【用戶+閑置】</h2>
PageFoot[cpuload]:<a href="www.kemok4.com">jb51 Inc</a>
#
#[內(nèi)存使用]
#
Target[memory]:.1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@localhost:
Options[memory]:gauge,growright
Directory[memory]:mem
Language:utf8
MaxBytes1[memory]:514908
MaxBytes2[memory]:2096472
Kmg[memory]:K,M,G
kilo[memory]:1024
Unscaled[memory]:dwym
YLegend[memory]:Memory Btyes
ShortLegend[memory]:B
Legend1[memory]:已用Mem(Bytes)
Legend2[memory]:已用Swap(Bytes)
LegendI[memory]:已用Mem:
LegendO[memory]:已用Swap
Title[memory]:內(nèi)存使用率
PageTop[memory]:<h2>內(nèi)存使用量(Mem+Swap)</h2>
PageFoot[memory]:<a href="www.kemok4.com">jb51 Inc</a>
#
#[硬盤使用率]
#
Target[disk]:.1.3.6.1.4.1.2021.9.1.8.1&.1.3.6.1.4.1.2021.9.1.8.2:public@localhost:
Options[disk]:gauge,growright
Language:utf8
Directory[disk]:disk
MaxBytes1[disk]:13102744
MaxBytes2[disk]:41279536
Kmg[disk]:K,M,G
Kilo[disk]:1024
Ylegend[disk]:Disk Bytes
Shortlegend[disk]:B
legend1[disk]:系統(tǒng)磁盤已用空間
legend2[disk]:數(shù)據(jù)盤已用空間
legendI[disk]:系統(tǒng)已用
legendO[disk]:數(shù)據(jù)已用
Title[disk]:硬盤空間使用率
PageTop[disk]:<h2>硬盤空間[系統(tǒng)盤+數(shù)據(jù)盤]</h2>
PageFoot[disk]:<a href="www.kemok4.com">jb51 Inc</a>
#================================================================================
#監(jiān)控系統(tǒng)負(fù)載[1分鐘+15分鐘]
#================================================================================
Target[systemload]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.3:public@localhost:
Options[systemload]: gauge,nopercent,growright
Directory[systemload]: load
MaxBytes[systemload]: 3000
YLegend[systemload]: System Load
ShortLegend[systemload]:
Legend1[systemload]: 最近1分鐘系統(tǒng)負(fù)載(x100)
Legend2[systemload]: 最近15分鐘系統(tǒng)負(fù)載(x100)
LegendI[systemload]: 1分鐘負(fù)載:
LegendO[systemload]: 15分鐘負(fù)載:
Title[systemload]: 系統(tǒng)負(fù)載(x100)[1分鐘+15分鐘]
PageTop[systemload]:<h2>系統(tǒng)負(fù)載(x100)[1分鐘+15分鐘]</h2>
#================================================================================
#監(jiān)控打開的TCP連接數(shù)[TCP連接數(shù)]
#================================================================================
Target[tcpopen]: .1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost:
Options[tcpopen]: gauge,nopercent,growright
Directory[tcpopen]: tcpopen
MaxBytes[tcpopen]: 1000
YLegend[tcpopen]: Tcp Connections
ShortLegend[tcpopen]: 個(gè)
Legend1[tcpopen]: 打開的TCP連接數(shù)(個(gè))
Legend2[tcpopen]:
LegendI[tcpopen]: TCP連接數(shù):
LegendO[tcpopen]:
Title[tcpopen]: TCP連接數(shù)[TCP連接數(shù)]
PageTop[tcpopen]:<h2> TCP連接數(shù)[TCP連接數(shù)]</h2>


(4)設(shè)置啟動(dòng)和corntab
mrtg安裝好后就已經(jīng)在 /etc/cron.d/下有一個(gè)mrtg的文件了 我們只需要修改

代碼如下:


*/2 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok  //每兩分鐘 執(zhí)行一次


第一次執(zhí)行會(huì)有錯(cuò)誤 所以我們必須手動(dòng)執(zhí)行三次 沒錯(cuò)誤就可以了

代碼如下:


LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok


(5)我們到目錄下生成index文件

代碼如下:


/usr/local/mrtg/bin/indexmaker /etc/mrtg/mrtg.cfg --output=/data/wwwroot/mrtg/index.html  --title="自己起名"


效果如下
怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量

感謝各位的閱讀,以上就是“怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對怎么在Linux系統(tǒng)上安裝MRTG來監(jiān)控網(wǎng)絡(luò)流量這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI