Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux Timesaving Techniques For Dummies.pdf
Скачиваний:
59
Добавлен:
15.03.2015
Размер:
15.98 Mб
Скачать

134 Technique 21: Making Your Inner System Administrator Happy (And Productive)

• Figure 21-3: The grace period file.

Change the grace period if you want — you can specify a number of days, hours, minutes, or seconds. Be sure to give yourself a reasonable amount of time to clean things up (at least a day). Save the file and close the editor when you’re finished.

Reviewing your quotas

To generate a complete listing of the quota definitions and the current system usage, type in this command:

# repquota -vugs /home

repquota generates a quota report listing the space used by all users (-u) and groups (-g) on the /home file system. The -v option tells repquota to produce a more detailed (or verbose) report that displays quota definitions that are not currently in use. By default, repquota displays quota information in terms of 1024-byte blocks; the -s flag tells repquota to print the totals in more readable terms (megs instead of blocks). The last argument in the command indicates the file system — in this case, the /home file system. To display quota information for all file systems, use the -a flag instead (repquota -avugs).

The listing shows user quotas first and then group quotas, as shown in Figure 21-4.

• Figure 21-4: The user quota report.

Worthy of note are the grace columns. If a quota has been exceeded, the amount of time left in the grace period is displayed. If the grace period has expired, none appears in the column.

Using System Accounting to Keep Track of Users

Linux gives you a number of command-line tools that can help you keep track of the resources used by a given user (not just disk space, but CPU time, connect time, and memory usage as well). After you’ve installed the tools, with a few quick keystrokes you can determine which users spend the most time at their keyboards.

Setting up system accounting

To install the psacct package on Fedora or Mandrake, or the equivalent, acct on SuSE, follow these steps:

1. Open a terminal window and give yourself superuser privileges with the su command.

2. Insert and mount your distribution disc.

Using System Accounting to Keep Track of Users

135

3. Use the cd command to move to the directory containing the RPM packages.

4. Type the following command and press Enter:

# rpm -Uhv psacct-version.rpm

On SuSE, install the acct package with the command:

#rpm -Uhv acct-version.rpm

The installation process creates a new background daemon.

To start the psacct service (or acct, if you’re running SuSE), follow these steps:

1. Open a terminal window and give yourself superuser privileges with the su command.

2. Start the service:

If you’re running Fedora, the command is

# /sbin/service psacct start

If you’re running Mandrake, use the command:

# /sbin/service psacct start

If you’re a SuSE user, start the service with the command:

# /etc/init.d/acct start

Now you’re up and running. Linux keeps track of resource usage in the /var/run/utmp and /var/log/ wtmp files.

The wtmp file can grow quickly. It’s a good idea to clean it up every now and then.

Looking up user login hours

Of all the information you can call up in a flash, summaries of user login hours are among the most useful. Use the ac command to find out how long (in hours) your users have been logged in. To generate a list of login hours, itemized by user, enter the following command:

The result will look something like this:

[freddie@bastille freddie]$ ac -p freddie 7.03

duncan 2.02 franklin 6.54 root 1.02 total 16.61

To generate a list of total login hours on a daily basis, use the -d flag:

$ ac -d

The result is a daily list of connect-time hours:

[freddie@bastille freddie]$ ac -d Feb 1total 0.33

Feb 2total 12.54 Todaytotal 1.01

One thing to note — the daily total is for everyone logged in.

This is a quick way to find out total system man hours if you need to answer to accounting about department costs or want to request more resources in a budget meeting.

The two flags we’ve listed are probably the most useful, but other flags work with the ac command as well. Check out the man page for more ideas — man ac.

Checking out command and program usage

Another useful command that comes courtesy of system accounting is the sa command. Use the sa command to find out which programs are being used on your system. To use the sa command, first you need to give yourself superuser privileges with the su - command. Then to generate a report of command usage, enter the following command:

# sa

The report shows the command usage for the system, as shown in Figure 21-5.

$ ac -p

136 Technique 21: Making Your Inner System Administrator Happy (And Productive)

• Figure 21-5: The result set from the sa command.

The columns in the result set (from left to right) contain the following information:

Total number of invocations

Total elapsed time

Combined system and user time in seconds

Average number of I/O operations (not currently used in some versions of Linux)

Memory usage in 1K blocks

Command name

The sa command generates a list showing a subset of all commands. (Commands executed only once and commands with unprintable characters are grouped into an entry labeled ***other*.) To see a complete list, use this command:

# sa --list-all-names

To summarize the list by user, use this command:

# sa -m

For a quick overview of system usage that includes statistics by percentage of resource used, use the following command:

#sa -c

Combine the sa command with the grep command to show usage of a specific program:

# sa | grep program

The preceding command returns a report including statistics only on the command named.

Keeping an eye on command usage can tell you what people are up to. You can find out if a lot of cping is going on that shouldn’t be.

These are just some of the options of the sa command. For a complete list, check out the man page — man sa.

Соседние файлы в предмете Операционные системы