2014/2/7

4個Linux服務器監控工具


只能單機,還要看後面幾個能不能用到snmp內

From :http://blog.jobbole.com/58003/

本文由 伯樂在線 - 敏敏 翻譯自 Aarvik。歡迎加入技術翻譯小組。轉載請參見文章末尾處的要求。


下面是我想呈現給你的4個強大的監控工具。

htop – 交互式進程查看器

你可能知道在機器上查看實時進程的標準工具top。如果不知道,請運行$ top看看,運行$ man top閱讀幫助手冊。
htop是top的擴展版本,有更豐富的概貌(例如全命令、可視化、圖形用戶界面gui和用戶界面ui),有鼠標點擊交互(譯者註:看下面的截圖,指的是最上面的列標題如CPU%、MEM%等可以通過鼠標點擊切換以顯示不同的功能),也有許多的指導教你如何做進程管理。
安裝該命令並嘗試運行:
$ sudo apt-get install htop
截圖如下:
htop
- From my OS X terminal in my Debian 7 box

iotop – 簡單的類似top的I/O監控器

iotop是IO實時監控器。使用它們附屬的詳細輸入輸出(IO)使用方法可以展示出你系統中每個進程線程的信息。
該命令可以與$ tcpdump(響應網絡流量的命令)一起使用。如果你發現你的web服務器上有程序在運行,你可以,比如運行$ tcpdump port 80檢查端口80(標準的http端口)的網絡流量來觀察細節。
最有用的信息可能是DISK WRITE這一列,從該列你可以準確的看到每個IO使用了多少個進程,單位為K/s。
安裝該命令並嘗試運行:
$ sudo apt-get install iotop
截圖如下:
iotop

apachetop – 展示web服務器實時統計數據

Apachetop展示Apache web服務器上關於http請求的實時表。
它顯示統計(stats), 點擊(hits), 請求(requests), 請求細節(request details),且能夠獲得當前你的web服務器正在運行程序的概貌,這一點很贊。
如果你使用的是Nginx,也有一些相似的工具,但似乎沒有apachetop那麼詳細。
安裝該命令並嘗試運行:
$ sudo apt-get install apachetop
截圖如下:
apachetop

Glances – 基於CLI curses庫的監控工具

Glances用各個分離的表列展示了你機器當前正運行的各種有用的實時數據。Glances旨在用最小的空間顯示儘可能多的信息,我認為它的目標完全達到了。
Glances用有限的交互可能性和更深層的信息監控PerCPU, Load, Memory, Swap, Network, Disk i/O, Mount data 和processes,但對於獲得一個整體概貌絕對是完美的。
安裝該命令並嘗試運行:
$ sudo apt-get install glances
截圖如下:
glances


原文鏈接: Aarvik   翻譯: 伯樂在線 - 敏敏
譯文鏈接: http://blog.jobbole.com/58003/
[ 轉載必須在正文中標註並保留原文鏈接、譯文鏈接和譯者等信息。]

於 Linux 如何查看 詳細的硬體資訊、型號

From :http://blog.longwin.com.tw/2014/02/linux-query-hardware-2014/

於 Linux 如何查看 詳細的硬體資訊、型號

這次遇到硬碟損毀(Raid 1), 想買同型號的硬碟來換掉, 但是之前都沒留下任何記錄, 不知道要買哪顆硬碟, 如何不拆機器的狀況下, 直接查詢硬體、型號等詳細資訊呢?

於 Linux 如何查看 詳細的硬體資訊、型號

先記錄硬碟的部份, 有下述幾種指令可以使用:
  • sudo smartctl -i /dev/sda # 顯示硬碟型號及規格, apt-get install smartmontools
    Model Family:     Seagate Barracuda 7200.14 (AF)
    Device Model:     ST2000DM001-1CH164
    Serial Number:    Z1E3NQMJ
    LU WWN Device Id: 5 000c50 050533951
    Firmware Version: CC24
    User Capacity:    2,000,398,934,016 bytes [2.00 TB]
    Sector Sizes:     512 bytes logical, 4096 bytes physical
    Rotation Rate:    7200 rpm
    Device is:        In smartctl database [for details use: -P show]
    ATA Version is:   ATA8-ACS T13/1699-D revision 4
    SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
  • sudo hdparm -i /dev/sda1 # apt-get install hdparm
    /dev/sda1:
    Model=ST2000DM001-1CH164, FwRev=CC29, SerialNo=Z340PKFV
    Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
    RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
    BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
    CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=3907029168
    IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
    PIO modes:  pio0 pio1 pio2 pio3 pio4
    DMA modes:  mdma0 mdma1 mdma2
    UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
    AdvancedPM=yes: unknown setting WriteCache=enabled
    Drive conforms to: Reserved:  ATA/ATAPI-4,5,6,7
    * signifies the current active mode
