Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

Students also viewed these Databases questions

Question

=+What does this say for the future of the business case for CSR?

Answered: 1 week ago