vnstat 流量統計 並附帶一個小 php 查看流量的頁面

來源:互聯網
上載者:User

標籤:png   配置   logs   add   order   author   sys   alt   blog   

安裝
apt-get install vnstat

配置到自動啟動
update-rc.d vnstat enable

啟動
/etc/init.d/vnstat start



vnstat基本使用命令

vnstat -i eth0 -l #即時資料流量情況
vnstat -i eth0 -h #按小時查詢流量情況
vnstat -i eth0 -d #按天數查詢流量情況
vnstat -i eth0 -m #按月數查詢流量情況
vnstat -i eth0 -w #按周數查詢流量情況
vnstat -i eth0 -t #查詢TOP10流量情況

php流量的頁面 ,實現原理太簡單了,直接調用 命令顯示到網頁上,這樣也挺好,不用每次打命令了。

 1 <style> 2 h1{text-align:center; /*author:ningci dev date:2017-04-27 22:21*/} 3 *{background-color:#000; color:#fff;} 4 pre{margin:10px;padding:10px;border:1px solid #00f; color:#f6c608;} 5 </style> 6 <h1>rel time network status !</h1> 7 <h3>day</h3> 8 <pre> 9 <?php10 echo system("vnstat -i eth0 -d");11 ?>12 </pre>13 <h3>hour</h3>14 <pre>15 <?php16 echo system("vnstat -i eth0 -h");17 ?>18 </pre>19 20 <h3>month</h3>21 <pre>22 <?php23 echo system("vnstat -i eth0 -m");24 ?>25 </pre>

 

使用比較簡單,直接放到 apache 中,然後就能訪問了,顯示的內容也很有用,每日,每月,每小時使用方式。

後期,有時間在做美化,加個 發郵件通知等功能。

 

vnstat 流量統計 並附帶一個小 php 查看流量的頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.