Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c809a0

Browse files
OS_interaction script added
1 parent dd335c4 commit 4c809a0

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎OS_interaction/OS_interaction.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import psutil
2+
import time
3+
import os
4+
5+
def monitor_cpu_threshold(threshold):
6+
while True:
7+
cpu_percent = psutil.cpu_percent(interval=1)
8+
print(f"Current CPU Usage: {cpu_percent}%")
9+
10+
if cpu_percent > threshold:
11+
print("CPU usage exceeds threshold!")
12+
# You can add more actions here, such as sending an email or notification.
13+
# For simplicity, we'll just print an alert message.
14+
os.system("say 'High CPU usage detected!'") # macOS command to speak the message
15+
16+
time.sleep(10) # Wait for 10 seconds before checking again
17+
18+
if __name__ == "__main__":
19+
threshold_percent = 80 # Define the CPU usage threshold in percentage
20+
monitor_cpu_threshold(threshold_percent)

‎OS_interaction/README.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OS_interaction script
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import psutil,time,os
7+
8+
9+
## Setup instructions
10+
11+
12+
Just Need to import psutil,time,os then run the OS_interaction.py file and for running python3 is must be installed!
13+
14+
## Detailed explanation of script, if needed
15+
16+
This Script Is Only for OS_interaction use only!

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /