From 196ce22eda6bd0c8c14094e033679d1127e15e86 Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Tue, 8 Sep 2026 16:14:48 -0500 Subject: [PATCH] Create generate_script.py --- MP1/generate_script.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 MP1/generate_script.py diff --git a/MP1/generate_script.py b/MP1/generate_script.py new file mode 100644 index 0000000..2272e9e --- /dev/null +++ b/MP1/generate_script.py @@ -0,0 +1,26 @@ +import random + +machine_num = input("Enter the machine number: ") +machine_log_file = f"machine.{machine_num}.log" +num_lines = int(input("Enter the number of log lines to generate: ")) + +log_level = ["TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "AUDIT"] + +log_messages = [ + "User logged in successfully.", + "Database connection established.", + "File not found: config.yaml", + "Memory usage is high.", + "Disk space is running low.", + "Unauthorized access attempt detected.", + "Configuration file updated.", + "Service restarted successfully.", + "Network latency is above threshold.", + "Scheduled backup completed.", + "System update installed.", +] + +for i in range(num_lines): + log_entry = f"[{machine_num}-{random.randint(1000, 9999)}] [{log_level[random.randint(0, len(log_level) - 1)]}] {log_messages[random.randint(0, len(log_messages) - 1)]}\n" + with open(machine_log_file, "a") as file: + file.write(log_entry) \ No newline at end of file