Friday, June 03, 2005

watch command monitoring

Monitoring system events in real-time is essential for troubleshooting
and debugging. Most Unix and Linux admins are already familiar with ps
and top. Add the watch command to your toolkit as well. watch lets you
observe the results of running a single command repeatedly, with all
of your chosen options. For example, to observe activity on an NIC in
real time:

$ watch -d /sbin/ifconfig eth0

Ctrl+c stops it. The -d flag highlights the changes. The default is to
rerun the command every two seconds. This can be changed with the -n
flag, which in this example is set for every second:

$ watch -n 1 -d /sbin/ifconfig eth0

To monitor memory usage:

$ watch -d free

Keep an eye on the printer queue with:

$ watch lpq

And monitor CPU temperature:

$ watch cat /proc/acpi/thermal_zone/THRM/temperature

In other words, you may watch any command in real-time. Consult the
watch man page to lean more.

0 Comments:

Post a Comment

<< Home