2015年12月14日 星期一

一些有關raid-check用的指令和參數

一些有關raid-check用的指令和參數

每秒觀看各CPU內核使用率
#watch -n1 mpstat -P ALL -u 1 10000

每秒觀看目前Raid的狀態
#watch -n1 cat /proc/mdstat

影響raid-check運行速度的參數
#sysctl dev.raid.speed_limit_min
#sysctl dev.raid.speed_limit_max

目前Software Raid的錯誤數 (Number)
#echo /sys/block/md1/md/mismatch_cnt
目前raid-check的動態 (Check/Idle)
#echo /sys/block/md1/md/sync_action

raid-check的設定檔
#vi /etc/sysconfig/raid-check
raid-check的執行檔 
#/usr/sbin/raid-check
raid-checkcronjob
/etc/cron.d/raid-check

改變目前speed_limit_max speed_limit_min
#echo 200000 > /proc/sys/dev/raid/speed_limit_max
#echo 5000 > /proc/sys/dev/raid/speed_limit_min
或是
#sysctl -w dev.raid.speed_limit_max=100000
#sysctl -w dev.raid.speed_limit_min=1000
但這個都是暫時性的,要永久性請修改 /etc/sysctl.conf,增加以下兩句
#vi /etc/sysctl.conf
增加
dev.raid.speed_limit_max = 100000
dev.raid.speed_limit_min = 50000
   

平時使用 #raid-check 執行檢查,又或是依照Cronjob設置的時間去做檢查。
又或者 #echo check > /sys/block/md1/md/sync_action 去啟動檢查

要停止時,可使用 #echo idle > /sys/block/md1/md/sync_action 去暫停。

可對raid-check進行一些參數上設置
#vi /etc/sysconfig/raid-check
範例
ENABLED=yes
CHECK=check
NICE=low
# To check devs /dev/md0 and /dev/md3, use "md0 md3"
CHECK_DEVS=""
REPAIR_DEVS=""
SKIP_DEVS=""

裡面有個NICE參數,和其他Linux指令的NICE參數一樣,可以設定IO讀寫時的Priority。預設值為low,最低級為Idle

結論:
raid-check所需要用到的CPURAM並不多,以R410作為實驗例子,以NICE=lowspeed_limit_max=5000000去運行,實際運作是230MB/sCPU最多用到99,但是只會用到其中一核。

注意#echo /sys/block/md1/md/mismatch_cntraid-check並不會主動修復一致性檢查中發現的不同步問題,要使用者自行修復。




2015年11月23日 星期一

Synology NAS Root Login

相信應該有人跟我一樣,NAS上的Surveilliance Station,因某些原因而讓該刪除掉的視頻,變成有權限問題。 所以造成刪除檔案時出現權限不足。

可以使用Root登入去刪除

先在圖形介面把SSH服務啟動起來。

控制台 > 終端機 > 啟動SSH功能

如果防火牆有限制的話,把防火牆設定一下,容許SSH登入。 沒開防火牆就算了。

然後使用putty或類似軟件,以root登入,密碼和admin密碼相同。

登入後,先 cd .. 退上一層,會看到整個NAS系統目錄。

而我們使用的檔案會存放於 volumn1 中。

看你要刪除甚麼檔案,刪除指令是 rm 。


2015年9月16日 星期三

Speedtest-cli.py 測試 (Linux下使用Command 做 Speedtest)

http://www.speedtest.net/ 這個網站相信就算平時不怎麼懂網路的人,也會知道。這是一個很有名的測速網站。 你的網速如何,從這兒可以得到一個很準確的參考。可是這個是GUI介面,用Browser的,現在介紹一下如果在Linux的Command Line底下,怎樣使用Speedtest.net做測試。

首先你要有 speedtest-cli.py 這個程式。可以參考以下網址:
https://pypi.python.org/pypi/speedtest-cli/

又或是懶點

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli

或者沒wget的話

curl -Lo speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli

這東西是用 Python寫成的,所以你要有Python安裝在你的電腦或服務器上。一般Mac和CentOS用戶,預設應有Python,所以不用太擔心。

