Linux Kernel Watchdog Explained

28/12/2020
Chưa phân loại

Linux Kernel Watchdog

The Linux kernel watchdog is used to monitor if a system is running. It is supposed to automatically reboot hanged systems due to unrecoverable software errors. The watchdog module is specific to the hardware or chip being used. Personal computer users don’t need watchdog as they can reset the system manually. However, it is useful for systems that are mission critical and need the ability to reboot themselves without human intervention. For example, servers on a remote location or embedded equipment on a spacecraft that need automatic hardware reset capabilities.

Warning: Proceed with Caution

Wrong configurations of a watchdog on your system can cause problems like:

  • Endless reboot loop
  • File corruption due to hard reset
  • Unpredictable random reboots

So avoid using live servers to test Linux kernel watchdog.

Watchdog Module

Watchdog functionality on the hardware side sets up a timer that times out after a predetermined period. The watchdog software then periodically refreshes the hardware timer. If the software stops refreshing, then after the predetermined period, the timer performs a hardware reset of the device. In order for a watchdog timer to be functional, the motherboard manufacturer has to use the chip’s watchdog functionality. Often the documentation from the manufacturer is not clear about whether the functionality was implemented. In that case, you have to test it out.

Also, you need the right watchdog kernel module to be loaded in your Linux system. Different chips use different modules. For example:

  • Intel chipsets might use the “iTCO_wdt” module
  • HP hardware might use “hpwdt”
  • IBM mainframes might use “vmwatchdog”
  • Xen VM might use “xen_wdt”

After the module is loaded, you can check /dev/watchdog on the Linux system. If this file is present, that means the watchdog kernel device driver or module was loaded. The system periodically keeps writing to /dev/watchdog. It is also called “kicking or feeding the watchdog”. If the system fails to kick or feed the watchdog, then after a while the system is hard reset.

Watchdog Daemon

The watchdog daemon opens the device and provides the necessary refresh to keep the system from resetting. It can test process table space, memory usage, file accessibility, work overload, file table overflow, IP address ping, network interface traffic, temperature, running processes and more. If the tests fail, then watchdog causes a shutdown.

Starting and Stopping Watchdog

Watchdog daemon should start at boot time and put itself in the background. You can check if it is running:

ps -af | grep watch*

If the kernel is NOT compiled with CONFIG_WATCHDOG_NOWAYOUT, then if you close the /dev/watchdog properly, it will not cause a reboot. You can write the character V into /dev/watchdog and then close the file. This should stop the watchdog.

Testing the Watchdog

If you want to test if the hardware watchdog is working, you can do the following from your administrator command prompt:

cat >> /dev/watchdog

And press “enter” twice and wait. The prompt will not come back. After awhile depending on your kernel’s setting, the system should perform the hard reboot.

References:

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to use variable in awk command

Variables are used to store any value temporary in any programming language.  Defining the variable in awk command is...
29/12/2020

[Python] Sử dụng tiện ích Remote-SSH trên Visual Studio Code để code Python trên remote server

Trong bài viết này , mình xin chia sẻ về một thủ thuật hữu ích để code Python một cách dễ dàng...
30/12/2020

Collections in Python

Python collections are just containers which can contain data objects of various data-types inside them. Each collection...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024