Monitoring System Performance


If your Linux system is being used as a multiuser computer, sharing the processing power of that computer can be a major issue. Likewise, any time you can stop a runaway process or reduce the overhead of an unnecessary program running, your Linux server can do a better job serving files, Web pages, or e-mail to the people that rely on it.

Utilities are included with Linux that can help you monitor the performance of your Linux system. The kinds of features you want to monitor in Linux include CPU usage, memory usage (RAM and swap space), and overall load on the system. The following sections describe tools for monitoring Linux.

Watch Computer Usage with System Monitor

If you like visual representations of your system use, the System Monitor provides a great way to see how much your system is being used. To open the System Monitor from the System menu on the GNOME panel, select Administration System Monitor. Figure 10-6 shows the System Monitor window with the Resources tab selected.

image from book
Figure 10-6: System Monitor graphically displays your system's CPU and memory usage.

On the Resource Monitor window, lines scroll from right to left, indicating the percentage of your CPU being used as it rises and falls . You can also see how much of your total memory (RAM) is being used at the moment (and over time), as well as the amount of swap space being used. The bar at the bottom of the window shows the amount of data being sent and received over your computers network interfaces.

Click the Processes tab to see a listing of processes that are running for the current user . Click the columns in that tab to sort processes by name , memory use, percentage of CPU being consumed by the process, and process ID. There are also columns showing the security context of the process (if SELinux is enabled) and the arguments associated with the process.

Click the Devices tab to see the storage devices (hard disk partitions, CD, USB flash drive, or other) that are currently mounted on your computer. Click columns to sort the devices by device name, directory name, file system type, total disk space, free disk space, or used disk space.

The example in Figure 10-6 shows a computer that is running with only 256MB of RAM. Because there is not much activity on the System Monitor in this example, there is still User memory available. However, if on your system User memory is running near the maximum, it would indicate the likely occurrence of performance problems as RAM fills up and data has to be moved to swap space. The CPU used is only about 34 percent, which indicates that the CPU is keeping up with the demand.

Monitoring CPU Usage with Top

Start the top utility in a Terminal window, and it displays the top CPU consuming processes on your computer. Every five seconds, top will determine which processes are consuming the most CPU time and display them in descending order on your screen.

By adding the -S option to top , you can have the display show you the cumulative CPU time that the process, as well as any child processes that may already have exited, has spent. If you want to change how often the screen is updated, you can add the -d secs option, where secs is replaced by the number of seconds between updates.

By default, processes are sorted by CPU usage. You can sort processes numerically by PID (press N), by age (press A), by resident memory usage (press M), by time (press T), or back to CPU usage (press P). The following output shows an example of top running, with information sorted by memory use. The system shown is running a GNOME desktop, with OpenOffice.org Writer, Firefox Web browser and several other applications active. Notice that the amount of memory free is very low. To get good performance out of a Fedora desktop system, 256MB is not enough once you start running a few applications.

  top - 16:11:41 up 10:27, 2 users, load average: 1.60, 0.51, 0.18   Tasks: 107 total, 2 running, 103 sleeping, 0 stopped , 2 zombie   Cpu(s): 16.6%us, 6.5%sy, 0.0%ni, 0.0%id, 76.9%wa, 0.0%hi, 0.0%si, 0.0%st   Mem: 252424k total, 249224k used, 3200k free, 2360k buffers   Swap: 1020088k total, 14240k used, 1005848k free, 86820k cached   PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND   4242 chris 18 0 183m 37m 25m R 19.9 15.0 0:05.86 swriter.bin   4217 chris 15 0 137m 31m 17m S 0.0 12.9 0:07.27 firefox-bin   4244 chris 15 0 39148 18m 7684 S 0.0 7.6 0:04.94 beagled-helper  4138 chris 15 0 101m 14m 9.8m S 0.0 5.9 0:06.87 baobab 

Monitoring Power Usage on Laptop Computers

To effectively use a laptop computer, you need to be able to monitor and manage the laptop's power usage. Using tools provided in Fedora or RHEL, you can configure your laptop to:

  • Monitor the battery level.

  • Notify you when the battery is low.

  • Notify you when the battery is fully charged.

  • Show when the laptop is plugged in.

  • Suspend the current session.