請使用 python -V 或 python --version 去檢查版本, speedtest-cli 需要 python 2.4以上版本。

輸入 ./speedtest-cli去執行,不輸入任何參數的話,他會去找最接近(最快)的服務器去測試。


你也可以輸入 speedtest-cli --server [SERVER_ID] 去指定測試Server,至於ID,你可以使用 speedtest-cli --list 去 Retrieve出來。



我是比較喜歡 http://www.speedtest.net/speedtest-servers.php  去查找需要的Server。

 用用看吧,很方便呢。



2015年6月12日 星期五

Fortigate 不同型號間的Firewall Configuration 檔案轉換

來源: http://kb.fortinet.com/kb/documentLink.do?externalID=10063

Technical Tip : How to load/convert a FortiGate configuration
file from one unit to another (file conversion for a different model).
This article explains how to transfer a FortiGate configuration file to a new 
FortiGate unit of a different model. 
1.  Open the backup configuration file from the previous and different FortiGate Unit.
2.  Download a backup of a new configuration file from the new unit. This procedure is 
different depending on which FortiOS version is running on the FortiGate:
In FortiOS 3.0, 4.0, 4.1.x, download a factory default configuration file from  
System>Maintenance>Backup&Restore
In FortiOS 4.2 download a factory default configuration file from 
System>Dashboard>System Information>System Configuration
3.  From the factory default configuration file copy the "config-version", and paste this value 
and replace in the backup of the previous configuration file.
Make sure that all interface names correspond to the new device.  For example, the previous 
unit may have had a "wan1" interface however the new device has a "port1" interface, it is 
critical to make sure these correspond.
Save the new configuration file under a new .conf file. This step is mandatory otherwise when 
reloading the new configuration file the error message "configuration file error" will be displayed 
on the web based interface.
Only copy the "config-version" section of the first line of the config file from the device being 
copied. In this way, upon conversion to the new device, the correct "vdom" and "opmode" 
settings will be applied.
4.  Verify which user admin account was used when saving the configuration file. Reloading a 
configuration that was saved under a super_admin account to a simple admin account will 
display the error message "invalid username or password on the web based interface.
5.  On the new FortiGate unit, go to System > Status, select Restore, and upload the edited 
config file to the new unit.  The unit restarts automatically.
6.  Test the configuration.
It must be noted that modifying .conf files in this manner will not ensure that all profiles will be 
saved. This is particularly true if this procedure is used for .conf files being used on a different 
versions of FortiOS. For example, reloading a .conf file to a FortiGate running FortiOS 4.1 
from a .conf file using FortiOS 4.2, any new profiles related to new FortiOS features will be lost.



以下是Ivan的測試結果:
文章說可以從FortiOS4.2備出的Conf檔,回復至4.1的設備上面,但我沒有測試到,4.2的檔能不能放到5.0上,理論上應該是不行的。

我測試過,同版本,不同Model的Fortigate,Conf檔需要用上述方法去解決。

案例: 5.0 build0292,我故意將兩個Fortigate都上成同一版本OS,一隻是Fortigate60C,一個是FortiWifi60D,任務是將60C的Conf檔,轉到60D身上。

一開始,把60C的Conf備份出來,直接套到60D身上Restore,結果出現Configuration File Error。 用文章提及方法,將60D的Conf備份出來(不一定是Factory Default),然後以文字編輯軟件打開,把裡面第一行 #config-version=FW........ 整行拷貝出來,貼到60C的Conf裡相同位置。

再將這個修改過的60C Conf檔,restore到60D中,結果就成功了。

要注意的是,文章也有提及過,如果Interface的名稱不一樣,就會出現大問題,例如60D轉去300D,因為300D沒有WAN1 WAN2的概念,所以就有問題。


16,Sep-2015
實際上,如果你要將一個舊Firewall的4.0 設定檔,以這種方法轉換成5.0能跑的設定檔,是能成功上載上去,亦很不幸地他會自動將不兼容的東西修復甚至Overwrite。造成很多隱藏問題。 最好的解決方法,還是以人手以CLI形式,檢查並貼到新設備中,然後再作修改。