要看機器的其他硬體資訊, 有下述程式命令可以使用, 在此就不詳細介紹:
  • sudo dmidecode -t # 後面可以接下述的參數
    bios
    system
    baseboard
    chassis
    processor
    memory
    cache
    connector
    slot
  • ex: sudo dmidecode -t memory # 列出 memory 詳細資訊
  • lshw
  • lspci # list all PCI devices
  • lspci -vv
  • lspci -nn
  • lsusb
  • dmesg # print or control the kernel ring buffer
  • lsusb # list USB devices
  • /proc : process information pseudo-file system
  • tree -d /sys/devices

相關網頁

2014/1/27

DNS support edns-client-subnet

2019/1/30日更新
有專家見解:"支援ECS的 recursive DNS resolver 可將DNS請求來源(DNS request client)的IP subnet(網段即可,不一定要精準到IP)附加到DNS query內提交給ADNS (authoritative DNS server),以便ADNS判斷最佳回應"


2018/11月就告訴我,我到今天(1/30日)才看到...
得證:夠偷懶....

 當時因為工作翻牆出來,從CDN的觀念查到這個
到今天新聞:一些google、IBM等等的DNS開始要支援EDNS
我又再度翻了一遍..





解釋:依照你來的IP,轉給目標網站,讓目標網站依照你的ISP等等,轉CDN給你資料
在台灣,這沒啥用處
在大陸,這用處可大了
不過遇到電信、聯通自己不願意公開自己DNS給別人,那也沒啥用處

來源:http://noops.me/?p=653




DNS support edns-client-subnet

作者: |   2,020 瀏覽  | 

看了2天RFC,終於讓DNS支持edns-client-subnet協議,通過google dns resolver的請求,可以獲取用戶的ip地址。
國內很多CDN和DNS提供商都已經實現了,但網上的中文資料比較少,所以在這裡分享一下,能力有限,錯誤之處還請諒解。

問題

  • CDN使用DNS獲取查詢IP,根據IP對用戶進行地域調度。但這裡獲取的IP地址是DNS地址,而不是用戶真實的IP地址。
  • 大多數情況下,我們假設用戶通過會使用離自己網絡最近的DNS resolver,CDN調度基本還是準確的。
  • 但也有很多nameserver設置錯誤,或者用戶使用google public dns(nameserver 8.8.8.8/8.8.4.4)或opendns進行DNS resolver
