ʹÓÃPHP»ñÈ¡Íø¿¨ÊµÊ±Á÷Á¿´ø¿íʹÓÃÇé¿ö
ÏÖÔڵķþÎñÆ÷¾³£Óжà¸öÍø¿¨£¬»òÕßµ¥¸öÍø¿¨µ«Êǰ󶨶à¸öIP£¬ËùÒÔÐéÄâ³öºÜ¶à¸öÉ豸³öÀ´£¬Ôõôͳ¼ÆÕâÕų̂·þÎñÆ÷µÄʵʱÁ÷Á¿Çé¿öÄØ¡£ÕâÀïÌṩ¸öShell½Å±¾ÓÃÀ´Í³¼Æ·þÎñÆ÷ʵʱÁ÷Á¿Çé¿ö¡£
- ʵÏÖÔÀí£º
[root@localhost ~]$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo:1068205690 1288942839 0 0 0 0 0 0 1068205690 1288942839 0 0 0 0 0 0
eth0:91581844 334143895 0 0 0 0 0 145541676 4205113078 3435231517 0 0 0 0 0 0
proc/net/dev Îļþ±£´æÁËÍø¿¨×ÜÁ÷Á¿ÐÅÏ¢£¬Í¨¹ý¼ä¸ôÒ»¶Î¼ä¸ô£¬½«ÈëÍø¿¨Óë³ö¼Ç¼¼ÓÆðÀ´¡£¼õȥ֮ǰ¾ÍµÃµ½Êµ¼ÊËÙÂÊ¡£
phpʵÏÖ´úÂ룺
<?php $dev = $argv[1]?$argv[1]:"eth0"; while(true){ $result = file_get_contents("/proc/net/dev"); preg_match("/{$dev}:(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)/", $result, $preg_arr); $lastre = $thisre; $lasttr = $thistr; $thisre = $preg_arr[1]; $thistr = $preg_arr[2]; $re = hbw($thisre - $lastre); $tr = hbw($thistr - $lasttr); echo "\33[2J"; printf("\33[1;1H%-12sss\n", 'Device', 'In', 'Out'); printf("\33[2;1H%-12sss\n", $dev, $re, $tr); sleep(1); } function hbw($size) { $size *= 8; if($size > 1024 * 1024 * 1024) { $size = round($size / 1073741824 * 100) / 100 . ' Gbps'; } elseif($size > 1024 * 1024) { $size = round($size / 1048576 * 100) / 100 . ' Mbps'; } elseif($size > 1024) { $size = round($size / 1024 * 100) / 100 . ' Kbps'; } else { $size = $size . ' Bbps'; } return $size; } ?>˵Ã÷£º¼ÆËã×ÜÁ÷Á¿²îµÃµ½Æ½¾ùÿÃëÁ÷Á¿¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