Fedora and RHEL offer two facilities that do power management: APM and ACPI.

  • Advanced Power Management (APM) - APM can be used to monitor the battery of your notebook and notify user-level programs to tell you when your battery is low. It can also be used to place your laptop into suspend mode.

  • Advanced Configuration and Power Interface (ACPI) - Besides monitoring power features on your laptop, ACPI can also do thermal control, motherboard configuration, and change power states.

Many older laptops do not include support for ACPI in the BIOS, so you must use APM to monitor and manage your batteries. For some newer laptops, ACPI may be required. In general, ACPI offers a more complete feature set for power management, but APM has more user-level support today.

To check whether ACPI or APM are supported on your Linux system, you can use the dmesg command after a reboot. For example, type:

 #  dmesg  less  

Page through the output looking for lines beginning with text strings ACPI or apm . On a computer where APM wasn't working, I saw the message "apm: overridden by ACPI." When ACPI wasn't working, I saw the message "ACPI: System description tables not found."

The following procedure was performed on a laptop that used ACPI to manage power events. It describes how to use the GNOME Power Manager applet on the desktop to monitor your battery.

Note 

If it seems that either ACPI or APM are interfering with the proper operation of your laptop, you can turn off either service when you boot your computer. Add either acpi=off or apm=off to the end of the kernel line (from the GRUB boot screen or the /boot/grub/grub.conf file) to turn off ACPI or APM, respectively.

Using the Power Manager Applet

If you are using the GNOME desktop, the GNOME Power Manager applet should automatically appear on your panel to keep track of the power levels of your battery (if a battery is present). The following procedure steps you through adding the monitor to your panel (if it is not already there) and configuring it to behave as you like.

  1. Move the mouse pointer over the battery icon in the top panel. A tooltip should tell you whether or not your laptop is currently running on AC power and your battery's current charge level. Figure 10-7 shows an example of battery information for a laptop that is on AC power and that is in the process of recharging the battery.

  2. Right-click the battery icon and select Preferences. The Power Management Preferences window appears.

  3. Change any of the following values related to your battery monitor:

    • Sleep - From the Sleep tab, you can select how many minutes of idle time should elapse before putting the computer or display to sleep. Each of those values can be set differently for when the laptop is running on AC power or on batteries.

    • Options - From the Options tab, you can set the type of action that occurs when the laptop is asked to go to sleep, when the suspend button is pressed, when the laptop lid is closed and when the power is critically low. By default, the first three cases cause the computer to go into suspend mode, while critically low power causes the computer to shut down.

    • Advanced - From the Advanced tab, you can choose when (or if) an icon is displayed on the panel to indicate your battery life.

image from book
Figure 10-7: View battery status from the Power Management applet in the GNOME panel.

Using apm to Enter Suspend Mode

If the apm service is running, the apm command lets you view information about your computer's power management and put the computer in suspend mode (if it is supported on your laptop). Here are some examples of using the apm command:

 #  apm -m  

Using the -m option, the apm command displays the number of minutes of battery life remaining (if that information is available). It may also give you information about the status of how the battery is charging and whether or not the laptop is currently plugged in.

 #  apm -s  

The -s option of apm causes the laptop to enter suspend mode. You can start up the laptop again, in most cases, by pressing a key on the keyboard.

Using acpi_listen to Monitor ACPI Events

If ACPI is running on your system, you can monitor ACPI events using the acpi_listen command. As root user, type the following from a Terminal window:

 #  acpi_listen  ac_adapter AC 00000080 00000000 processor CPU 00000080 00000000 processor CPU 00000081 00000000 battery BAT0 00000080 00000001 ac_adapter AC 00000080 00000001 processor CPU 00000080 00000000 processor CPU 00000081 00000000 battery BAT0 00000080 00000001 button/lid LID 00000080 00000001 button/lid LID 00000080 00000002 

The message above appeared when the AC power was disconnected, the power was reconnected, the laptop's lid was closed and the lid was again opened.




Fedora 6 and Red Hat Enterprise Linux Bible
Fedora 6 and Red Hat Enterprise Linux Bible
ISBN: 047008278X
EAN: 2147483647
Year: 2007
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net