Question
Write a Single Linux Python script that retrieves the following Machine name List of all users and the group they are associated with From /proc/cpuinfo
Write a Single Linux Python script that retrieves the following Machine name List of all users and the group they are associated with From /proc/cpuinfo get the following o Processor o Vendor_id o Model o Model name o Cache All services on machine and their current status This data needs to be collected and formatted in a text file for easy readability.
What I have so far
Get_CPU_Info.py import os import re import socket #get machine name print(socket.gethostname()) #get cpu information specList = ["processor", "vendor_id", "model", "model name", "cache size"] file = open("/proc/cpuinfo", "r") lines = file.readlines() for spec in specList: for line in lines: if re.search(spec, line): print(line) break #break loop after finding pattern os.system("service --status-all > test.txt") #append to file by double arrows >> #other os.system("systemctl list-units --type service >> test.txt") os.system("systemctl list-unit-files >> test.txt") #All system services on Machine os.system("systemctl list-unit-files --type service >> test.txt") |
If possible to add loops, and lists
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started