比如:
  1. 國內用戶設置nameserver 8.8.8.8 (dig xxx.com @8.8.8.8)
  2. 我們得到的DNS query IP是74.125.16.208,判斷IP屬於美國,,,加利福尼亞州山景市谷歌公司
  3. 這個時候,我們的DNS會返回離美國加州最近的CDN節點IP給用戶。
  4. 國內用戶錯誤的調度到美國節點…… :(

edns-client-subnet

  • google提交了一份DNS擴展協議,允許DNS resolver傳遞用戶的ip地址給authoritative DNS server.
  • CDN的DNS支持該協議,就可以獲取用戶真實的IP地址,進行準確的調度。
    图片1
  • OpenDNS和Google Public DNS已經支持了該協議,如果希望他們的query中帶有用戶IP,需要聯繫他們添加白名單。提供nameserver的hostname、ip以及可以 用來測試解析的域名即可,一般幾天就可以搞定。(註:我是晚上22:l00提交的申請,第二天10:00就已經生效了)

實現

一. 支持發送和接收edns-client-subnet的dig

  1. 先下載bind,下載地址
  2. 下載edns-client-subnet dig patch,下載地址
    下載上述2個包,將patch打進bind,編譯出dig進行測試:
注意上面的OPT PSEUDOSECTION,已經可以發送和接收edns-client-subnet請求了

二. 協議

  • DNS協議
  • DNS query會包含header和RR 2部分,這裡只介紹我們關注地方,網上可以搜到很多協議的介紹,比如這個http://archercai.blog.sohu.com/60779796.html
  • header會描述本次請求中Questions、Answer RRs、Authority RRs和Additional RRs的數量,RR部分會詳細描述每個資源的內容,所有的RR格式是相同的,如下:
  • 個人理解edns-client-subnet是對edns協議的擴展,附加在一個DNS請求的Additional RRs區域,這裡重點描述edns-client-subnet的結構
    • EDNS協議 Extension mechanisms for DNS (EDNS0):http://tools.ietf.org/html/draft-ietf-dnsind-edns0-01
  • EDNS0每個字段的結構和描述如下:
  • OPT 的值41,詳細的協議值如下:
  • RDLENGTH描述RDATAD的長度,edns-client-subnet的詳細格式存在RDATA中,如下:
  • OPTION-CODE: 2個字節
  • OPTION-LENGTH: 2個字節,描述它之後的內容長度(BYTE)
  • FAMILY: 2個字節,1表示ipv4, 2表示ipv6
  • ADDRESS: 實際存放IP地址的地方,ipv4長度為4,google發送過來的長度一般為3,隱藏了ip地址最後一位

三. 開發

完成前2個步驟,就可以開搞了,邏輯很簡單:
1. 判斷dns query是否包含Additional RRs,讀取NAME部分
2. 讀取10個字節(byte),判斷TYPE是否為41,rdlength > 8
3. 如果rdlength > 8,再讀取8個字節,對應OPTION-CODE(2)–>OPTION-LENGTH(2)–>FAMILY(2)–>SOURCE NETMASK(1)–>SCOPE NETMASK(1)
4. 讀取剩下的address,長度 rdlength – 8 或者 option-length – 4都行
註:讀取到的地址長度為4,可以用socket.inet_ntoa變成ip地址,如果不夠4個字節,需要後面補\x00
5. 獲取到的IP地址就可以用來進行判斷調度了
6. respond時也需要增加一個Additional RRs區域,直接把請求的Additional內容發過去就可以(如果支持source netmask,將請求中的source netmask複製到scope netmask中,OpenDNS要求必須支持scope netmask)

四. 抓包

  1. 發包
    • 發送dns query請求時,可以看到Questions:1, Additional RRs: 1
    • Additional RRs中,type: 41(OPT), rdlength: 12 (google發過來的包,長度為11,沒有IP地址最後一位)
    • 12 – OPTION-CODE(2) – OPTION-LENGTH(2) – FAMILY(2) – SOURCE NETMASK(1) – SCOPE NETMASK(1) = 4,IPV4 地址的大小
      图片2
  2. 回包
    • 發送dns query請求時,可以看到Questions:1, Answer RRs:1, Additional RRs: 1
      图片3

jboss 的啟動方式

轉貼自http://www.soezblog.com/plate/group/web/papermsg.jsp?UI=markcool&GI=47&CI=22&p=1&PI=967

1.前言
  在JBoss預設的情況下,JBoss可以用3種方式啟動,分別為 minimal, default 和 all。
  這3種啟動模式分別對應在 JBOSS_HOME/server 的目錄之下。
  如果按照正常的啟動模式,JBoss會啟動default的模式。不同的啟動方式,會載入不同的模組與部署檔。
2.執行JBoss
  你可以執行 JBOSS_HOME/bin/run.bat 批次檔,在預設的情況下,會部署 default 的內容。
  如果想用其它模式啟動,你可以在[捷徑]或[命令提示定元]中,執行:
  run.bat -c all    ,以 all 模式啟動。
  run.bat -c minimal  ,以 minimal 模式啟動。

以下是啟動之後的視窗。
3.部置其它的JBoss伺服器。
  一般預設為 minimal, default 和 all 三種模式,但如果自己想要自行定義
伺器。

  你可以在 JBOSS_HOME/server/ 目錄下,增加自己所定義的伺服器,
  例如,建立 JBOSS_HOME/server/self 的目錄,這樣就建立 self的伺服器名,然放入自己想部署的模組內容(假如目前並沒有自己想部署的內容,那沒有關係,我們可以先將minimal目錄下的內容,全複製到 self 的目錄下,當做是內容的部署)
  部置完畢之後,執行 run.bat -c self 就可以啟動 self的內容了
ps1.部署的內容,可以參考 minimal, default 和 all 的部署內容,當然,如果有個別的需要,就要自行調整)
ps2.JBOSS_HOME/server/self/deploy/ 是web 專案所運作的目錄,你的專案程式,就是放在這之中。

2014/1/11

what's up 抓系統error log


what's up Percent Variables,帶變數到email內



