## 3 Architecture of the Proposed Solution
### Algorithm(s) used for the Proposed Solution  
Here, we discuss the proposed algorithms for our monitoring solution. These algorithms are used by our monitoring solution to collect data. The key issues that our submitted algorithm addresses are as follows. Figure 1: Schematic diagram of the proposed solution. * The obtaining of the PID of the OS interface. * The monitoring of the CPU steal time. The following are the algorithms used to collect the monitoring data for the metrics mentioned above. * Algorithm 1: To obtain the PID of the VM. * Algorithm 2: To collect data for the CPU steal time of a VM. ```
1 Receive query x from Monitoring. 2 Do
3 if (x = PID) then
4 Get PID from/proc
5 Monitoring \(\leftarrow\) PID
6 Else
7 if (x = server_ID) then
8 Get server_ID from/proc/PID/cmdline
9 Monitoring \(\leftarrow\) server_ID
10 endif
11 endif
12 End
```  
**Algorithm 1 OS interface**  
Algorithm 1 represents the OS interface, which plays a crucial role in monitoring. When the monitoring component sends a query (denoted as x) to the OS interface using the push model, the algorithm processes the query and responds accordingly. The algorithm begins by receiving the query x from the monitoring component. It then proceeds to evaluate the query by following the steps outlined below. If the query x requests the process identifier (PID), the algorithm enters the \"if\" condition at line 3. In this case, it retrieves the process identifier (PID) from the /proc directory, which contains system information about the running processes. The obtained PID value is then assigned to the monitoring component, enabling it to track and monitor the specific strategy. Alternatively, if the query x pertains to the server identifier (server_ID), the algorithm moves to the \"else if\" condition at line 7. It retrieves the server_ID associated with the queried process by accessing the /proc/PID/cmdline file. This file contains the command line arguments to launch the process with the specified PID. The algorithm retrieves the server_ID value from this file and assigns it to the monitoring component, allowing it to monitor and track the specific virtual machine (VM) within the cloud environment. Utilizing Algorithm 1, the OS interface bridges the monitoring component and the operating system. It effectively handles different queries, retrieves the relevant information from the appropriate system files, and delivers the necessary data back to the monitoring component, facilitating comprehensive monitoring capabilities. ```
1 Receive query x from Monitoring. 2 Do
3 if (x = PID) then
4 Get PID from/proc
5 Monitoring \(\leftarrow\) PID
6 Else
7 if (x = server_ID) then
8 Get server_ID from/proc/PID/cmdline
9 Monitoring \(\leftarrow\) server_ID
10 endif
11 endif
12 End
```  
**Algorithm 2**  
Algorithm 2 outlines the process of monitoring the CPU steal time for a virtual machine (VM). The CPU steal time refers to the amount of time a virtual CPU waits for the physical CPU. This algorithm collects the CPU steal time statistics and evaluates them against predefined threshold values to determine the status of the VM. The algorithm begins by starting the process (line 1). It then retrieves the process ID (PID) of the VM from the /proc/directory of the host machine (line 2). Using this PID, the algorithm accesses the /proc/PID/stat file to obtain the CPU steal time of the VM (line 3). The algorithm enters a loop (lines 4-13) to compare the CPU steal time against specific threshold values and to assign a corresponding status. The status is set to 'OK' if the CPU steal time is less than 2 (lines 5-6). If the CPU steal time is between 3 and 7, the status is set to 'WARNING' (lines 7-8). If the CPU steal time exceeds 7, the status is 'CRITICAL' (lines 9-10). After determining the status, the algorithm prints a message indicating the CPU steal time of the VM along with the corresponding status (line 12). This provides visibility to the current CPU steal time performance of the VM.