2014年12月17日 星期三

有關ATI Hydravision消失問題

最近重灌電腦,遇到ATI Hydravision消失問題,在三螢幕變得很麻煩,因為原本好用的Hydragrid不見了,找了一下找到資料說可以安裝這個然後只勾選Hydravision選項即可讓Hydravision選項在Catalyst裡面重新出現。給遇到一樣問題的大家參考。

參考資料
http://forums.amd.com/game/messageview.cfm?catid=454&threadid=173369

2014年11月26日 星期三

robotframework selenium2library

使用robotframework selenium時遇到兩個問題,第一個是使用cron設定排程時pybot無法啟動,後來看了一下應該是PATH的問題,後來使用原始執行緒python -m robot.run取代pybot後解決。第二個問題是browser無法啟動,會顯示Chrome failed to start: exited abnormally。後來找到解決方法是在shell script前面加一行export DISPLAY=:0即可正常執行。

參考資料
setup chromedriver
http://installselenium.blogspot.tw/2013/06/how-to-setupinstall-selenium.html
export DISPLAY=:0
http://stackoverflow.com/questions/6971595/how-to-set-a-cron-job-to-open-a-web-page-in-the-browser-using-crontab
http://stackoverflow.com/questions/23908319/run-selenium-with-crontab-python
python -m robot.run
自己

google sheet 問題

對空白格A1而言
istext(A1)為false
if(A1="",1,0)為1

if(istext(A1),1,0)+if(A1="",1,0)=1

但是在arrayformula之下卻會變成0

我覺得是google sheet的bug

參考資料
自己

2014年11月25日 星期二

windows 7 開機卡住

這兩天遇到一個很詭異的狀況,開機之後卡在"正在啟動windows"然後四個球不出來,嚐試chkdsk無效,修改system32/driver下sys檔也無效,要進入安全模式結果卡在Atipcie64.sys,最後無計可施要重灌居然載入檔案完還是卡在同一個地方。本來都要拆機檢查硬體了,結果拔掉插在USB上面的無線滑鼠dongle居然就可以正常啟動了,浪費了我兩天時間,紀錄一下以便他人參考。

無法正常開機之前最後一個動作是安裝該無線滑鼠的driver。

參考資料
自己

2014年10月30日 星期四

有關mac翻牆問題

最近遇到一個問題是mac要帶去中國翻牆,台灣這邊已經架設好PPTP VPN server,mac也設定好並連上VPN,卻發現IP不是VPN server的IP,翻牆失敗。但是同樣設定windows也設定過好幾台,並沒有遇到這樣的問題,VPN server端也設定all traffic through vpn server。最後search了一下,發現設定好連線之後,要按齒輪,set service order(中文好像是設定服務順序),然後把VPN拖到最上端,就可以讓所有流量都透過VPN傳送了,翻牆成功。

參考資料
http://superuser.com/questions/436434/os-xs-send-all-traffic-over-vpn-connection-seems-to-be-failing

2014年8月20日 星期三

硬碟資料夾毀損無法讀取、參數錯誤、無法磁碟檢查

使用r-studio發現檔案結構都還在,猜測是磁碟分割表損壞。使用testdisk之後修復成功。

參考資料
http://rengo921.blogspot.tw/2008/05/testdisk.html

selenium 無法在背景執行問題

執行selenium測試時遇到一個問題就是一定要在桌面執行而無法在背景執行,造成很大困擾,因為必須保持桌面登入。後來研究了一下想到可能跟權限有關(經測試在桌面的terminal執行可以,ssh連入執行不可),同事研究了一下發現的確是,進入VNC更改使用者即可解決。

參考資料
同事

Dlink DIR-615 正在取得IP問題

將加密WPA密碼類型設成AES即可解決

參考資料
http://www.geekzone.co.nz/forums.asp?topicid=30806

Jenkins文字檔識別問題

使用Jenkins讀入文檔時發現無法讀取出現error,後來發現是使用的notepad++將格式存成了DOS/Windows。解決方法為選取編輯-檔案格式轉換-轉換成UNIX格式即可解決。

