• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to obtain virtual/physical CPU information in Oracle VM (XEN)

by admin

This post explains how to obtain virtual or physical CPU usage of an Oracle VM Server, including actual CPU usage and running time of guest domains. Guest-specific (Dom-U) CPU usage can be obtained by running commands on the guest itself, for example; top, ps, and sar.

If, however, you wish to obtain specific CPU usage, including that of the Oracle VM Server management domain/hypervisor (Dom-0), the following xen-tools utilities are available to run on the Oracle VM Server:

  • /usr/sbin/xentop -v
  • /usr/sbin/xenmon.py

1. xentop

The xentop -v command display virtual CPU information e.g.:

# xentop -v
6 domains: 2 running, 3 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown 
Mem: 8312440k total, 6212448k used, 2099992k free    CPUs: 2 @ 2128MHz 
      NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR SSID 
4461_EL5U3 ------      53060    0.0    1056636   12.7    1064960      12.8     1    0        0        0    3        0        0        0    0 
VCPUs(sec):   0:      53060s 
4474_EL5U2 ------      45070    0.0    1056636   12.7    1064960      12.8     2    0        0        0    2        0        0        0    0 
VCPUs(sec):   0:      32213s  1:      12857s 
4516_EL4U6 -----r     512039    0.0    1056636   12.7    1064960      12.8     1    0        0        0    2        0        0        0    0 
VCPUs(sec):   0:     512039s 
4570_EL464 --b---        302    0.0    2097152   25.2    2097152      25.2     1    1       10   218297    1        0    22371    16768    0 
VCPUs(sec):   0:        302s 
  Domain-0 -----r      87787    0.0     254976    3.1   no limit       n/a     2    8  1717873  4158394    0        0        0        0    0 
VCPUs(sec):   0:      57819s  1:      29968s 
4511_EL564 --b---        108    0.0     524288    6.3     524288       6.3     2    1      342   214623    1        0      822        1    0 
VCPUs(sec):   0:         96s  1:         12s

In the example above, domains Domain-0, 4474_EL5U2 and 4511_EL564 each utilize two virtual CPUs, whereas all others only utilize one virtual CPU. Domain Domain-0 utilizes a total CPU time of 87787 seconds; 57,819 seconds on VCPU0 and 29,968 seconds on VCPU1.

Xentop usage:

Usage: xentop [OPTION] 
Displays ongoing information about xen vm resources

-h, --help           display this help and exit 
-V, --version        output version information and exit 
-d, --delay=SECONDS  seconds between updates (default 3) 
-n, --networks       output vif network data 
-x, --vbds           output vbd block device data 
-r, --repeat-header  repeat table header before each domain 
-v, --vcpus          output vcpu data 
-b, --batch          output in batch mode, no user input accepted 
-i, --iterations     number of iterations before exiting
-f, --full-name     output the full domain name (not truncated)         # Note: this can be used from the latest version of Oracle VM Server 2.2.2

The parameters mean:

Parameters meanings
CPU(sec) CPU time which the guest OS has consumed(cumulated)
CPU(%) “CPU percentage which the guest OS consumes currently. Note1: This is calculated as CPU(%) = Actuall Assigned CPU# * Actual CPU Usage on the Guest OS(0-100%).Thus this could be up to 300% when 3 CPUs are assigned to the Guest OS. “”Actuall Assigned CPU#”” is not the Virtual CPU Number assigned to the Guest OS, But Actual CPU Number assigned to the Guest OS, since it should be up to 200% when physical CPU cores are 2 even if VCPUs assigned to the Guest OS are 3 or more. Note2: this is always 0.0% at the 1st xentop output, since this is calculated by dividing the interval of the updates. Thus “”-i”” option needs to be set as 2 or more to get correct CPU(%). Note3: This just shows the CPU usage on Host OS for the Guest OSs, therefore this could be different from the CPU usage (ex. which “”top”” shows) on the Guest OSs.”
MEM(k) Memory size in Kbyte which the guest OS occupies on host OS memory. For Domain0, this is equal value of dom0_mem= specified in /etc/grub.conf of Host OS, and also equal value of “memory =” in vm.cfg for Guest OS. ex. dom0_mem=1024M shows 1048576(kB) for MEM(k) for the Host OS.
MEM(%) Memory size in percentage which the guest OS occupies on host OS memory
MAXMEM(k) Max memory size in Kbyte which the guest OS could occupies on host OS memory
MAXMEM(%) Max memory size in percentage which the guest OS occupies on host OS memory
VCPUS Virtual CPU number which is assigned to the guest OS
NETS Virtual network interface number which is assigned to the guest OS
NETTX(k) network traffic in Kbyte the guest OS sends(cumulated)
NETRX(k) network traffic in Kbyte the guest OS receives(cumulated)
VBDS Virtual block device(=storage) number which is assigned to the guest OS
VBD_OO blocked number of I/O from/to the guest OS
VBD_RD read request number from the guest OS(cumulated)
VBD_WR write request number from the guest OS(cumulated)
VBD_RSECT read sector number from the guest OS(cumulated), old xentop does not show this
VBD_WSECT write sector number from the guest OS(cumulated), old xentop does not show this
SSID N/A

2. Xenmon.py

The xenmon.py command displays specific physical CPU information e.g.:

# /usr/sbin/xenmon.py
CPU = 0        Last 10 seconds (99.80%)                              Last 1 second (99.72%) 
 =============================================================================================================================================================================== 
  1   13.98 ms    1.40%       14.57 us/ex       10.40 ms    1.04%       14.00 us/ex       Gotten 
  1   456.93 ms   45.69%      0.00 ns/io        349.26 ms   34.93%      0.00 ns/io        Blocked 
  1   486.25 ms   48.63%      506.85 us/ex      36.53 ms    3.65%       49.15 us/ex       Waited 
  0   40.33 ms    4.03%       101.06 us/ex      69.70 ms    6.97%       177.92 us/ex      Gotten 
  0   588.45 ms   58.84%      0.00 ns/io        581.26 ms   58.13%      0.00 ns/io        Blocked 
  0   17.87 ms    1.79%       44.77 us/ex       37.90 ms    3.79%       96.75 us/ex       Waited 
  28  26.00 ms    2.60%       16.02 us/ex       20.30 ms    2.03%       14.22 us/ex       Gotten 
  28  611.88 ms   61.19%      0.00 ns/io        586.71 ms   58.67%      0.00 ns/io        Blocked 
  28  26.19 ms    2.62%       16.14 us/ex       67.13 ms    6.71%       47.02 us/ex       Waited 
 Idle 448.98 ms   44.90%      229.59 us/ex      359.74 ms   35.97%      251.82 us/ex      Gotten 
 Idle 0.00 ns     0.00%       0.00 ns/io        0.00 ns     0.00%       0.00 ns/io        Blocked 
 Idle 550.66 ms   55.07%      281.58 us/ex      640.01 ms   64.00%      448.01 us/ex      Waited 
  41  1.40 ms     0.14%       54.30 us/ex       964.77 us   0.10%       57.33 us/ex       Gotten 
  41  459.20 ms   45.92%      0.00 ns/io        470.01 ms   47.00%      0.00 ns/io        Blocked 
  41  1.94 ms     0.19%       75.09 us/ex       11.80 ms    1.18%       701.16 us/ex      Waited 
  13  466.75 ms   46.67%      863.83 us/ex      536.81 ms   53.68%      1.06 ms/ex        Gotten 
  13  0.00 ns     0.00%       0.00 ns/io        0.00 ns     0.00%       0.00 ns/io        Blocked 
  13  8.52 ms     0.85%       15.77 us/ex       8.46 ms     0.85%       16.75 us/ex       Waited 
  49  568.29 us   0.06%       34.60 us/ex       444.77 us   0.04%       31.72 us/ex       Gotten 
  49  546.79 ms   54.68%      0.00 ns/io        560.84 ms   56.08%      0.00 ns/io        Blocked 
  49  1.13 ms     0.11%       69.04 us/ex       6.18 ms     0.62%       441.01 us/ex      Waited 
 *                99.80%                                    99.84%

The above example output displays information about physical CPU 0 i.e. how CPU=0 is used by various domains and how long it has been used within the last 1 and 10 seconds. The first column reports the Domain ID – 0 refers to Dom-0.

Three lines are printed for each domain:

  • 1st row: Gotten = amount of the CPU time/percentage which the CPU is running on the domain.
  • 2nd row: Blocked = amount of sleeping time/percentage.
  • 3rd row: Waited = amount of the CPU time/percentage which the domain is in wait state.

Press the ‘p’ or ‘n’ key to display information for the previous/next physical CPU.

Xenmon.py usage:

usage: xenmon.py [options] 

options: 
  -h, --help            show this help message and exit 
  -l, --live            show the ncurses live monitoring frontend (default) 
  -n, --notlive         write to file instead of live monitoring 
  -p PREFIX, --prefix=PREFIX 
                        prefix to use for output files 
  -t DURATION, --time=DURATION 
                        stop logging to file after this much time has elapsed 
                        (in seconds). set to 0 to keep logging indefinitely 
  -i INTERVAL, --interval=INTERVAL 
                        interval for logging (in ms) 
  --ms_per_sample=MSPERSAMPLE 
                        determines how many ms worth of data goes in a sample 
  --cpu=CPU             specifies which cpu to display data for 
  --allocated           Display allocated time for each domain 
  --noallocated         Don't display allocated time for each domain 
  --blocked             Display blocked time for each domain 
  --noblocked           Don't display blocked time for each domain 
  --waited              Display waiting time for each domain 
  --nowaited            Don't display waiting time for each domain 
  --excount             Display execution count for each domain 
  --noexcount           Don't display execution count for each domain 
  --iocount             Display I/O count for each domain 
  --noiocount           Don't display I/O count for each domain

Filed Under: Linux, Oracle VM

Some more articles you might also be interested in …

  1. groupdel: command not found
  2. mktemp Command Examples in Linux
  3. ss Command Examples in Linux
  4. kscreen-doctor Command Examples in Linux
  5. pvmove Command Examples in Linux
  6. How To Install Python 3 On CentOS 7 Using SCL
  7. eject: command not found
  8. How to configure iSCSI Initiator (client) in CentOS / RHEL 6
  9. How to use “xfs_admin” command to change parameters of an XFS filesystem
  10. How to install packages using dnf in CentOS/RHEL 8

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright