2011年11月8日 星期二

MRTG可以丟了...Monitorix登場!

monitorix
簡單的安裝步驟,只需yum幾個套件即可馬上使用,但須注意以下幾點:
1.預設不開放其他網段登入,更改/etc/httpd/conf.d/monitroix.conf改allow from all後httpd restart
2.安裝完畢記得也須httpd restart
3.注意yum套件是否安裝落實,如果沒有的話rpm -ivh monitorix-n.n.n-1.noarch.rpm會有相依性錯誤訊息

安裝設定步驟:
1.#yum install httpd rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI
2.#rpm -ivh http://www.monitorix.org/monitorix-2.5.1-1.noarch.rpm (注意官網是否有更新版)
日後更新可用rpm -Uvh即可!
3.#vi /etc/httpd/conf.d/monitroix.conf (更改瀏覽權限)
4.#vi /etc/monitorix.conf(monitroix設定檔)
our $TITLE = "Place a Title Here";#更改網頁瀏覽器標頭名稱
our $HOSTNAME = "";#更改主機名稱
5.#service monitorix start (chkconfig可考慮是否加入)
6.#service httpd restart

http://localhost/monitroix (登入)

2011年11月2日 星期三

CentOS 5.6 install MRTG(Webmin)

1.#yum -y install net-snmp net-snmp-utils mrtg
2.進入webmin MultiRouterTrafficGrapher>MRTG Configuration>Run
如果出現下方ERROR......line 352錯誤訊息請進行下列更改...
#vi /etc/snmp/snmpd.conf
把第89行#拿掉
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
在第62行修改
access notConfigGroup "" any noauth exact systemview none none
變成
access notConfigGroup "" any noauth exact mib2 none none
#service snmpd restart
3.webmin MultiRouterTrafficGrapher>MRTG Configuration>Delete File
4.webmin MultiRouterTrafficGrapher>MRTG Configuration>Add Host
5.webmin MultiRouterTrafficGrapher>MRTG Configuration>Run
6.View WorkDir:/var/www/mrtg是否有相關html出現

#vi /etc/mrtg/webmin.cfg
RunAsDaemon: Yes
Interval: 5

2011年10月4日 星期二

VM抓不到第二張網卡

今天在VirtualBox CentOS6新增了第二張網卡發生了怪問題,reboot後用setup指定卻找不到eth1網卡,dmesg|grep eth1時發現了這段話" udev: renamed network interface eth1 to eth2",Google後發現是因為MAC Address會被鎖定在/etc/udev/rules.d/70-persistent-net.rules,只要將此檔案刪除後reboot即可(文獻說service network restart也可以,但我卻失敗= =)!

2011年9月15日 星期四

系統監控

最近找到了兩套還不錯的免費系統監控
1.PC Monitor Link
可安裝於LINUX與WINDOWS上,利用Web、iPhone、Andorid遠端監控,免費版本只能監控三台機器,功能分非常強大,可監控硬體、登出入、軟體安裝、event事件等級等發出警示或是線上監控!
2.Tagbeep Link
監控網站是否offline,並發出郵件或是簡訊通知(支援台灣),免費版本單日似乎只能發出5次簡訊

2011年8月12日 星期五

封包側錄_windump

因工作上需求找到了windump這工具,tcpdump只能用在Linux上,如果是windows就需要此工具,
安裝上還算簡單,需要winpcap and windump即可。
操作方式為command mode下執行windump,以下為常用指令:

查看目前網卡有幾張,每張網卡介面前有依序編號
#windump -D
1.\Device\NPF_{F3E23777-3BA2-4E9F-80A6-F7955BCA6E33} (Microsoft)
2.\Device\NPF_{6BB81C9E-A51A-4DE0-9BBA-E6F3918D9FFC} (Broadcom NetXtreme Gigabit
Ethernet Driver)
3.\Device\NPF_{E9F63A7F-508B-4877-B7C2-0FF758A70444} (Microsoft)
4.\Device\NPF_{541E2CE7-9BB6-4D4E-A56E-D877E4FF5B1B} (Sun)
5.\Device\NPF_{F4247049-70B5-4F45-BB9E-DD048281D137} (Microsoft)

通過埠80從介面#2記錄所有流量
#windump -i 2 port 80

記錄所有從the host www.123.com到介面#2的流量   
#windump -i 2 host www.123.com
  
-i 2>監聽第二張網卡 -n>不將IP轉換成電腦名稱 udp>監聽udp dst>目的地為第二張網卡 test.txt>顯示結果寫入test.txt(建議加入-q參數會使寫入檔案變小一點)
#windump -i 2 -n udp dst port 514 > 222.txt
如果改成-w 會將擷取封包內容寫入(注意檔案內容會很大),-C 5就可限制寫入檔案最大為5MB、-c 10擷取封包數量為10

2011年8月11日 星期四

Linux備份工具Clonezilla

Clonezilla此工具由國人開發,可備份以及還原Linux(含EXT4)或Windows系統,目前實際測試過利用USB隨神碟開機(Clonezilla有出USB專用工具),將Linux備份至網路磁碟(SMB),再由網路磁碟之image線上直接還原,相關資料請參考以下兩個Link。
http://clonezilla.nchc.org.tw
http://hc.cyc.edu.tw/exe/clonezilla_live/

2011年8月1日 星期一

判別網卡為哪張

現今Server動不動就是兩張網卡以上,如何判別哪張網卡為eth0或是eth1呢,以下有兩個方式可以查出!

#ethtool -p eth1 30
使用此指令命令eth1閃燈30秒

#mii-tool
[root]# mii-tool
SIOCGMIIREG on eth0 failed: Input/output error
eth0: negotiated 100baseTx-FD flow-control, link ok
SIOCGMIIREG on eth1 failed: Input/output error
eth1: no link
從此可看出eth0目前是有Link上的,eth1無連線。

