-
Notifications
You must be signed in to change notification settings - Fork 0
/
thegrapher.py
executable file
·128 lines (113 loc) · 3.81 KB
/
thegrapher.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/local/bin/python3.5
'''
TheGrapher takes custom generated CSV files with Exalogic's compute nodes and
IB Switches's information, loads them into python structures and graphs the variables
recolected.
Copyright (C) 2016 Daniela Torres Faria
GitHub: dtorresf
Mail: [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later versi
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more detai
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import sys, getopt
from Server import Server
from Switch import Switch
from Report import Report
import Methods
import Config
from ZFSServer import ZFSServer
from datetime import datetime
def main(argv):
'''Handle some arguments
Optional:
-h : Display help usage message.
-c : Especify configuration file.
If not configuration file is especified generate one from the command line
'''
global configfile
try:
opts, args = getopt.getopt(argv,"hc:",["cfile="])
except getopt.GetoptError:
print("thegrapher.py -c [configfile]")
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
print("thegrapher.py -c [configfile]")
sys.exit()
elif opt in ("-c", "--cfile"):
configfile = arg
def Servers(cf):
print("* Loading data for servers ...")
servers = Methods.importallservers(cf)
print("* Graph Servers ... (This could take a while)")
Methods.graphallservers(cf,servers)
return servers
def Switches(cf):
print("* Loading data for switches ...")
switches = Methods.importallswitches(cf.variables['eoib_ports'],cf)
print("* Graph Switches ...")
Methods.graphallswitches(cf.variables['eoib_ports'],cf,switches)
return switches
def ZFS(cf):
print("* Loading data for ZFS ...")
zfs = ZFSServer()
zfs.importdatatozfs(cf)
zfs.graphzfs(cf)
print("* Graph ZFS ...")
return zfs
def reportPPTX(cf,servers,switches,zfs):
print("* Generate Final Report ...")
date = datetime.now().strftime("%d%m%Y-%H%M%S")
name = cf.variables['pptx_report'] + '/' + 'Exalogic_Report_'+ date + '.pptx'
r = Report()
r.loadreport(date,name,"Informe de desempeño de nodos Exalogic", servers, switches, zfs, cf)
r.generatepptxreport()
print("* ENJOY :) * ")
def reportPPTX2(cf,servers,switches):
print("* Generate Final Report ...")
date = datetime.now().strftime("%d%m%Y-%H%M%S")
name = cf.variables['pptx_report'] + '/' + 'Exalogic_Report_'+ date + '.pptx'
r = Report()
r.loadreport2(date,name,"Informe de desempeño de nodos Exalogic", servers, switches, cf)
r.generatepptxreport2()
print("* ENJOY :) * ")
def thegrapher(cf):
#1) Load config file
if cf.file:
print("* Loading Configuration File ...")
cf.loadconfigfile(cf.file)
print("* Validate Configuration File Format ...")
#cf.validateconf()
#2) Bring the data files to the corresponding directories (Validate Existence of directories)
# print("* Copy data files from exalogic first compute node ...")
# cf.copydatafiles()
#3) Graph all compute nodes
servers=Servers(cf)
#4) Graph EoIB swithces statistics
switches=Switches(cf)
#5) Graph ZFS data
#zfs=ZFS(cf)
#6) Generate PPT with graphs
reportPPTX2(cf, servers, switches)
if __name__ == "__main__":
'''Main program'''
configfile = ''
main(sys.argv[1:])
cf = Config.Config()
if configfile:
cf.file = configfile
thegrapher(cf)
else:
#Call function to generate config file from cmd
#Execute thegrapher function
print("Please ... configfile ... Please")
cf.generateconfigfile()
thegrapher(cf)