Linux 自帶的 watchdog 的簡介

Linux 自帶了一個 watchdog 的實現,用於監視系統的運行,包括一個內核 watchdog module 和一個用戶空間的 watchdog 程序

內核 watchdog 模塊:

內核 watchdog 模塊通過 /dev/watchdog 這個字符設備與用戶空間通信。用戶空間程序一旦打開 /dev/watchdog 設備,就會導致在內核中啓動一個 1分鐘的定時器,此後,用戶空間程序需要保證在 1分鐘之內向這個設備寫入數據,每次寫操作會導致重新設定定時器。如果用戶空間程序在 1分鐘之內沒有寫操作,定時器到期會導致一次系統 reboot 操作。

用戶空間程序可通過關閉 /dev/watchdog 來停止內核中的定時器。

用戶空間的 watchdog 守護進程:

在用戶空間,還有一個叫做 watchdog 的守護進程,它可以定期對系統進行檢測,包括:

  • Is the process table full?
  • Is there enough free memory?
  • Are some files accessible?
  • Have some files changed within a given interval?
  • Is the average work load too high?
  • Has a file table overflow occurred?
  • Is a process still running? The process is specified by a pid file.
  • Do some IP addresses answer to ping?
  • Do network interfaces receive traffic?
  • Is the temperature too high? (Temperature data not always available.)
  • Execute a user defined command to do arbitrary tests.

如果某項檢測失敗,則可能導致一次 soft reboot (模擬一次 shutdown 命令的執行)

它還可以通過 /dev/watchdog 來觸發內核 watchdog 的運行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章