LAB 12 ‐ Performance Monitoring and Alerting for CPU, Memory of instance - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki

Performance Monitoring and Alerting in OCI (CPU & Memory) Overview

In Oracle Cloud Infrastructure (OCI), monitoring helps you track the health and performance of your compute instances. You can monitor metrics like CPU and memory usage and set alerts to get notified when thresholds are exceeded.

Key Components

  1. Monitoring Service

OCI provides a built-in Monitoring Service to collect and analyze metrics such as:

CPU utilization Memory usage Network traffic

  1. Metrics for Compute Instances CPU Utilization Measures how much CPU is being used. Available by default in OCI.

Example: 80% CPU usage means high workload on instance. Memory Utilization Shows how much RAM is being used. Requires enabling OS Management / Monitoring agent.

Example: 90% memory usage may cause performance issues. Creating Alarms (Alerting)

What is an Alarm?

An alarm monitors a metric and triggers a notification when a condition is met.

Example Alerts CPU Alert Condition: CPU Utilization > 80% for 5 minutes Action: Send email notification Memory Alert Condition: Memory Usage > 85% Action: Trigger alert to admin Notifications

OCI uses the Notifications Service to send alerts via:

Email SMS Slack / HTTPS Best Practices Set realistic thresholds (avoid too many alerts) Monitor both CPU and memory together Use dynamic groups + policies for automation Enable monitoring agent for detailed metrics Review alarms regularly Simple Example

Imagine a web server:

CPU spikes to 90% Alarm triggers You receive email You scale instance or fix issue Summary

Performance monitoring in OCI ensures:

Better resource utilization Early issue detection Improved application reliability

Steps to create performance monitoring and CPU alerts

1.Navigate to burger menu select compute and go to instances

2.Select the instance that you have created

3.Inside the instance go to monitoring tab

4.Now in the Monitoring tab, click on the three dots in the CPU Utilization section and select the option to create an alarm on this query.

  1. While creating the alarm in OCI, enter the alarm name, add a brief summary, and verify the metric description to ensure it matches the selected CPU utilization metric.

6.Select the appropriate notification topic to specify who should receive the alert when the alarm is triggered. Once selected, click Save Alarm to finalize and create the alarm.

  1. To see the alarm that you have created navigate to burger menu click on observability and management then click on Monitoring.

🔹 CPU Load Testing & Alert Verification (OCI) 🔸 Objective

👉 “CPU load was artificially increased using background processes, and verified using top and uptime commands. Alarm was triggered when CPU crossed threshold and returned to OK state after load normalization.”

🔹 Steps to Increase CPU Load

  1. Connect to Instance Login to the instance using PuTTY (SSH)
  2. Generate CPU Load using Python

Run the following command:

python3 -c "while True: pass"

👉 This command runs an infinite loop and continuously consumes CPU.

  1. Increase Load Further (Optional) Run the same command multiple times (2–4 times) in separate sessions or background This increases CPU utilization above threshold (e.g., 70–80%) 🔹 Verify CPU Usage
  2. Check CPU Utilization top

👉 Displays real-time CPU usage

[Run to check high CPU usage from top command]

  1. Check Load Average (LR) uptime

👉 Shows system load average

Example:

load average: 2.00, 1.80, 1.50

[Run uptime command showing load average]

🔹 Stop CPU Load pkill -f python3

👉 Stops all running Python processes

🔹 Alarm Verification

  • When CPU usage crosses threshold:
  • Alarm state → FIRING
  • When CPU returns to normal:
  • Alarm state → OK

🔹 Key Concept Python infinite loop is a reliable method to simulate CPU load Multiple executions increase CPU usage further Monitoring alarms validate system performance thresholds 🔹 Conclusion

CPU load testing helps ensure that OCI monitoring and alerting are working correctly. By simulating high utilization and verifying alarm states, we can confirm system reliability and responsiveness.