Skip to main content

[Raspberry pi] 陽台的老鼠偵測器

前言: 話說前陣子爸爸家陽台不斷出現米奇老鼠,立刻清理陽台所有東西,然後又跟市政部門反映問題,可是情況還沒有好轉,米老鼠來完一隻又一隻,我爸陽台在老鼠界應該是網紅打卡聖地(誤),要不然就是米奇老鼠版米奇林三星餐廳(?) 雖然我們抓到了三隻,到上兩個禮拜為止還有至少一隻一直抓不到,每天淩晨還會來吃事後煙留下老鼠屎,真_北。 這隻老鼠對傳統攻擊有抗性,有IT9朋友前陣子用Raspberry pi自製了一台electric mouse trap ,用pi的超聲波雷達放在鞋盒裡,鞋盒裡有一堆食物,底部佈了鐵網,偵測到有老鼠進去以後立即關門通9V電,通個1分鐘再放牠離開,大推我自己也造一台 (Youtube片搜尋一大堆,人類真變態啊,朋友好變態啊)。可是我覺得這樣又好像有點太殘忍,不如先偵測牠們什麼時候來,嚇嚇牠們看看有沒有效果再說吧。 目的: 用Raspberry pi及手上有的感測器弄一隻放陽台用來偵測和嚇嚇老鼠的東西,並把紀錄圖像化到雲端給老爸使用。 邏輯及設計: 當老鼠進入偵測範圍,Motion Sensor偵測到生物活動Raspberry pi 處理來自Motion Sensor的訊號,如果夠強的話開始準備作出回應 Raspberry pi在Angry cats sounds中隨機選出叫聲,再經由Speaker輸出貓叫聲 Raspberry pi指示強光元件發出強光束照射目標 把偵測計數上傳到雲端圖表 材料: Sensor 在網路上看了一些Raspberry pi wild animal camera ,很多也是用Motion Sensor先偵測動物再來,我用的是PIR Motion Sensor被動式紅外線感測器,有低耗電成本便宜的好處。[1],而且可手動調整靈敏度及反應時間。  PIR Motion Sensor就是下面這個 圖片來源: learn.adafruit.com 可手動調整敏感度還有反應時間,這個有點不好調,要試好多遍才找到最佳位置。 可以在Raspbian中輸入pinout查詢GPIO避免插錯 圖片來源: learn.adafruit.com . 一台Raspberry pi 這次使用較舊的Raspberry pi model B+ 萬一老鼠生氣被咬爛錢包也不太痛 . ...

[分享] 系統改善方案企劃書例子


如果今天老闆要你對某系統提出改善方案, 很多工程師包括我也不知道從那裡著手開始寫. 剛好遇到這次機會花掉了我畢生腦 精 力寫好一份SQL Server改善方案, 把小弟的文章部分內容分享一下希望對各位同業有幫助. 部分內容因為公司機密有所刪減, 請見諒 (公司要用英文寫, 抱歉沒中文版本= =")


------
Introduction:
This study will focus on how can we improve existing SQL Server to provide more reliable, more secure and improve capacity in order to fulfill future usage.

Current Status overview:
Operation System: windows Server 2003 SP2 32bits with 3.75 GB ram.
SQL Server version: SQL Server 2005 standard edition.
numbers of databases: 18.


Performance evaluation:
We capture the sample data from 23/07/2012 to 27/07/2012. evaluating 8 indicators[1] covering memery, CPU, and harddisk performance. here is the result:

Existing issues:
Security: 
    • Accounts level:
      • XX% databases using administrator as its login account. That's mean using one account can access several databases.
      • All developers known SQL Server admin username and password.

    • Operating system level:
      According to Microsoft security guideline, the highest risk of infection servers generally meet one or more of the following criteria. Conditions 1, 3, 5 are ture in our environment
      1. Server can access to the internet.
      2. The servers have open ports to servers that are not behind a firewall.
      3. The servers read or execute files from other servers.
      4. The servers run HTTP servers, such as Internet Information Services (IIS) or Apache. (For example: SQL XML for SQL Server 2000.)
      5. The servers are also hosting file shares.
      6. The servers use SQL Mail to handle incoming or outgoing email messages.
System:
    • The effectiveness of existing backup solution is unknown.
    • Some databases do not accepted of any system failure or abnormal termination in office hour(ex, dms). Existing SQL Server can not provide any failover capability.
    • 32-bit Operating system means only 4GB ram can be used on the SQL server, no matter how much really it is or what platform it is using(ex. Virtual machine). In other words, the capacity of SQL server is pretty tight.
    • The SQL server is multi-functional.
    • Lack of developmen environment. Developers always do development in production server directly.

Propose improvements:
Security level:
    1. Create independent account for each databases.
    2. Using independent account for SQL server administration. Reduced the power in a single account(domain admin).
    3. SQL Server admin password can be only known by SQL Server administrator and associated members, not for all developers.
    4. isolated to external environment. Block SQL Server connect to internet, whether incoming or out going.
    5. Simplified server function only for database system. Migrate other programs to another server. It is because execute, read or exchange files can increase the risk of infection.
    6. Disabled all share folder in the server.
System level:
    1. re-Formulate clear backup plan.
    2. Periodically do backup restore drill. Let infra team-mates do it faster and more accurate.
    3. Reconsider the necessity of failover plan. If yes, details planning in hardware, software, network, infrastructure.
    4. As quick as possible to build up development environment. To prevent excess modification in production server.
Resource planning level:
  • 32bit to 64 bit: 
    More and more systems choose SQL Server as their final database solution in our department. Moreover, according to a report from Gartner, a company  which 
    delivers technology research, said SQL Server holding the third in global database market share, about 17% [3]. So we can estimate that the usage of SQL Server will increase inevitably. More usage means more RAM would be spent in the future. Unfortunately, 32bits SQL Server maximum support ram size are only 3.99GB, but 64 bits almost no limitation. The higher the memory, the larger is the buffer pool and less time is spent on accessing the data from the physical disk, reading cache, make connections, etc.
  • Physical to Virtualization:
    Since SQL Server usage is unpredictable, Virtualization technology can dynamically increase or decrease resources to the SQL Server according to the usage. No need to open the hardware server and plug more ram or CPU physically.  More flexible.
  • Windows Server 2003 to 2008:
    I have read many articles the differences between version 2003 and 2008. The main benefits upgrade 2003 to 2008 are [4]
    • Increase server efficiency. Reduce the power consumption of server.
    • more features on management and virtualization.

  • Monitor performance regularly.[5]
[1] Evaluation items are based on this article.
[2] Microsoft security guideline [3] Oracle依舊領跑關系型數據庫市場
[4] Windows Server 2008 wiki
[5] Why you really do Performance Management in production.


Comments

Popular posts from this blog

[軟體] 在Windows7 安裝骨灰級學倉頡軟體--快快樂樂學倉頡

前言: 話說我們這些用電腦宅齡超過十五年以上的挨踢人聚在一起的時候總喜歡提一些當年的技術,Duron鉛筆超頻這種骨灰級方案在圈裡是常識吧XD。 突然有朋友提到"快快樂樂學倉頡"這套DOS 1.0年代用來學打字的軟體,應該是很多港澳挨踢人的集體回憶吧。 有沒有方法在Windows7上回憶一下呢?答案當然是有啦! 方法: 這次我們會用到DOSBox這套軟體。根據官網說法" DOSBox is an emulator that recreates a MS-DOS compatible environment"。顧名思義DOSBOX就是一台MS-DOS的虛擬機器囉。安裝好以後在裡面安裝快快樂樂學倉頡基本上就OK了。 準備工作: 根據貴用戶的要OS, 先到 這裡 下載相對應的DOSBox版本,我裝的是Windows版本。 快快樂樂學倉頡的執行檔。(沒有的話可以私下問我) 步驟: 裝好了以後按下圖示開啟 進入到DOSBox主畫面 由於這裡是MS-DOS的虛擬機器,當然不會有任何其他檔案,接下來我們要把裝住 "快快樂樂學倉頡" 的資料夾掛載(Mount)到虛擬機器去。這裡裝住軟體的資料夾叫 "HPCJ",所以在浮標上輸入 mount C: C:\Users\xxxxx\Documents\Software\HPCJ 這句的意思是mount a disk called "C:", and its location is "C:\Users\xxxxx\Documents\Software\HPCJ",搞定以後按確定。就會出現已經mount好的訊息。 接下來可以直接存取"快快樂樂學倉頡" 資料夾的內容了。先輸入C: 然後按確定跳到剛掛載的C: 直接輸入"快快樂樂學倉頡"的exe名稱按確認。例如我的是Open.exe,按enter。 登登~!!成功了。 打了這麼多年,其實我打字速度也不快就是了。囧rz

[Windows7] 跨距磁碟區, 等量磁碟區, 鏡像磁碟區之區別

話說前兩天用來備份的USB硬碟無緣無故去領便當了. 大幸的是我一直有好好備份, 資料至少存在兩顆硬碟上, 所以備份硬碟掛了損失也不大(錢包除外). 所以昨天下班以後趕緊去買一顆seagate的2TB內置硬碟回家(感覺USB硬碟還是不太安全), 裝好以後突然想到一個問題: 現在我桌機總共有5顆硬碟, 首先是剛買回來的2TB, 1顆80G SSD, 1顆640G, 1顆320G, 1顆160G. (真多舊硬碟囧), 關於硬碟的部分Windows 7比XP多了一些選項, 應該選那個才對? 讓我自己先分析一下: 那麼零碎的硬碟應該選擇合拼方案為主 關於合拼的方案Windows7有三大選項, 分別是 跨距磁碟區 ;  等量磁碟區;  鏡像磁碟區三種, 應該怎樣選呢? 說穿了那三種其實就是軟體的RAID方案, 硬要改一些好像很簡單又不簡單的中文字 . 其實: 跨距磁碟區 = JOBD,  就是簡單把幾顆硬碟變成一顆大的邏輯硬碟,  資料的存放機制是由第一顆硬碟開始依序往後存放,即作業系統看到的是一個大硬碟(由許多小硬碟組成的)。但如果硬碟損毀,則該顆硬碟上的所有資料將無法救回。若第一顆硬碟損壞,通常無法作救援(因為大部分檔案系統將磁碟分割表(partition table)‎存在磁碟前端,即第一顆)[1] 等量磁碟區 = RAID 0 把資料分散在幾顆硬碟, 存取的速度比較快, 不過壞一顆又是全部壞掉. 鏡像磁碟區 = RAID 1 顧明思義有兩份data, 超安全, 不過由於write的時候也要write兩份, 所以速度會慢. 更詳細的解釋 這裡 [2] 魚仔大有好好的解釋說明三種功能, 小弟就再不說了. 總結: 那我要怎麼辦? 最後我選擇的是.... 什麼都不做 , 80G的SSD留給OS及程式專用, 640G的用來放照片/動畫/影片/影像檔, 320G的用來放文件還有裝一些不重要的應用程式(遊戲啦,遊戲啦,還有一些遊戲之類的), 160G的用來裝音樂還有.......你懂的. 至於2TB的那顆就是當成上面所有硬碟的mirror, 用sync工具即時備份. 為 什 麼 ? 因為JORB不是不好, 不過把那幾顆舊硬碟變一顆有很大的風險, ...

[SQL Server]Linked Servers中的login mappings問題

話說前陣子同事打算利用SQL Server 內我已經設定好的Linked Server更新AS400的資料表(table). 出現不能更新的錯誤. 發現原來設漏了東西....囧. 以連接AS400為例子, 如果有大大跟我一樣是用ODBC做連結, 並且在AS400那邊有獨立登入名稱跟密碼的話. 當連結完了以後還要進行user mapping的動作, 否則可能會因為權限不夠更新不到. 在設定之前要先考慮這個Linked Server是否給全部SQL SERVER的使用者使用, 還是只是某些使用者才有權限進行存取. 如果Linked Server打算只開放給某些使用者存取的話: 首先選擇目標的Linked Server, 按右鍵-> "Properties" 轉到 "Security"頁面-> 按一下"Add", 在"Login Login"中選擇一個SQL Server的帳戶, 例如你打算從ABC資料庫存取Linked Server的話, 最好是使用ABC資料庫的使用者帳號. 然後在"Remote User"跟"Remote Password"中輸入AS400那邊的帳號跟密碼按OK. 如果你打算開放Linked Server給所有SQL SERVER的用戶存取的話: 首先還是跟上面一樣進入到Properties的畫面->Security的部分, 往下找到 "For a login not defined in the list above, connections will" 這一欄. 選擇 "Be made using this security context:" 輸入AS400中打算用來登入的名稱跟密碼然後"OK." 那麼所有SQL SERVER的使用者也可以存取AS400的資料庫囉...