-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInventar_2_CSV.py
More file actions
52 lines (45 loc) · 1.42 KB
/
Inventar_2_CSV.py
File metadata and controls
52 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/local/bin/python3
##############################################
#
# Name: Inventar_2_CSV.py
#
# Author: Peter Christen
#
# Version: 1.0
#
# Date: 10.06.2017
#
# Purpose: Server Inventar Script
# Zusätzlich mit einer CSV-Funktion
#
##############################################
import platform,multiprocessing,os,time,argparse
####Parameter auswerten
parser = argparse.ArgumentParser(description='Liest die Inventardaten des aktuellen Servers aus')
parser.add_argument('-c', action='store_true', help="Daten in CSV-Format ausgeben")
args = parser.parse_args()
###Variabeln
timestamp=time.time()
inventar={}
###Funktionen
def getdata():
inventar["name"]=platform.node()
inventar["nrcpu"]=multiprocessing.cpu_count()
inventar["system"]=platform.system()
inventar["release"]=platform.release()
inventar["machine"]=platform.machine()
inventar["timestamp"]=int(timestamp)
def showdata():
print ("Server Angaben\n##############")
print ("Name:",inventar["name"])
print ("Nr.CPU:",inventar["nrcpu"])
print ("System:",inventar["system"])
print ("Release:",inventar["release"])
print ("Machine:",inventar["machine"])
print ("Timestamp:",inventar["timestamp"])
def showcsv():
print (inventar["name"]+","+str(inventar["nrcpu"])+","+inventar["system"]+","+inventar["release"]+","+inventar["machine"]+","+str(inventar["timestamp"]))
###Daten ausgeben
getdata()
if args.c: showcsv()
else: showdata()