0

How can I create a python script to get a server information base on these fields?

hostname, osrelease, if it's a virtual or physical server.

Output

hostname1, redhat 5.8, VMware

I have something like this:

import platform

print 'uname:', platform.uname()

print 'system   :', platform.system()
print 'node     :', platform.node()
print 'release  :', platform.release()
pirulo
  • 335
  • 1
  • 5
  • 13
  • Hi, can you share some code to show what you've tried so far? Thanks! – Alex Lynham Jun 19 '15 at 16:45
  • I have somthing like this as a code.: I have something like this as a code.: import platform print 'uname:', platform.uname() print 'system :', platform.system() print 'node :', platform.node() print 'release :', platform.release() – pirulo Jun 19 '15 at 16:49
  • Please add your code to the question. – Alex Lynham Jun 19 '15 at 16:50
  • Is this script running on the server? What do you mean by hostname, the DNS entry corresponding to the IP-adres? – chtenb Jun 22 '15 at 11:48
  • Yes the script is running on the server. The script will collect the information only. – pirulo Jun 22 '15 at 15:53

1 Answers1

0

The first two columns of your required output are quite simple to obtain:

import platform
print (platform.node(), ' '.join(platform.dist()[:2]))

The information of the last column, i.e. if Python is running under a virtual or physical machine, seems tricky. Consult the following pages for some hints:

Have a look also at the following modules:

Community
  • 1
  • 1
davidedb
  • 867
  • 5
  • 12
  • Thank you, for you help.. I really wanted to see see if the servers is "virtual or physical" using the the Python script not Python under either servers env. I'm sorry for the misunderstanding. – pirulo Jun 22 '15 at 15:51