2015年5月20日 星期三

Fortigate V5.0 Switch mode to interface mode

一時失憶,忘記了怎樣將新的Fortigate 從 Switch mode 變成 interface mode. 因為新到的Fortigate預設都是 所有internal互通的。

一開始 要先連接本機與Fortigate的Internal 1,並使用 https://192.168.1.99 進入管理介面。 進去後,把Interface Wan2的 HTTPS打開,再把網線接到WAN2,再用https://192.168.101.99 進入管理介面。

把Internal 的 DHCP Server Disable掉,把Policy關於Internal 的Policy delete掉。

回到Interface, 再Internal上按右鍵,叫出選單,點擊Change Mode。 如下圖。(下圖為已轉好的畫面)



2015年1月8日 星期四

iPhone 將照片從 相簿 移到 電腦

我不知道這問題,是常態還是不正常。 我收到一個將iPhone4s 轉移資料到 iPhone6的任務。雖然我不熟,但當然也知道,使用iTunes將i4s備份,再將備份轉移到i6。但結果發現,照片的備份,只備份到"相機膠卷",即Camera Roll的內容,在相簿內的照片,卻沒有備份到,想當然i6也沒有i4s相簿裡面的照片。

用iTunes或Image Capture都無法將相簿裡面的照片,導出來。上網找方法,發現坊間都是用第三方軟件,把資料直接導出來。

以下是我試用過的軟件心得和注意事項。

PhotoTrans
http://www.imobie.com/phototrans/download.htm

免費下載,試用版本,首次使用可以免費導出50張照片。
缺點是導出來的資料,不是原本的資料,即是照片的詳細內容會不見,尤其是日期,所以如果你很重視照片的拍攝日期,就不該用PhotoTrans。

iMazing
http://imazing.com/

免費下載,試用版本,首次使用可以免費導出100張照片。
和PhotoTrans一樣的價錢,但導出來的照片,可以把照片的詳細資料一併導出,所以就是有拍攝日期啦。


iTools
http://tw.gashplus.com/iTools/Download

免費正式版本,導出音樂和照片應該是最簡單的一個軟件,照片的詳細資料均如實導出,很不錯。必需先安裝iTunes,才能讀取蘋果系列手機。
缺點是只有Windows版本。









2015年1月2日 星期五

Apple iPhone 的 Voice Over無法關閉?

我肯定有一個熱鍵,或一個方法,讓iPhone使用者可以把VoiceOver莫名奇妙的叫出來!


VoiceOver 是iPhone一個相當重要的功能,讓視力有問題的用家,也可以順利地使用手機,但沒用過VoiceOver的朋友,相信就這功能啟動後,一定會變成iPhone使用障礙。

首先,當VoiceOver啟動後,手指在屏幕上滑動時,每停留一個點,手機就會朗讀那點所存在的資訊,例如文字,按鈕;選定按鈕或連結或任何一個功能時,雙擊能使用該功能。滑動需要三隻手指手勢。

所以,當VoiceOver因不明原因啟動了以後,因為會完全改變使用者使用iPhone的手勢習慣,極致時可能讓使用者不能操作手機。

好吧,今天碰到一個情況,一位女仕的iPhone6,VoiceOver功能突然啟動了,手機於是不斷說話,不斷說話,但最壞是,在輔助選項裡的VoiceOver選項,不能取消,強迫啟動著,就算重啟手機也不能還原。

上網找了一個方法,但必需使用iTunes。

手機連上iTunes,在iPhone「摘要」或「Summary」裡,右邊顯示了iPhone的詳細資料,右邊頁面拉到最下,出現輔助選項選單,裡面有選項 「VoiceOver」「Zoom」「Neither」,但它們竟然是Radio Button! 意味著VoiceOver和Zoom只能二擇其一。 只要選擇 Neither,就可以兩樣都不啟動,VoiceOver無法關閉的問題也隨之解決。

但是,為甚麼會不能關閉呢?奇怪。

相關資料:
https://www.apple.com/hk/accessibility/ios/voiceover/




Google