English 中文(简体)
在当地网络通过沙捞越电脑的硬件和系统信息
原标题:Get Hardware and System information of computers on the local network via Python
  • 时间:2023-10-10 10:14:27
  •  标签:
  • python

How to get hardware information of a computer on a local network. (IP, MAC, computer name, user, RAM, Mainbroad, Operating System, Processor,...) I researched the platformWin32_ComputerSystem but could only check the current computer s information. Can anyone help me about the method and its code?

from tkinter import *
import wmi
import platform, socket
import cpuinfo

S = wmi.WMI()
my_system = S.Win32_ComputerSystem()[0]
Ram = str(round(int(my_system.TotalPhysicalMemory) / (1024.0 **3)))+" GB"
Ip = socket.gethostbyname(socket.gethostname())
CPUinfo = cpuinfo.get_cpu_info()[ brand_raw ]
OpSys = platform.platform()
User = my_system.UserName

master = Tk()
master.title( Get info PC )
Label(master, text="
Manufactured: "+ my_system.Manufacturer).grid(row=0,column=1)
Label(master, text="
Modell: "+ my_system.Model).grid(row=1,column=1)
Label(master, text="
Name: "+ my_system.Name).grid(row=2,column=1)
Label(master, text="
Operator System: "+ OpSys).grid(row=3,column=1)
Label(master, text="
System Type: "+ my_system.SystemType).grid(row=4,column=1)
Label(master, text="
RAM: "+ Ram).grid(row=5,column=1)
Label(master, text="
Processor: "+ CPUinfo).grid(row=6,column=1)
Label(master, text="Ip Address: "+ Ip).grid(row=7,column=1)
Label(master, text="
UserName: "+ User[User.find( \ )+1:]).grid(row=8,column=1)

master.mainloop()
问题回答

没有(某些级别)将另一台机器的硬件信息输入该机器,就无法获取。 这要么要求你明确建立所有机器的日志账户,要么安装,要么能够使用某些遥控软件。 这不是一个简单的文字。

如果你在含水层方面提出这个问题,我建议你研究一个先前存在的配置和管理框架,例如: Puppet, Chef, 盐类、盐类等。 请注意,所有这些(我认为)要求你在将要管理的每个机器上预先安装代理软件。 我不熟悉在Windows方面通常用于这一目的的工具。

The other approach is to simply script something to get (say) an SSH session into the remote machine, run a command on the remote, and capture the output. But there are all sorts of hidden traps in this ... not least that you could open a massive security hole if you do this incorrectly.

我认为,如果你把这个问题当作一个系统管理问题,而不是一个方案规划问题,你可能会得到更好的答案。 对服务器Fault进行跟踪(如有必要询问)。

You can execute the command "systeminfo" in cmd to get the IP, MAC, computer name, user, RAM, Mainbroad, Operating System, Processor.. of that machine. To run this command in python install os by typing this into cmd:

pip install os-sys

之后,你可以按照该法典管理信息指挥系统:

import os

commandtoexecute =  "systeminfo"

returned_value = os.system(cmd) 
print( returned value: , returned_value)

这将在碎块中进行突击性处理,并将它储存在回收价值中。 然后将予以印刷。

你们需要远程使用计算机,或者有人操作这种假装。 如果你想要把数据输入你的电脑,我建议你在你的计算机与他人之间建立起一个袖珍的链接,并转让数据。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签