參考資料
http://stackoverflow.com/questions/16239551/eol-conversion-in-notepad

2014年7月22日 星期二

Virtualbox 共用資料夾無法symbolic link問題

在寫case的時候遇到無法建symbolic link的問題,顯示唯讀的檔案系統。搜尋了一下發現是virtualbox在win7上的問題,跟管理員權限與virtualbox要打開設訂有關。

Fixing your virtualbox shared folder symlink error

Operations such as installing node.js or python virtualenv to a virtualbox writable shared folder can fail if you try to do this as a linux (ubuntu) virtualbox guest running Windows 7 host.
The cause is symlink permission.
Typical error:
ln -fs out/Release/node node
ln: failed to create symbolic link `node': Read-only file system
It can also be a “Protocol error”.
This happens even if your shared folder is writable.

Fix: Enable symlinks feature in VirtualBox

Run at cmd prompt:
  1.     
  2. VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1  
  3.     
Verify by running:
  1.     
  2. VBoxManage getextradata YOURVMNAME enumerate  
  3.     
If your user belongs to Administrators group then start VirtualBox with “Run as Administrator”!

上面的參數請視情況修改:
  • c:\Oracle\VirtualBox\ : 這是VirtualBox的預設資料夾,如果安裝在不同資料夾,請自行修改。
  • YOURVMNAME : 請修改為你要開啟的VM名稱。
  • YOURSHAREFOLDERNAME :修改為VM設定中共用資料夾的名稱

參考資料
http://www.plumeqi.com/post/VirtualBox-shared-folder-symlin-error.html
http://ahtik.com/blog/2012/08/16/fixing-your-virtualbox-shared-folder-symlink-error/
http://gwokae.mewggle.com/wordpress/index.php/archives/1097

2014年6月26日 星期四

工作排程器使用Powershell監控chkdsk記錄檔(將log檔存至檔案)

想要看chkdsk的結果時,除了可以使用事件檢視器搜尋應用程式chkdsk(自己執行)或者wininit(系統執行),在網路上找到一個方法可以用powershell將log檔抓取出來成文字檔,如此可以方便使用email傳送或自動化。此方法只適用windows vista以上版本,方法如下:

windows鍵+R執行powershell.exe

鍵入

get-winevent -FilterHashTable @{logname="Application"; id= 1001,26214} | ?{$_.providername -match "chkdsk" -or $_.providername -match "wininit"} | fl timecreated, message | out-file C:\chkdskresult.txt

檔案會生成在 C:\chkdskresult.txt

可以自己類推代換路徑

另外如果只要看昨天的事件
先鍵入
$yesterday = (get-date) = (new-timespan -day 1)
再鍵入
get-winevent -FilterHashTable @{logname="Application"; id= 1001,26214; StartTime=$yesterday} | ?{$_.providername -match "chkdsk" -or $_.providername -match "wininit"} | fl timecreated, message | out-file C:\chkdskresult.txt

將上面指令建立一個文字檔並命名為chkdskresult.ps1
再於工作排程器啟動powershell.exe
新增引數 -File "剛剛chkdskresult.ps1的路徑" (前後要保留"")
最後要於powershell內執行Set-ExecutionPolicy RemoteSigned指令並選擇yes (才可開啟指令碼執行)

配合使用email傳送可參考我之前文章

另外chkdsk 搭配 /x 引數可強制卸載磁碟開始掃描

參考資料
自己
http://www.sevenforums.com/tutorials/96938-check-disk-chkdsk-read-event-viewer-log.html
設定時間參數
http://ss64.com/ps/get-winevent.html
可用Powershell排程
http://mqjing.blogspot.tw/2009/01/script-powershell.html
系統上已停用指令碼執行
http://taien.idv.tw/2012/07/25/powershell-%E6%AA%94%E6%A1%88%E7%84%A1%E6%B3%95%E8%BC%89%E5%85%A5%EF%BC%8C%E5%9B%A0%E7%82%BA%E9%80%99%E5%80%8B%E7%B3%BB%E7%B5%B1%E4%B8%8A%E5%B7%B2%E5%81%9C%E7%94%A8%E6%8C%87%E4%BB%A4%E7%A2%BC%E5%9F%B7.html
篩選複數ID
http://technet.microsoft.com/en-us/library/ee177028.aspx
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a637d5c3-6b36-474f-8092-bcdf0f686e3a/multiple-values-for-a-property-in-a-whereobject-filter?forum=ITCG
http://stackoverflow.com/questions/17691893/filterhashtable-filter-by-event-code
out-file
http://technet.microsoft.com/en-us/library/hh849882.aspx
get-content
http://stackoverflow.com/questions/17434151/writing-new-lines-to-a-text-file-in-powershell
replace
http://stackoverflow.com/questions/3403217/how-to-replace-multiple-strings-in-a-file-using-powershell

2014年6月19日 星期四

電腦右鍵選單管理無法開啟電腦管理(磁碟管理)

請進入REGEDIT修改:
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Manage\command]

將預設值改為 mmc.exe %windir%\system32\compmgmt.msc 就可以了

參考資料
http://www.mobile01.com/topicdetail.php?f=300&t=1681759&p=1

2014年6月11日 星期三

世紀帝國二 2.2被遺忘的王朝畫面變色問題

下載下面網址的2.2更新檔,執行FixAOFE.exe選enable windowed mode。apply後退出即可執行視窗化並且調好解析度進入遊戲後會變成全螢幕。

順帶一提的是,此方法會跟Teamviewer衝突導致FC,請執行前務必將Teamviewer結束。

參考資料
自己
http://blog.yam.com/LuGaunTaoStudio/article/69104861

2014年4月22日 星期二

有關jorte待辦事項無法同步及開啟行事曆項目當掉問題之解決方法

前一陣子發現jorte待辦事項突然無法同步,搜尋了一下找到解決的方法是把google帳號移除再重新加入讓jorte重新取得權限。結果待辦事項是可以同步了但卻發現行事曆項目打開就會當掉。自己測試了之後發現是由於我有兩個google帳號,將第二個帳號也移除重新加入之後問題解決。提供有遇到此問題的人參考。

參考資料
自己

2014年3月25日 星期二

pfsense openvpn設置,設定有線網路優先於無線網路

如何使有線網路優先於無線網路。進入網路與共用中心,變更介面卡設定,F10,進階,進階設定。

pfsense裡設定openvpn重點如下

  • 先設定ca certification
  • 接著server certification於pfsense用
  • client certification用於要連接的設備
  • 注意LZO compression及cipher兩端(server及client)要設定一樣
  • 目前測試pfsense只能用tun而不能用tap
  • 建立.crt與.key時如common name設一樣則會拿到同一個IP,會造成互搶,應避免
  • 如需使用samba服務如網路芳鄰則需將Enable NetBIOS over TCP/IP打勾並選擇m-node,但android device有時還是會連不上


參考資料
有線網路優先
http://www.techbang.com/posts/6326-in-windows-7-fast-switching-wired-wireless-network
http://bojack.pixnet.net/blog/post/35356025-%E3%80%90windows%E3%80%91%E5%9C%A8-windows-7-%E8%AA%BF%E6%95%B4%E6%9C%89%E7%B7%9A%E7%B6%B2%E8%B7%AF%E5%92%8C%E7%84%A1%E7%B7%9A%E7%B6%B2%E8%B7%AF
IP相同
https://forum.pfsense.org/index.php?topic=4587.0
SMB
https://doc.pfsense.org/index.php/Why_can't_I_access_Windows/SMB_shares_on_OpenVPN_clients
同事討論與實做測試

2014年2月25日 星期二

按鍵精靈在VM中輸入問題

自己測試的結果,由於VM擷取鍵盤,所以無法用saystring直接輸入字串,而必須使用KeyPress代替,並且可以使用變數。也幸好我要輸入的變數是數字,所以使用迴圈來輸入。

參考資料
迴圈
http://tw.knowledge.yahoo.com/question/question?qid=1508062208839
輸入@等組合鍵寫法
http://tw.knowledge.yahoo.com/question/question?qid=1612072311102

ubuntu菱形進不去系統,powerbutton直接關機,忽略錯誤及關閉自動檢查

出現F<10个菱形>I<8个菱形>S<8个菱形>M<6个菱形>時的解決方法

Press F to attempt to fix the errors, I to ignore, S to skip mounting, or M for manual recovery

出現 菱形 S 菱形 M 菱形

Press S to skip mount or M for manual recovery

進入terminal之後

輸入
export LC_ALL=en_US.UTF-8 (將語言改為英文就不會再出現菱形)
fsck.ext4 /dev/sda1 (改成你毀損的磁區)

可以使用tune2fs設定檢查時機
tune2fs -c 2 /dev/sda1
上述即為掛載兩次檢查fsck

可修改 /etc/default/rcS 內的FSCKFIX=yes可在fsck時自動yes修復不須確定

參考資料
http://forum.ubuntu.org.cn/viewtopic.php?t=386633&p=2848077
Powerbutton直接關機方法
1.- sudo gedit /etc/acpi/events/powerbtn
2.- Add # to comment line: #action=/etc/acpi/powerbtn.sh
3.- Add a new line: action=/sbin/poweroff
4.- Save file
5.- Open a console and type: sudo acpid restart
http://askubuntu.com/questions/66723/how-do-i-modify-the-power-options/84984#84984?newreg=f3d31f5e61b8490fb1d67db682319552
圖形加速
http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=71872
windows關機前執行指令
http://ithelp.ithome.com.tw/question/10114763?tag=rt.rq
windows忽略錯誤及關閉自動修復
bcdedit /set {default} recoveryenabled no
bcdedit /set {default} bootstatuspolicy ignoreallfailures
(bcdedit /set {default} bootstatuspolicy displayallfailures) 啟用
http://www.i-so.org/disable-windows7-startup-repair.html
ubuntu關閉磁碟檢查
要進入開機選單在啟動時按住SHIFT
http://crunchbang.org/forums/viewtopic.php?pid=190573
http://forums.linuxmint.com/viewtopic.php?f=90&t=97550
https://help.ubuntu.com/community/Grub2
http://bbs.csdn.net/topics/390190378?page=1#post-393687150
http://neicole.blog.51cto.com/5621716/975581
http://tobalatech.blogspot.tw/2009/12/ubuntu-grub2.html
http://kenchio.wordpress.com/2012/05/24/20120524/
http://marvell1001.blogspot.tw/2012/09/grub-200-ubuntu-1204.html
Press S to skip mount or M for manual recovery
http://unix.stackexchange.com/questions/46628/not-able-to-lock-var-lib-dpkg-lock-read-only
tune2fs
http://wiki.debian.org.hk/w/Configure_regular_filesystem_check
fsck -y
http://askubuntu.com/questions/151025/how-can-i-make-fsck-run-non-interactively-at-boot-time

cisco router

連接console
http://bubble727.pixnet.net/blog/post/6789747-%5Bcisco%5D%E8%B6%85%E7%B4%9A%E7%B5%82%E7%AB%AF%E6%A9%9F,-%E9%87%8D%E8%A8%AD%E9%81%BA%E5%A4%B1%E5%AF%86%E7%A2%BC%E7%9A%84cisco-router
http://www.james-tw.com/cisco/cisco-she-ding-yuan-duan-lian-xian-telnet-ssh

基本
http://www.netadmin.com.tw/article_content.aspx?sn=1208100002&jump=1
http://www.netadmin.com.tw/article_content.aspx?sn=1205070002&jump=2
http://giboss.pixnet.net/blog/post/26807628-cisco-router%E5%9F%BA%E6%9C%AC%E8%A8%AD%E5%AE%9A
http://www.dotblogs.com.tw/box5068/archive/2011/01/19/20896.aspx
http://eservice.seed.net.tw/class/class33.html
http://www.james-tw.com/cisco/cisco-switch-base-setting

gns3 switch
http://tanzih.blogspot.tw/2010/07/gns3switch.html
https://learningnetwork.cisco.com/docs/DOC-13824
https://www.youtube.com/watch?v=f868S9NnmHg
vlan
ghs3使用c3700模擬switch使用vlan時要連結到fastethernet1/x才可以,fastethernet0/x是屬於router部分指令會出錯
http://www.netadmin.com.tw/article_content.aspx?sn=1201100001
http://www.digininja.org/blog/gns_vbox_vlan_lab.php
http://blog.yam.com/gavint/article/31578943
http://www.hkitblog.com/?p=11273
兩個vlan互通
http://blog.xuite.net/ganpin917/home/38918407-%E5%88%A9%E7%94%A8Cisco+Router%E5%BB%BA%E7%BD%AEDHCP+Service

static ip
router基本上無法設定gateway,一般router可以設定default gateway是因為已經與switch合併,故當需要設定時可以當作switch使用
https://learningnetwork.cisco.com/thread/64528

dhcp
在分配IP時要將router介面設定ip並在dhcp default-router設定此ip
https://www.youtube.com/watch?v=P_H9BLP-MRw
http://wfeng520.blog.hexun.com.tw/80502133_d.html
jointlesscisco#show ip int brief
jointlesscisco(config-if)#ip address dhcp
jointlesscisco(config-if)#no shutdown
jointlesscisco(config)#ip domain-lookup
https://www.youtube.com/watch?v=tgJgUyja0XU

NAT
切換介面
Router1(config-if)#ip nat inside
切換介面
Router1(config-if)#ip nat outside
Router1(config)#access-list 1 permit any any
Router1(config)#ip nat inside source list 1 pool nat1 overload
http://blog.roodo.com/kennykao1976/archives/4751865.html
https://www.youtube.com/watch?v=FfPJ_dvM_is
http://www.hkitblog.com/?p=11027

full-duplex dismach
設定duplex auto即可
http://www.gossamer-threads.com/lists/cisco/nsp/135763

SDM
http://zenfei.blog.51cto.com/763386/392728

debug:
enable
config t
logging on
logging console debug
access-list 199 permit icmp any any
do debug arp
do debug ip pack deta 199
do ping 8.8.8.8 rep 1




  • #************************************************  
  • # telnet login routine  
  • #  
  • # @PARAMS  
  • # ipaddr - remote device ip address  
  • # user   - user name to login in  
  • # passwd - login password  
  • #  
  • # @RETURN  
  • # spawn_id if login success, otherwise 0  
  • #************************************************  
  •  proc login   
  • {  
  •  ipaddr user passwd  
  •  }  
  •  
  • {  
  •  global g_prompt g_usrPrompt g_pwdPrompt  
  •  
  •   spawn telnet $ipaddr  
  •   expect   
  •  {  
  •   "$g_usrPrompt"   
  •   {  
  •    exp_send "$user\r\n"  
  •     exp_continue  
  •    }  
  •   "$g_pwdPrompt"   
  •   {  
  •    exp_send "$passwd\r\n"  
  •     exp_continue  
  •    }  
  •   -ex "$g_prompt"   
  •   {  
  •    dbgLog "Login Successful\n"  
  •     return $spawn_id  
  •    }  
  •   timeout   
  •   {  
  •    send_user "timeout"  
  •     return 0  
  •    }  
  •  }  
  • 2014年1月13日 星期一

    copy.com&工作排程器使用vbs引數&相對路徑與使用效能監視器監視硬碟空間

    copy.com提供多個資料夾同步的功能,方法是將要同步的資料夾建立捷徑在copy資料夾內。
    相對路徑是指執行程式的位置,不是vbs指向的程式位置,要注意。而在工作排程器中則必須設定開始位置來定義相對路徑。

    NOTES:
    “Any Directory” Syncing. Okay, we totally make up this name but it is exactly how it sounds. While Dropbox limits us to sync only files in a central folder (aptly named Dropbox), Copy.com lets you sync any directories on your computer. You can do this by creating a shortcut to that folder and place it within Copy directory. Not very intuitive like SugarSync though, which lets us do exact same thing within right-click menu.

    Found a solution if any one is interested the only way it would take the parameters is by adding the path of the wscript to the scheduler to the run line in the scheduler. 
    Although wscript is the default for vbs files the scheduler would still ignore the parameters. 
    So to get it working the run text in the scheduler should be:

    C:\WINDOWS\system32\wscript.exe C:\TASKS\test.vbs one two

    I am not sure why this works when other methods dont but I have read that parameters are only passed to .exe files so this may be why they are ignored for .vbs files.

    Thanks for the help from KrisSimonis & dglienna.


    • Telnet is an extremely limited tool. A much better utility would be sc.exe (http://www.securityfocus.com/data/tools/nc11nt.zip). In a batch file you could use it like so:
      @echo off
      nc -z 81.6.53.245 1724
      if %ErrorLevel% EQU 0 (echo Port is open) else (echo Port is not open)
      While you could embed nc.exe in a VB Script file, this only complicates the matter.
      Alternatively, if you run Windows 7, portqry.exe could do a similar job.
      • Marked as answer by zsustar Thursday, July 29, 2010 8:11 AM
      Thursday, July 29, 2010 5:43 AM
      Avatar of Forest brook
      (MCC)
      19,605 Points
    • Portqry is helpful to my case because the parameter -q will
      returns 0 if port is listening
      returns 1 if port is not listening
      returns 2 if port is listening or filtered 
      And i draft a script as following~
      ***************
      Set WshShell = WScript.CreateObject("WScript.Shell")
      Return = WshShell.Run("PortQry.exe -nwww.google.com -p tcp -e 80 -q", 1, true)
      WScript.Echo Return
      *****************
      It's cool. Thank you Peqasus.
      BTW, nc.exe is not working, maybe it's killed by my Norton. Anyway i prefer the tools from MS in term of security control.


    會要這個功能,是因為我朋友反應說。硬碟空間不夠,就是要再買大容量的硬碟來換。但總不能等到磁碟空間都滿了才發現吧?所以,只好上網找一下 Solution 囉!
    因為之前已經做過利用 MailSend 這支小程式來發信,現在只要能夠找到觸發執行批次檔的方式就行了。
    上網看了有用 Power ShellVBScript 來做的,不過,我想我還是兜一下好了。所以,就利用「效能監視器」的「警示」功能囉!
    第一個動作,當然是先寫一下 batch 檔囉!因為我有切三個磁區,所以就分別監控囉!先利用 psinfo.exe -d 來檢視各磁碟的狀況。
    因為對 Linux 比較熟,所以就習慣用剩餘空間百分比來做觸發條件囉!但因為三個磁區的容量差異還蠻大的,經換算後,就以空間剩 85%90%97% 來做為觸發條件。
    列一下我所寫的 batch 檔:
    echo Volume Type  Format     Label                            Size            Free          Free > C:\sch\alarmhdd_c.txt
    C:\pstools\psinfo.exe -d |find "C: Fixed" >> C:\sch\alarmhdd_c.txt
    rem 郵件標題:伺服器C磁碟使用率達 85%
    C:\sch\mailsend -d msa.hinet.net -smtp mail.domain.com.tw -t admin@domain.com.tw -f hddcheck@hinet.net -sub "=?UTF-8?B?5Ly65pyN5Zmo77yj56OB56Kf5L2/55So546H6YGUIDg177yF?=" -m C:\sch\alarmhdd_c.txt
    因為 E-Mail 主旨有中文,怕有編碼上的問題,就利用網路上有線上轉換 Base64 的網頁,進行 Base64 編碼的動作。
    收到信的內容就大概如下:

    (這是測試用的,所以在未達 85% 也會寄發)
    接下來就是到「效能監視器」的「警示」來進行「新增警示設定」的動作。
    輸入一個警示名稱,本例為「DriveCAlarm」。
    在「註解」欄位寫入說明,再按下「新增」鈕。
    依照下列的圖示進行「計數器」項目的挑選,完成後按下「新增」鈕,再按「關閉」鈕。
    計數器欄位已經設定好了,接下來就是設定觸發條件。我對C磁區的設定為可用空間小於 5.86GB 就發出告警,1天檢查1次。
    切換到「執行」頁籤,除了預設勾選的第一項外,再勾選「執行以下程式」。按下「瀏覽」鈕,挑選要執行的 Batch 檔,本例為:C:\sch\DriveCAlarm.bat
    按下「套用」鈕後,會出現「設定密碼」的視窗,使用者欄位格式要為「Domain\User」。
    確認一下「執行身分」是為之前所設定的「Domain\User」。
    這樣子「警示」功能就多了一項設定。如果未啟動,就將它啟動。有問題的話,就到事件檢視器看看訊息。
    為了要測試設定是否可運作?所以進行了下列的修改來確認。
    在事件檢視器中,就可以看到類似下面的事件訊息。當然也會收到 E-Mail
    大功告成,記得要將觸發條件改回來,要不然信就收不完啦!DE 磁區的設定也依樣畫葫蘆即可。


    [Tip]使用效能監視器監控伺服器狀態,並寄送異常通知

      
    當我們在管理伺服器時,常常會希望能監控伺服器狀態, 如果伺服器發生CPU持續過高,或是硬碟空間不足時能夠發出異常通知, 我們可以透過Windows內建的效能監視器來簡單實現這樣的功能。

    設定效能監視器異常界線

    在這邊以監控硬碟有效空間來做為範例。
    1. 首先打開我們的效能監視器,新增資料收集器集合工具
    2. 輸入名稱"伺服器效能監控",選擇使用手動建立
    3. 選擇"效能監視器警訊
    4. 我們可以看到已經出現了這個資料收集器集合
    5. 接下來開始新增我們的監控項目,新增一個資料收集器
    6. 輸入硬碟空間監控,並選擇效能計數器警訊
    7. 點選新增,選擇監控項目
    8. 選擇Logical Disk的% Free space,新增要監控的磁區
    9. 設定在20%以下時觸發警訊
    10. 勾選設定警訊內容

    設定效能監視器警訊執行動作

    1. 設定抽樣間格為2分鐘 (普通應該一小時即可)
    2. 點選警訊動作頁籤,勾選在事件紀錄檔紀錄
    3. 設定發生異常時執行排程及通知訊息,點選右邊小箭頭可以瀏覽可使用的變數

    設定發送警訊通知排程

    1. 進入工作排程器,新增排程工作
    2. 設定執行帳號,選擇不論是否登入都執行
    3. 點選動作頁籤,選擇新增
      當伺服器發生異常時,
    4. 輸入寄送email的資訊,$(Arg0)會自動帶入從效能監視器剛剛設定的警訊文字
    5. 設定完成,當伺服器異常時就會收到通知的Email了
    ※註: 使用內建的傳送電子郵件,僅支援不需驗證的SMTP Server, 此處可自由置換其他的警訊通知方法 (ex.Powershell) 只要記住可使用$(Arg0)來讀取帶入的警訊內容即可

    總結


    透過效能監視器,我們可以根據自己的需要實現簡單的伺服器監控機制, 當然隨著伺服器數量越來越多,可以按照需求使用更好的解決方案, 這邊提供大家一個簡單且輕量級的伺服器監控方法, 關於今天的內容,若有任何問題歡迎大家提出來一起討論!

    參考資料
    http://olivetjournal.com/my-honest-copy-com-review#proreviewhttp://forums.codeguru.com/showthread.php?439916-How-to-run-a-very-long-SQL-statementhttp://social.technet.microsoft.com/Forums/scriptcenter/en-US/37c5fced-38e4-4508-82a3-7e59cafce46f/how-to-use-vbscript-to-check-telnet-result?forum=ITCG

    http://blog.xuite.net/jyoutw/xtech/62155589
    http://www.dotblogs.com.tw/kirkchen/archive/2012/11/24/use-performance-monitor-to-monitor-server-and-send-alert-email.aspx