2011年7月22日 星期五

CentOS install Openwebmail

須手動安裝Text-Iconv,不可安裝RPM檔案,否則初始化openwebmail會有錯誤訊息!
官網雖有教學yum安裝方式,但卻缺檔案= =
安裝完後記得縮短連結網址

# vi /etc/httpd/conf/httpd.conf

ScriptAlias /mail "/var/www/cgi-bin/openwebmail/openwebmail.pl"

#service httpd restart

2011年6月20日 星期一

Postfix轉寄設定

公司Mail server是postfix,因Android使用K9這套軟體收mail很耗電,所以我使用轉寄至Gmail方式會比較方便,此舉僅需修改/etc/aliases即可!

#vi /etc/aliases
(原帳號) (轉寄帳號須設定一個原帳號在加上轉寄帳號,如無設定原帳號local會無mail)
tony: tony@123.com.tw tony@gmail.com

#postalias hash:/etc/aliases

Check UDP port

在Linux下使用nmap檢查UDP port是否有開
[root@mail ~]# nmap -p 514 -sU -P0 192.168.1.6

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-06-20 10:25 CST
Interesting ports on mail.gits.com.tw (192.168.1.6):
PORT STATE SERVICE
514/udp open|filtered syslog

2011年6月7日 星期二

Windows目錄共享安全性

預設的windows目錄共享查看指令
#net share
刪除共享指令
#net share c$ /d
可寫script放在啟動區來刪除

2011年5月19日 星期四

強制cp覆蓋並不顯示提示

預設Linux系統的cp已被宣告"cp -i"
如果要暫時跳脫此宣告可用#\cp xxx xxxx
這樣可以不顯示擾人的覆蓋提示

2011年4月11日 星期一

查看Linux系統幾位元

常遇到客戶不知道是灌32位元還是64位元作業系統,可以用此命令來查詢!
#getconf LONG_BIT

2011年4月1日 星期五

補安裝X window

如果想在現有CentOS系統下安裝Xwin只要兩個指令即可!
#yum groupinstall "X Window System"

#yum groupinstall "GNOME Desktop Environment"

2011年3月25日 星期五

新增Windows啟動批次檔(關閉休眠程式產生的暫存檔)

今天幹了個蠢事,新增了一個批次檔之後手動執行居然會loop,搞了半天原來是我指令和檔名相同,這樣會導致一直呼叫自己= =

這次批次檔作用是為了要手動移除休眠程式產生的暫存檔,因Acer的Power managet程式都會呼叫休眠程式啟動,導致C槽每次開機都會出現約三G的暫存檔,指令如下:

#powercfg -h off

2011年3月22日 星期二

利用SecureCRT傳輸檔案

當遠端連至Linux系統想傳輸檔案可利用SecureCRT Xmodem功能,但前提需安裝lrzsz,這是一個在 unix 平台下使用 zmodem 協定的檔案傳輸工具!

傳送檔案至本機
#sz xxx.xxx

接收檔案
#rz

2011年3月17日 星期四

rc.local debug

當rc.local沒有執行預期中的動作可以依照下方方式來找出問題,通常是指令打錯居多!
To be sure rc.local is being called just append to it a line for debugging:
echo $(date) - Running >> /var/test.run
Reboot and check /var/test.run

To check your scripts errors just use:
/path/to/script > /var/myscript.log 2>&1
This will make sure the output and errors will be written to /var/myscript.log

修改完畢執行#sh /etc/rc.d/rc.local即可測試不用重新開機!

CentOS mount VirtualBox share folder

手動指令
#mount -t vboxsf 共用資料夾名稱 /自建目錄
注意"共用資料夾名稱"可在VirtualBox>裝置>共用資料夾>名稱看到,此指令重開機後就無效。

如果要每次開機自動mount上去,似乎只要安裝過Guest Additions後,可在/media內找到共用目錄。

更新:
這次安裝CentOS6可能是少勾選幾個套件,所以安裝Guest Additions比較麻煩:
1.選擇裝置>安裝Guest Additions
2.#mount /dev/cdrom1 /mnt (先確認是否在VB上設定好光碟機)
3.#yum install -y kernel-devel-2.6.....(因執行VboxLinusAddtions.run告知要安裝)
4.#/mnt/VboxLinusAddtions.run
安裝過程出現Installing the Windows System drivers[FAILED]可以無需理會

2011年3月2日 星期三

設定瀏覽器搜尋引擎為google語法

http://www.google.com.tw/search?hl=zh-TW&q=%us >>>台灣
http://www.google.com/search?hl=en&q=%us >>>美國
由此可見%us是搜尋關鍵字代碼!

2011年2月28日 星期一

Maxthon3匯出我的最愛

目標:Maxthon3我的最愛匯出至Google瀏覽器,並用Google瀏覽器線上備份
做法:
1.Maxthon3匯出我的最愛成html
2.Maxthon2匯入html
3.Maxthon2匯出至IE
4.Google瀏覽器匯入IE我的最愛並同步線上備份

好麻煩的做法,都怪Maxthon3不可以匯出至IE,Google瀏覽器也不支援匯入Maxthon3,只好匯來匯去= =

2011年2月25日 星期五

Maxthon3瀏覽OpenWebMail

當使用Maxthon3瀏覽公司OpenWebMail 2.53用html格式發信卻無顯示時,要至Maxthon選單>選項>進階設定>自訂User agent改成Firefox後重開瀏覽器即可!

2011年2月24日 星期四

安裝VirtualBox Guest Additions至CentOS 5.5

#yum install gcc kernel sources kernel-deve
#reboot
#sh /media/VBoxLinuxAdditions.run