Amazon Elastic Process Cloud (EC2) gives Elastic computing capacities in the cloud, permitting organizations to run applications with a degree of adaptability that customary servers can't coordinate. As a component of overseeing EC2 cases, monitoring and checking the cycles running on the server to guarantee smooth activity, keep up with security, and investigate issues is fundamental. Knowing how to check the running cycles is central for system managers, DevOps designers, and engineers operating in cloud conditions.Understanding Processes in EC2Before exploring the strategies, it's critical to comprehend what cycles are. An interaction is a running project. Each interaction has an extraordinary Cycle ID (PID) and works inside its memory space. Processes can be system processes, similar to services essential for the operating system, or client processes, such as applications launched by the client.In an EC2 example, running cycles can consume CPU, memory, and I/O, affecting the case's presentation. Observing these cycles keeps up with ideal execution, avoids resource exhaustion, and detects malicious exercises.Importance of Monitoring ProcessesChecking the process running on your EC2 instance is significant in light of multiple factors:Performance Optimization: By following asset utilization, you can recognize bottlenecks, high memory utilization, and different failures.Troubleshooting: If your application is lazy or failing to meet expectations, dissecting the cycles can help you distinguish the underlying driver.Security: Dubious or obscure cycles might demonstrate malware or unapproved movement.Compliance: Contingent upon your industry, you might be expected to log or screen processes for the end goal of evaluating.Methods to Check Running Processes on an EC2 InstanceUsing SSH to Access Linux EC2 InstancesThe most widely recognized method for checking processes on a Linux-based EC2 instance is to interface with it using SSH. When associated, a few command-line tools can be utilized to list and oversee processes.Step 1: SSH into the EC2 InstanceTo connect to an EC2 instance using SSH, follow these steps:ssh -i /path/to/key.pem ec2-user@ec2-public-ipReplace /path/to/key.pem with the path to your confidential key and ec2-public-ip with the public IP address of your EC2 occasion.Step 2: Using the ps CommandThe ps order is one of the easiest and most familiar ways of posting running cycles in Linux. The basic syntax is:ps auxThis command gives a point-by-point rundown of every running interaction, with data, such as the client who began the cycle, computer chip use, memory use, PID, and order that started the interaction.Step 3: Using top CommandThe top command gives a real-time, unique perspective on running cycles. It shows an arranged rundown of cycles by a central processor or memory utilization, permitting you to screen asset utilization progressively.To use the top, simply run:topYou can exit the top command by pressing q.Step 4: Using htop (Alternative to top)The htop command is an upgraded top version with an intuitive UI. It gives various coded data and considers more straightforward interactions on the board. Nonetheless, it may not be introduced on your EC2 occasion.To install htop:sudo yum install htop # For Amazon Linux/RedHat sudo apt-get install htop # For Ubuntu/DebianOnce installed, run:htopStep 5: Using pgrep CommandIf you're searching for a particular cycle, the pgrep order can be utilized to look for processes by name. For example, to find the PID of Apache processes:pgrep apache2Step 6: Using lsof to List Open FilesThe lsof command lists open documents and the processes utilizing them. This helps identify which methods are utilizing explicit documents or organization associations.To list all open files:sudo lsofTo list open files for a specific process:sudo lsof -p <PID>Steps to Check Processes on EC2 and Send Email NotificationsStep 1: Connect to Your EC2 Instancessh -i /path/to/your-key.pem ec2-user@<your-ec2-public-ip>Step 2: Install Required PackagesFor Amazon Linux:sudo yum install -y mailxFor Ubuntu:sudo apt-get install -y mailutilsStep 3: Create a Script to Check Processesnano check_processes.shAdd the following code to the script:#!/bin/bash # Define email variables EMAIL="your_email@example.com" SUBJECT="Running Processes on EC2 Instance" PROCESS_INFO=$(ps aux) # Send email with the process information echo "$PROCESS_INFO" | mail -s "$SUBJECT" "$EMAIL"Step 4: Make the Script Executablechmod +x check_processes.shStep 5: Test the Script./check_processes.shStep 6: Schedule the Script Using Croncrontab -e 0 * * * * /path/to/check_processes.shExample Commands in Sequence# Connect to your EC2 instance ssh -i /path/to/your-key.pem ec2-user@<your-ec2-public-ip> # Install mail utility sudo yum install -y mailx # For Amazon Linux # or sudo apt-get install -y mailutils # For Ubuntu # Create the script nano check_processes.sh # Add the following to check_processes.sh #!/bin/bash EMAIL="your_email@example.com" SUBJECT="Running Processes on EC2 Instance" PROCESS_INFO=$(ps aux) echo "$PROCESS_INFO" | mail -s "$SUBJECT" "$EMAIL" # Make the script executable chmod +x check_processes.sh # Test the script ./check_processes.sh # Schedule the script using cron crontab -e # Add the line: 0 * * * * /path/to/check_processes.shChecking Processes on Windows EC2 InstancesFor Windows-based EC2 instances, you can use Remote Desktop Protocol (RDP) to interface and the Task Manager or PowerShell to screen processes.Step 1: Connect via RDPTo connect to a Windows EC2 instance, open Remote Desktop Connection on your local machine and enter the public IP address of your instance.Step 2: Using Task ManagerOpen Task Manager (Ctrl + Shift + Esc) to see running cycles when connected. The Processes tab outlines a CPU, memory, disk, and network used for each running interaction.Step 3: Using PowerShellYou can likewise utilize PowerShell to list processes on a Windows EC2 instance. To do this, open PowerShell and use the Get-Process command:Get-ProcessThis will display a list of all running processes, similar to the ps command in Linux.Step 4: Using WMICWMIC (Windows Management Instrumentation Command-line) is one more helpful asset to query processes:wmic process list briefThis will list running processes, their Processes, session IDs, and status.Using CloudWatch to Monitor EC2 ProcessesAmazon CloudWatch is an observing service that can follow execution measurements like computer processor use, memory use, and disk action. While it doesn't straightforwardly screen processes, it can provide insight into the general asset utilization of your EC2 instance.Step 1: Enabling CloudWatch MonitoringCloudWatch observing can be empowered through the AWS Management Console, SDKs, or CLI. However, you should be cautious when setting off notifications when resource use surpasses a specific edge, corresponding with explicit processes consuming excessive assets.Step 2: Using CloudWatch Logs AgentThe CloudWatch Logs agents can be installed on your EC2 instance to send log information (counting system logs and application logs) to CloudWatch. This can provide insight into what processes are running and any possible mistakes or issues.Useful Commands to check processes running on AWS EC2 instanceCommandPurposeExampleUsageps auxLists all running processes in snapshot viewps auxCheck running processes with user info and memory usagetopReal-time monitoring of system processestopView dynamic resource usage of processeshtopEnhanced real-time process viewerhtopNavigate, filter, and manage processes interactivelypidof <name>Finds the process ID (PID) of a specific apppidof apache2Get PID of a running servicekill <PID>Terminates a process by PIDkill 1234End a specific processpgrep <name>Lists PIDs of processes with a specific namepgrep nginxFind multiple processes by nameFinal Thoughts on Monitoring EC2 ProcessesChecking processes on your EC2 instances is critical for execution advancement, investigation, and security. For Linux instances, instruments like ps, top, htop, and lsof give nitty-gritty knowledge into running cycles. For Windows instances, Task Manager and PowerShell offer process management capacities. Moreover, Amazon CloudWatch and third-party applications like Nagios and Datadog can assist with checking asset utilization and process activity. You can guarantee that your applications remain safe and secure by consistently checking the processes running on your EC2 instances.Read Morehttps://devopsden.io/article/azure-devops-professionals-jobs-in-ukFollow us onhttps://www.linkedin.com/company/devopsden/