在what's up 裡面,能夠email 通知使用者有什麼錯誤
能夠帶一些相關參數,統稱Percent Variables ,列表如下


 
Percent Variables
You can customize an action's message by adding any of the variables in the following table.
Note: We do not recommend that you use percent variables in script text (Active Script Action), because they may resolve to text containing special characters (' ' (quotes), " " (double-quotes), % (percent), new line characters, and the like) that may break your script.
Active Monitor Variables
Description
%ActiveMonitor.Argument
SNMP instance number. This is only used when an action is associated directly with an active monitor, and not the device as a whole.
%ActiveMonitor.Comment
The human readable name that coincides with the network switch. This is only used when an action is associated directly with an active monitor, and not the device as a whole.
%ActiveMonitor.Name

The name of the active monitor that fired an action. This is only used when an action is associated directly with an active monitor, and not the device as a whole.
%ActiveMonitor.NetworkInterfaceAddress
IP address for the network interface. This is only used when an action is associated directly with an active monitor, and not the device as a whole.
%ActiveMonitor.Payload
The payload returned by a WMI, Exchange, SQL, SNMP or Active Script active monitor. This is only used when an action is associated directly with an active monitor and not the devices as a whole.
For Active Script Active Monitors, the payload is the text that is passed to the SetResult() method in the script.
%ActiveMonitor.State

The Current status of the monitor, such as "Down at least 5 min." This is only used when an action is associated directly with an active monitor, and not the device as a whole.

Device Variables
Description
%Device.ActiveMonitorDownNames
List of down services using the abbreviated name if available.
%Device.ActiveMonitorUpNames
Full service names of all UP monitored services on a device.
%Device.Address
IP address (from device properties).
%Device.Attribute.[Attribute Name]
Returns an attribute from the SNMP information available for the device, such as the Contact name. To specify the attribute, append the category name (listed below) to the end of the variable. For example: %Device.Attribute.Contact, returns the contact name.
Default categories:
 *. Returns all attributes
 Info1. Upgrade path from v8
 Info2. Upgrade path from v8
Contact. Contact information from SNMP
 Location. Location information from SNMP
Description. Description information from SNMP
Custom. If you have created a custom attribute you can use the name of that custom attribute in the percent variable.
Example:
%Device.Attribute.Phone
%Device.Attribute.RackPosition
To avoid an error, always place a space or line break after the attribute name.  
%Device.DatabaseID
Returns the database ID of a device.
%Device.DisplayName
Display Name (from General of device properties)
%Device.HostName
Host Name (from General of device properties)
%Device.Notes
Notes. (Notes are from the device properties Notes)
%Device.SNMPOid
SNMP Object identifier.
%Device.State
The state's description (such as "Down at least 2 min" or "Up at least 5 min")
%Device.Status
This shows the name of the active monitor, preceded by the device state id : 10|DNS
%Device.Type
Device Type (from General of device properties)

Passive Monitor Variables
Description
%PassiveMonitor.DisplayName
The name of the monitor as it appears in the Passive Monitor Library.
%PassiveMonitor.LoggedText
Detailed Event description. (SNMP traps - Returns the full SNMP trap text.) (Windows Log Entries - Returns information contained in the Windows Event Log entries.) (Syslog Entries - Returns the text contained in the Syslog message.)
%PassiveMonitor.Payload.*
Payload generated by a passive monitor.
%PassiveMonitor.Payload.EventType
The type of passive monitor (Syslog, Windows Event, or SNMP Trap)
%PassiveMonitor.Payload.LogicalSource
Shows the device's logical IP address.
%PassiveMonitor.Payload.PhysicalSource
Shows the device's physical IP address.

System Variables
Description
%System.Date
The current system date. Configure the date format in Regional Options (from Program Options)
%System.DisplayNamesDownDevices
Display names of devices with down monitors
%System.DisplayNamesDownMonitors

Shows the name of a device and each monitor that is down on that device. The format of the response is 'device name':'monitor 1','monitor 2','...'
Example: ARNOR: FTP, HTTPS, Ping
%System.DisplayNamesUpDevices
Display names of up devices
%System.DisplayNamesUpMonitors
Shows the name of a device and each monitor that is up on that device. The format of the response is 'device name':'monitor 1','monitor 2','...'
Example: ARNOR: FTP, HTTPS, Ping
%System.InstallDir
Displays the directory on which WhatsUp Gold is installed
%System.NumberofDownDevices
Number of down devices on your network
%System.NumberOfDownMonitors
Shows the number of down monitors on your network
%System.NumberofUpDevices
Number of up devices on your network
%System.NumberOfUpMonitors
Shows the number of up monitors on your network
%System.Time
The current system  time. The format is hh:mm:ss

手機QQ禁用NFC

一圖解千言萬語 應用程式權限:透過NFC起動