From 3476c3431bdeb8ef33579fe6099cd10fafeb0a6e Mon Sep 17 00:00:00 2001 From: kshitij Date: Wed, 21 Jan 2026 16:57:24 +0530 Subject: [PATCH 1/2] Python Script Added Task 1 Completed --- day-01/system_health.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 day-01/system_health.py diff --git a/day-01/system_health.py b/day-01/system_health.py new file mode 100644 index 0000000..3be515b --- /dev/null +++ b/day-01/system_health.py @@ -0,0 +1,25 @@ +#pyscipt to Check CPU Usages + +import psutil + +def check_cpu_usages(name,usages,limit): + if usages > limit: + print("CPU alert email Send High Use...") + else: + print("Usages is Ok") + +cpu_limit = int(input("Enter CPU Threshold")) +memory_limit = int(input("Enter Memory Threshold")) +disk_limit = int(input("Enter Disk Threshhold")) + +print("\n Checking Systems Usages...") + +cpu_usage = psutil.cpu_percent(1) +memory_usage = psutil.virtual_memory().percent +disk_usage = psutil.disk_usage('/').percent + +check_cpu_usages("CPU", cpu_usage, cpu_limit) + +check_cpu_usages("Memory", memory_usage, memory_limit) + +check_cpu_usages("Disk", disk_usage, disk_limit) \ No newline at end of file From ebdb6a8f9f2cf1991590ce8de53846a2603858d3 Mon Sep 17 00:00:00 2001 From: kshitij Date: Fri, 23 Jan 2026 15:40:11 +0530 Subject: [PATCH 2/2] Day 2 Task Completed --- day-01/system_health.py | 9 +++--- day-02/api_data_fetcher.py | 56 ++++++++++++++++++++++++++++++++++++++ day-02/output.json | 6 ++++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 day-02/api_data_fetcher.py create mode 100644 day-02/output.json diff --git a/day-01/system_health.py b/day-01/system_health.py index 3be515b..265236b 100644 --- a/day-01/system_health.py +++ b/day-01/system_health.py @@ -8,10 +8,11 @@ def check_cpu_usages(name,usages,limit): else: print("Usages is Ok") -cpu_limit = int(input("Enter CPU Threshold")) -memory_limit = int(input("Enter Memory Threshold")) -disk_limit = int(input("Enter Disk Threshhold")) - +for i in range(5): + cpu_limit = int(input("Enter CPU Threshold")) + memory_limit = int(input("Enter Memory Threshold")) + disk_limit = int(input("Enter Disk Threshhold")) + break print("\n Checking Systems Usages...") cpu_usage = psutil.cpu_percent(1) diff --git a/day-02/api_data_fetcher.py b/day-02/api_data_fetcher.py new file mode 100644 index 0000000..e48db89 --- /dev/null +++ b/day-02/api_data_fetcher.py @@ -0,0 +1,56 @@ +import requests +import json + +BASE_URL = "https://pokeapi.co/api/v2/pokemon/" + +def get_Pokemon(pokemon_name): + url = BASE_URL + pokemon_name.lower() + headers = { + "Accept": "application/json" + } + + try: + response = requests.get(url, headers=headers, timeout=10) + response.raise_for_status() + data = response.json() + + print("API is working... \n") + + selected_data = { + "name": data["name"], + "id": data["id"], + "height": data["height"], + "weight": data["weight"], + } + print(json.dumps(selected_data, indent=4)) + + with open("output.json", "w", encoding="utf-8") as f: + json.dump(selected_data, f, indent=4) + + print("Saving data to output.json ") + + return selected_data + + except requests.exceptions.RequestException as e: + print("API request failed ❌") + print("Error:", e) + + + except requests.exceptions.HTTPError: + print(f"❌ Pokémon '{pokemon_name}' not found!") + + except ValueError: + print("Invalid JSON response ❌") + + +# pokemon_data = get_Pokemon() +def main(): + pokemon_name = input("Enter Pokemon Name...Eg.Pikachu,ditto").strip() + # print("Eg.Pikachu,ditto") + + if not pokemon_name: + print("Pokemon cannot be empty") + + get_Pokemon(pokemon_name) + +main() \ No newline at end of file diff --git a/day-02/output.json b/day-02/output.json new file mode 100644 index 0000000..428945d --- /dev/null +++ b/day-02/output.json @@ -0,0 +1,6 @@ +{ + "name": "ditto", + "id": 132, + "height": 3, + "weight": 40 +} \ No newline at end of file