您的位置:首页 > 运维架构 > Linux

Linux资源管理相关的命令

2017-07-27 10:43 281 查看
如何查看CPU和内存的统计数据



FREE(1)                       Linux User's Manual                      FREE(1)

NAME

       free - Display amount of free and used memory in the system

SYNOPSIS

       free [-b | -k | -m | -g | -h] [-o] [-s delay ] [-c count ] [-a] [-t] [-l] [-V]

DESCRIPTION

       free  displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel.  The shared memory column represents the 'Shmem' value.  The

       available memory column represents the 'MemAvailable' value.

   Options

       The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes; the -g switch displays it in gigabytes.

       The -h switch displays all output fields automatically scaled to the shortest (three digit) representation including the unit. That makes the values human readable.

       The -t switch displays a line containing the totals.

       The -o switch disables the display of a "buffer adjusted" line.  If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to the free memory reported.

       The -s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times.

       The -c switch used together with the -s switch interrupts the polling after count repetitions.

       The -l switch shows detailed low and high memory statistics.

       The -a switch shows the available memory (if supported by the running kernel and enabled with sysctl -w vm.meminfo_legacy_layout=0 ; shows zero when unsupported or disabled). The produced out-

       put is wider than 80 characters.

       The -V switch displays version information.

SAR(1)                        Linux User's Manual                       SAR(1)

NAME

       sar - Collect, report, or save system activity information.

SYNOPSIS

       sar [ -A ] [ -b ] [ -B ] [ -C ] [ -d ] [ -h ] [ -i interval ] [ -m ] [ -p ] [ -q ] [ -r ] [ -R ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -v ] [ -V ] [ -w ] [ -W ] [ -y ] [ -j { ID | LABEL | PATH | UUID

       | ... } ] [ -n { keyword [,...] | ALL } ] [ -I { int [,...] | SUM | ALL | XALL } ] [ -P { cpu [,...] | ALL } ] [ -o [ filename ] | -f [ filename ] ] [ --legacy ] [ -s [ hh:mm:ss ]  ]  [  -e  [

       hh:mm:ss ] ] [ interval [ count ] ]

DESCRIPTION

       The  sar  command  writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval

       parameters, writes information the specified number of times spaced at the specified intervals in seconds.  If the interval parameter is set to zero,  the  sar  command  displays  the  average

       statistics  for the time since the system was started. If the interval parameter is specified without the count parameter, then reports are generated continuously.  The collected data can also

       be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen. If filename is omitted, sar uses the standard  system  activity  daily  data  file,  the

       /var/log/sa/sadd file, where the dd parameter indicates the current day.  By default all the data available from the kernel are saved in the data file.

       The sar command extracts and writes to standard output records previously saved in a file. This file can be either the one specified by the -f flag or, by default, the standard system activity

       daily data file.

       Without the -P flag, the sar command reports system-wide (global among all processors) statistics, which are calculated as averages for values expressed as percentages, and as sums  otherwise.

       If  the  -P  flag  is given, the sar command reports activity which relates to the specified processor or processors. If -P ALL is given, the sar command reports statistics for each individual

       processor and global statistics among all processors.

       You can select information about specific system activities using flags. Not specifying any flags selects only CPU activity.  Specifying the -A flag is equivalent to specifying -bBdqrRSvwWy -I

       SUM -I XALL -n ALL -u ALL -P ALL.

       The  default  version  of  the  sar command (CPU utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system

       resources. If CPU utilization is near 100 percent (user + nice + system), the workload sampled is CPU-bound.

       If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command.  Run the sar command as a background process. The syntax for this is:

       sar -o datafile interval count >/dev/null 2>&1 &

       All data is captured in binary form and saved to a file (datafile).  The data can then be selectively displayed with the sar command using the -f option. Set the interval and count  parameters

       to  select  count  records  at interval second intervals. If the count parameter is not set, all the records saved in the file will be selected.  Collection of data in this manner is useful to

       characterize system usage over a period of time and determine peak usage hours.

       Note:     The sar command only reports on local activities.

VMSTAT(8)                Linux Administrator's Manual                VMSTAT(8)

NAME

       vmstat - Report virtual memory statistics

SYNOPSIS

       vmstat [-a] [-n] [-t] [-S unit] [delay [ count]]

       vmstat [-s] [-n] [-S unit]

       vmstat [-m] [-n] [delay [ count]]

       vmstat [-d] [-n] [delay [ count]]

       vmstat [-p disk partition] [-n] [delay [ count]]

       vmstat [-f]

       vmstat [-V]

DESCRIPTION

       vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity.

       The  first report produced gives averages since the last reboot.  Additional reports give information on a sampling period of length delay.  The process and memory reports are instantaneous in

       either case.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: