4.3. Managing Processes and Services¶
In Virtuozzo Hybrid Server, services and processes can be managed using the following command-line utilities:
With their help, you can perform the following tasks:
Print the information about active processes on your hardware node.
View the processes activity in real time.
Change the mode of the services that can be either
xinetd-dependent or standalone.
Identify the container UUID where a process is running by the process ID.
The maximum number of processes per container is limited to 131,072.
4.3.1. Viewing Active Processes and Services¶
vzps utility provides certain additional functionality related to monitoring separate containers running on the hardware node. For example, you can use the
-E switch with the
vzps utility to:
Display the container UUIDs where the processes are running.
View the processes running inside a particular container.
vzps prints the information about active processes on your hardware node. When run without any options,
vzps lists only those processes that are running on the current terminal. Below is an example output of
# vzps PID TTY TIME CMD 4684 pts/1 00:00:00 bash 27107 pts/1 00:00:00 vzps
Currently, the only processes assigned to the user/terminal are the
bash shell and the
vzps command itself. In the output, the PID (Process ID), TTY, TIME, and CMD fields are contained. TTY denotes which terminal the process is running on, TIME shows how much CPU time the process has used, and CMD is the name of the command that started the process.
The IDs of the processes running inside containers and displayed by running the
vzps command on the hardware node does not coincide with the IDs of the same processes shown by running the
ps command inside these containers.
As you can see, the standard
vzps command just lists the basics. To get more details about the processes running on your server, you will need to pass some command line arguments to
vzps. For example, using the
aux arguments with this command displays processes started by other users (
a), processes with no terminal or one different from yours (
x), the user who started the process and when it began (
# vzps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 1516 128 ? S Jul14 0:37 init root 5 0.0 0.0 0 0 ? S Jul14 0:03 [ubstatd] root 6 0.0 0.0 0 0 ? S Jul14 3:20 [kswapd] #27 7 0.0 0.0 0 0 ? S Jul14 0:00 [bdflush] root 9 0.0 0.0 0 0 ? S Jul14 0:00 [kinoded] root 1574 0.0 0.1 218 140 pts/4 S 09:30 0:00 -bash
There is a lot more information now. The fields USER, %CPU, %MEM, VSZ, RSS, STAT, and START have been added. Let us take a quick look at what they tell us.
The USER field shows you which user initiated the command. Many processes begin at system start time and often list root or some system account as the user. Other processes are, of course, run by actual users.
The %CPU, %MEM, VSZ, and RSS fields all deal with system resources. First, you can see what percentage of the CPU the process is currently utilizing. Along with CPU utilization, you can see the current memory utilization and its VSZ (virtual memory size) and RSS (resident set size). VSZ is the amount of memory the program would take up if it were all in memory. RSS is the actual amount currently in memory. Knowing how much a process is currently eating will help determine if it is acting normally or has spun out of control.
You will notice a question mark in most of the TTY fields in the
vzps aux output. This is because most of these programs were started at boot time and/or by initialization scripts. The controlling terminal does not exist for these processes; thus, the question mark. On the other hand, the
bash command has a TTY value of pts/4. This is a command being run from a remote connection and has a terminal associated with it. This information is helpful for you when you have more than one connection open to the machine and want to determine which window a command is running in.
STAT shows the current status of a process. In our example, many are sleeping, indicated by an S in the STAT field. This simply means that they are waiting for something. It could be user input or the availability of system resources. The other most common status is R, meaning that it is currently running.
You can also use the
vzps command to view the processes inside any running container. The example below shows you how to display all active processes inside the container
MyCT with UUID 26bc47f6-353f-444b-bc35-b634a88dbbcc:
# vzps -E 26bc47f6-353f-444b-bc35-b634a88dbbcc CTID PID TTY TIME CMD 26bc47f6-353f-444b-bc35-b634a88dbbcc 14663 ? 00:00:00 init 26bc47f6-353f-444b-bc35-b634a88dbbcc 14675 ? 00:00:00 kthreadd/26bc47 26bc47f6-353f-444b-bc35-b634a88dbbcc 14676 ? 00:00:00 khelper 26bc47f6-353f-444b-bc35-b634a88dbbcc 14797 ? 00:00:00 udevd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15048 ? 00:00:00 rsyslogd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15080 ? 00:00:00 sshd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15088 ? 00:00:00 xinetd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15097 ? 00:00:00 saslauthd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15098 ? 00:00:00 saslauthd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15116 ? 00:00:00 sendmail 26bc47f6-353f-444b-bc35-b634a88dbbcc 15125 ? 00:00:00 sendmail 26bc47f6-353f-444b-bc35-b634a88dbbcc 15134 ? 00:00:00 httpd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15139 ? 00:00:00 httpd 26bc47f6-353f-444b-bc35-b634a88dbbcc 15144 ? 00:00:00 crond 26bc47f6-353f-444b-bc35-b634a88dbbcc 15151 ? 00:00:00 mingetty 26bc47f6-353f-444b-bc35-b634a88dbbcc 15152 ? 00:00:00 mingetty
4.3.2. Monitoring Processes in Real Time¶
vztop utility is rather similar to
vzps but is usually started full-screen and updates continuously with process information. This can help with programs that may infrequently cause problems and can be hard to see with
vzps. Overall system information is also presented, which makes a nice place to start looking for problems.
vztop utility can be used just as the standard Linux
htop utility. It shows a dynamic list of all processes running on the system with their full command lines.
By default, it shows information about processor, swap and memory usage, number of tasks, load average, and uptime at the top of the screen. You can change the default meters, along with display options, color schemes, and columns at the setup screen (S or F2).
vztop can be used interactively for sending signals to processes. For example, you can kill processes—without knowing their PIDs—by selecting them and pressing F9. You can also change process priority by pressing F7 (increase; can only be done by the
root user) and F8 (decrease).
vztop utility usually has an output like the following:
# vztop 1 [ 0.0%] Tasks: 77, 65 thr; 1 running 2 [||| 2.6%] Load average: 0.02 0.03 0.05 3 [|||| 4.6%] Uptime: 06:46:48 4 [| 0.7%] Mem[||||||||||||||||||||| 344M/3.68G] Swp[ 0K/3.87G] PID CTID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command 1 0 root 20 0 41620 4132 2368 S 0.0 0.1 0:05.91 /usr/lib/systemd/systemd 3164 0 root 20 0 19980 1380 1160 S 0.0 0.0 0:00.32 /usr/1ib/systemd/systemd- 3163 0 root 21 1 1402M 56992 10204 S 0.0 1.5 4:12.41 /usr/libexec/qemu-kvm -na 3186 0 root 20 0 1402M 56992 10204 S 0.0 1.5 0:00.09 /usr/libexec/qemu-kvm -na 3185 0 root 20 0 1402M 56992 10204 S 0.7 1.5 2:16.83 /usr/libexec/qemu-kvm -na 3180 0 root 20 0 1402M 56992 10204 S 0.0 1.5 0:00.00 /usr/libexec/qemu-kvm -na 3084 0 smmsp 20 0 85712 2036 516 S 0.0 0.1 0:00.19 sendmail: Queue runner@01 3064 0 root 20 0 98M 2380 572 S 0.0 0.1 0:01.43 sendmail: accepting conne 3036 0 root 20 0 291M 4788 3580 S 0.0 0.1 0:00.00 /usr/sbin/virt1ogd 3037 0 root 20 0 291M 4788 3580 S 0.0 0.1 0:00.00 /usr/sbin/virt1ogd 2787 0 nobody20 0 15548 896 704 S 0.0 0.0 0:00.14 /sbin/dnsmasq --conf-file 2788 0 root 20 0 15520 184 0 S 0.0 0.0 0:00.00 /sbin/dnsmasq --conf-file 2479 0 root 20 0 1962M 33344 24160 S 0.7 0.9 3:13.12 /usr/sbin/pr1_disp_servic 9022 0 root 20 0 1962M 33344 24160 S 0.0 0.9 0:10.74 /usr/sbin/pr1_disp_servic
CTID shows the container UUID inside which the process is running (
0 means that it is running on the server).
PRI (PRIORITY) displays the kernel’s internal priority for the process.
NI (NICE) shows niceness (the nicer the process, the more it lets other processes take priority).
To organize processes by parenthood, you can switch to the tree view by pressing F5.
4.3.3. Determining Container UUIDs by Process IDs¶
Each process is identified by a unique PID (process identifier), which is the entry of that process in the kernel’s process table. For example, when you start Apache, it is assigned a process ID. This PID is then used to monitor and control this program. The PID is always a positive integer. In Virtuozzo Hybrid Server, you can use the
vzpid (retrieve process ID) utility to print the container UUID the process with the given id belongs to. Multiple process IDs can be specified as arguments. In this case the utility will print the container number for each of the processes.
The typical output of the
vzpid utility is shown below:
# vzpid 14663 Pid VEID Name 14663 26bc47f6-... init
You can also display the container UUID where the corresponding process is running by using the