#!/usr/bin/env python

import sys
import os
import math
import re
import string

import pprint

OS=sys.platform


class DBHwCheck:


	def __init__(self):
		self.HWInfo = dict()
		self.HWInfo['CPU Version']=''
		self.HWInfo['CPU Core Enabled']=''
		
		
		



	def performCheck(self,prefix='',Multiparam='',multilineParam=False,Multivalue=[],TotalMemSize=0):
		if OS == 'win32':


			####parse Windows stuff#####
			lines=os.popen('systeminfo').read().split('\n')
			for line in lines:
				param=line.split(':')
				if len(param)>1:
					self.HWInfo[param[0].strip()]=param[1].strip()
				
		elif OS=='linux2':
			try:
				user=os.popen('id -u').read()
				user=user.replace('\n','')
				if user.strip() != ('0'):
						print 'This check has to be executed as root! You are ' + os.popen('whoami').read()
						return
				self.HWInfo['CPU Numa']=os.popen('numactl --show|grep nodebind|sed \'s/nodebind://g\'|wc -w').read().strip()
				if os.path.exists('/etc/SuSE-release'):		
					lines=os.popen(' cat /etc/SuSE-release').read().split('\n')
					for line in lines:
						if line.startswith('SUSE Linux Enterprise Server'):
								self.HWInfo['OS']='SLES'
						if line.strip().startswith('VERSION'):
									param=line.split('=')
									self.HWInfo['OS Version']=param[1].strip()
						if line.startswith('PATCHLEVEL'):
									param=line.split('=')
									self.HWInfo['OS SP']=param[1].strip()
				if os.path.exists('/etc/redhat-release'):
					line=os.popen(' cat /etc/redhat-release').read()
					if line.startswith('Red Hat Enterprise Linux Server'):
						self.HWInfo['OS']='RHEL'
						line = line.replace('Red Hat Enterprise Linux Server release ','')
						params = line.split(' ')
						self.HWInfo['OS Version'] = params[0].strip()
						self.HWInfo['OS SP'] = 'n/a'
			
			except KeyError, key:
				print 'could not get Hardware Information:',key						
			lines=os.popen('/usr/sbin/dmidecode -s processor-version | grep -i -v "not specified"').read().split('\n')
			try:
				self.HWInfo['CPU Sockets']=len(lines)-1
				
				if self.HWInfo['CPU Sockets'] > 16:
					self.HWInfo['CPU Sockets'] = int(self.HWInfo['CPU Numa'])	
			except KeyError, key:
	    			print 'could not get Hardware Information:',key		
			self.HWInfo['CPU Flags']=''
			###parse linux stuff####
			lines=os.popen('/usr/sbin/dmidecode -t1,4,17').read().split('\n')
	
			for line in lines:
				
				if line.startswith('Memory Device'):
					prefix = 'Memory '
				if line.startswith('System Information'):
					prefix = 'System '
				if line.startswith('Processor Information'):
					prefix = 'CPU '		
				param=line.split(':')
				if param[0].strip() == 'Flags':

					multilineParam= True
					MultiParam= 'Flags'
					continue
	
				if len(param)==1 and multilineParam== True:
					Multivalue.append(param[0].strip())
				if len(param)>1 and multilineParam==False:
					self.HWInfo[prefix + param[0].strip()]=param[1].strip()

				if len(param)>1 and multilineParam==True:
					self.HWInfo[prefix + MultiParam]=Multivalue
					self.HWInfo[prefix + param[0].strip()]=param[1].strip()	
					multilineParam= False

				if prefix == 'Memory ' and param[0].strip() == 'Size':
					if param[1].strip() != 'No Module Installed':
						Size = param[1].replace('MB','')
						Size = Size.replace('kB','')
						Size = Size.replace('KB','')
						if Size.endswith('GB'):
							
							Size = Size.replace('GB','')
							Size = int(Size)*1024
						TotalMemSize= TotalMemSize + int(Size)

			try: 
#				print 'Here: '+ self.HWInfo['CPU Core Enabled']
				self.HWInfo['Memory Total']=TotalMemSize
				
				if self.HWInfo['CPU Core Enabled']=='' or self.HWInfo['CPU Core Enabled']==0:
#					if self.HWInfo['OS']=='SLES':
					infolines=os.popen('hwinfo --cpu --short').read().split('\n')
										
#					print infolines
#					print len(infolines)
#					for line in infolines:
#						print 'Line: ' +line

					self.HWInfo['CPU Core Enabled']=(len(infolines)-1) / self.HWInfo['CPU Sockets']
#					print str((len(infolines)-1))+'/'+str(self.HWInfo['CPU Sockets'])
#					print self.HWInfo['CPU Core Enabled']
#					print 'Cores/Socket: ' + str(self.HWInfo['CPU Core Enabled'])
#					print 'Socket: ' + str(self.HWInfo['CPU Sockets'])
					if 'HTT (Hyper-threading technology)' in self.HWInfo['CPU Flags']:
#						self.HWInfo['CPU HTT']='activated'
						self.HWInfo['CPU Core Enabled']=(len(infolines)-1)/(2 * self.HWInfo['CPU Sockets'])
#						print 'Cores/Socket without HTT: ' + str(self.HWInfo['CPU Core Enabled'])
				if 'HTT (Hyper-threading technology)' in self.HWInfo['CPU Flags']:
						self.HWInfo['CPU HTT']='activated'
				else:
						self.HWInfo['CPU HTT']='not activated'		
				self.HWInfo['Core count']=int(self.HWInfo['CPU Core Enabled'])*self.HWInfo['CPU Sockets']
#				print 'Version: ' + self.HWInfo['CPU Version']
				self.HWInfo['System Product Name']=re.sub('.*\-\[','',self.HWInfo['System Product Name'])
				if self.HWInfo['System Product Name'].startswith('714'):
					self.HWInfo['System Product Name'] = re.sub('(?P<IBM>714[3,5,7,8]).*','\g<IBM>',self.HWInfo['System Product Name'])
				if self.HWInfo['System Product Name'].startswith('7383'):
					self.HWInfo['System Product Name'] = re.sub('7383.*','7383',self.HWInfo['System Product Name'])			 
				if self.HWInfo['System Product Name'].startswith('7914'):
					self.HWInfo['System Product Name'] = re.sub('7914.*','7914',self.HWInfo['System Product Name'])
				if self.HWInfo['System Product Name'].startswith('7915'):
					self.HWInfo['System Product Name'] = re.sub('7915.*','7915',self.HWInfo['System Product Name'])	 
				if self.HWInfo['System Product Name'].startswith('5460'):
					self.HWInfo['System Product Name'] = re.sub('5460.*','5460',self.HWInfo['System Product Name'])
				if self.HWInfo['System Product Name'].startswith('3837'):
					self.HWInfo['System Product Name'] = re.sub('3837.*','3837',self.HWInfo['System Product Name'])			 			 
				if self.HWInfo['CPU Version']=='Not Specified' or self.HWInfo['CPU Version']=='':
					versionlines=os.popen('/usr/sbin/dmidecode -s processor-version').read().split('\n')
					self.HWInfo['CPU Version']=versionlines[0]
#				if self.HWInfo['CPU Version'].startwith('000000'):
					 
#				print self.HWInfo['CPU Version']
				tabs=self.HWInfo['CPU Version'].split(' ')
				oldtab=''
				versiontab=''
				filled = 0
#				print tabs
				for tab in tabs:
#						print tab
						if oldtab.startswith('CPU'):
							self.HWInfo['CPU Model']=tab.strip()
							filled=1
						if tab.startswith('@'):
							oldtab=oldtab+versiontab
							self.HWInfo['CPU Model']=oldtab.strip()
							filled=1
						if tab != '' and tab != '0' and tab != 'v2':	
							oldtab=tab
						if tab.strip() == 'v2':
							versiontab=' v2'	
				if filled == 0 and self.HWInfo['OS']=='SLES' :
					
					HwInfolines=os.popen('hwinfo --cpu --short').read().split('\n')
					if len(HwInfolines)>1:
						tabs = HwInfolines[1].split(' ')				
						for tab in tabs:
#						print tab
							if oldtab.startswith('CPU'):
									self.HWInfo['CPU Model']=tab.strip()
									filled=1
							if tab.startswith('@'):
									self.HWInfo['CPU Model']=oldtab.strip()
									filled=1
							if tab != '':	
									oldtab=tab
				if filled == 0:
					
					HwInfolines=os.popen('cat /proc/cpuinfo').read().split('\n')
					for line in HwInfolines:
#						print line
						if line.startswith('model name'):
							tabs = line.split(' ')				
							for tab in tabs:
#								print tab
								if oldtab.startswith('CPU'):
									self.HWInfo['CPU Model']=tab.strip()
									filled=1
								if tab.startswith('@'):
									self.HWInfo['CPU Model']=oldtab.strip()
									filled=1
								if tab != '':	
									oldtab=tab	
									
			except KeyError, key:
	    			print 'could not get Hardware Information:',key
				
		else:
			print 'OS not supported'
	
	
	def performFilerCheck(self, location):
	    	
		lines=os.popen('df -Tm ' + location).read().split(' ')
		
		
		itemlist = [location+' Type',location+' 1M-blocks',location+' used',location+' Available', location+' in use', location+' mount']
		i=0
		begin=0
		for line in lines:
		

			
#			if begin==1 and	line.find('%')!=-1:
#				break
			if begin==1 and line.strip() != '':	
				self.HWInfo[itemlist[i]]=line.strip()
				i=i+1
			if line.startswith('on'):
				begin=1	
		
	def performCloudCheck(self):
		try:
			fog= os.popen('curl -s http://169.254.169.254/latest/meta-data/metrics/vhostmd').read().split('\n')
		except KeyError, key:
	    			print 'could not get Hardware Information:',key
	    	cloudConfig = dict()		
		if any(fog)==False:
			print('Virtual Host configuration could not be determined. Trying fallback....\n')
		
			infolines=os.popen('hwinfo --cpu --short').read().split('\n')				
				
			cloudConfig['CPU Cores Enabled']=(len(infolines)-2)
			HwInfolines=os.popen('cat /proc/cpuinfo').read().split('\n')
			for line in HwInfolines:
					
					if line.startswith('model name'):
#							print line
							oldtab=''
							filled = 0
							tabs = line.split(' ')				
							for tab in tabs:
#								print tab
								if oldtab.startswith('CPU'):
									cloudConfig['CPU Type']=tab.strip()
									filled=1
								if tab.startswith('@'):
									cloudConfig['CPU Type']=oldtab.strip()
									filled=1
								if tab != '' and tab!= '0':	
									oldtab=tab
			HwInfolines=os.popen('cat /proc/meminfo').read().split('\n')
			for line in HwInfolines:					
				if line.startswith('MemTotal'):
						Meminfo = line.split(':')
						Meminfo[1] = Meminfo[1].replace('kB','')
						cloudConfig['Current Memory available'] = Meminfo[1].strip()
			rc=1	
			try:
				print string.ljust('Cloud Provider',30), string.ljust('AWS-like Xen container',25),string.ljust('OK',10)			
				if cloudConfig['CPU Type'] in ['X5550','E5-2665','E5-2670']:
			
					print string.ljust('Processor Type',30), string.ljust(cloudConfig['CPU Type'],25),string.ljust('OK',10)
			
				if cloudConfig['CPU Cores Enabled'] in [24]:
			
					print string.ljust('Number of Cores',30), string.ljust(str(cloudConfig['CPU Cores Enabled']),25),string.ljust('OK',10)
			
				if cloudConfig['Current Memory available'] in ['35000','60500','142614612']:
					print string.ljust('Memory available',30), string.ljust(cloudConfig['Current Memory available']+' KB',25),string.ljust('OK',10)
			except KeyError, key:
	    			print 'could not get Hardware Information:',key	
			return rc				
													
#			return 0
		try:
		 for thing in fog:
		 	 print thing
			 if thing.strip().startswith('<name>'):
			  	thing = thing.replace('<name>','')
			  	thing = thing.replace('</name>','')
			  	key = thing.strip()
			 if thing.strip().startswith('<value>'):
			 		thing = thing.replace('<value>','')
				 	thing = thing.replace('</value>','')
				 	value= thing.strip()
				 	cloudConfig[key]= value
				 	key=''
		 tabs=cloudConfig['Processor Type'].split(' ')
		 oldtab=''
		 for tab in tabs:
				if oldtab.startswith('CPU'):
					cloudConfig['CPU Type']=tab.strip()
				if tab.startswith('@'):
					cloudConfig['CPU Type']=oldtab.strip()
				if tab != '' and tab != '0':	
					oldtab=tab		
		 cloudConfig['AWS Instance'] = os.popen('curl -s http://169.254.169.254/latest/meta-data/instance-type').read() 			
#		print cloudConfig
		
		
		 if cloudConfig['Cloud Provider'] in ['Amazon Web Services']:
			 print string.ljust('Cloud Provider',30), string.ljust(cloudConfig['Cloud Provider'],25),string.ljust('OK',10)
		 if cloudConfig['AWS Instance'] in ['cc2.8xlarge', 'm2.2xlarge']:
			 print string.ljust('AWS Instance Type',30), string.ljust(cloudConfig['AWS Instance'],25),string.ljust('OK',10)
		 if cloudConfig['CPU Type'] in ['X5550','E5-2665']:
			 print string.ljust('Processor Type',30), string.ljust(cloudConfig['CPU Type'],25),string.ljust('OK',10)
		 if cloudConfig['Number of Cores per CPU'] in ['4','8']:
			 print string.ljust('Number of Cores',30), string.ljust(cloudConfig['Number of Cores per CPU'],25),string.ljust('OK',10)	
		 if cloudConfig['Current Memory available'] in ['35000','60500']:
			 print string.ljust('Memory available',30), string.ljust(cloudConfig['Current Memory available'],25),string.ljust('OK',10)		
		
		except KeyError, key:
	    			print 'could not get Hardware Information:',key
	  	rc=1  			
		return rc
		
	def compareResults(self):
	    try:
	    	
		rc=1
		if self.HWInfo['System Manufacturer'] in ['Hewlett-Packard','HP','IBM', 'VMware, Inc.','Dell Inc.','Cisco Systems Inc','HUAWEI TECHNOLOGIES CO.,LTD.','FUJITSU','LENOVO','HITACHI','NEC']:
			print string.ljust('System Manufacturer',30), string.ljust(self.HWInfo['System Manufacturer'],25),string.ljust('OK',10)
		else:		
			print string.ljust('System Manufacturer',30),string.ljust(self.HWInfo['System Manufacturer'],25), string.ljust('not supported',10)							
			rc=0
		if self.HWInfo['System Product Name'] in ['Express5800/A1080a [NE3100-xxxx]','Express5800/A1040a [NE3100-xxxx]','BladeSymphony E57A2', '7143', '7147', '7145', '7148','7383','7914','7915','5460','3837','ProLiant ML350p Gen8','Compute Blade 2000 X57A2', 'Compute Blade E57A2','Lenovo WQ R680 G7','PowerEdge R620','PowerEdge T620','PRIMERGY RX600 S5', 'PRIMERGY RX900 S1', '738325Z]-', 'PRIMERGY RX900 S2','PRIMERGY RX600 S6','PRIMERGY RX300 S6','PRIMERGY RX350 S7', 'PRIMERGY TX300 S6','PRIMERGY TX300 S7','ProLiant DL980 G7','ProLiant DL580 G7','ProLiant BL680c G7','UCSC-BASE-M2-C460','C260-BASE-2646','B440-BASE-M2','R460-4640810', 'PowerEdge R910', '-[7145]-','System x3690 X5','System x3650 M4','System x3550 M4','System x3500 M4','System x3850 X5','System x3850 X5 / x3950 X5','Tecal RH5885 V2','VMware Virtual Platform','System x3950 X5' ]:
			print string.ljust('System Product Name',30),string.ljust(self.HWInfo['System Product Name'],25),string.ljust('OK',10)
		else:		
			print string.ljust('System Product Name',30),string.ljust(self.HWInfo['System Product Name'],25),string.ljust('not supported',10)							
#			rc=0	
		if self.HWInfo['CPU Model'].strip() in ['X7560','X5670','X5675','2870','4870','8870','E7-8880 v2','E7-8890 v2','E7-4880 v2','E7-4890 v2','E7-2880 v2','E7-2890 v2','E5-2670']:
			print string.ljust('CPU Model',30),string.ljust(self.HWInfo['CPU Model'],25),string.ljust('OK',10)
		else:		
			print string.ljust('CPU Model',30),string.ljust(self.HWInfo['CPU Model'],25),string.ljust('not supported',10)							
#			rc=0
		if self.HWInfo['OS'] in ['SLES','RHEL']:
			if self.HWInfo['OS Version'] in ['11','6.5']:
				if self.HWInfo['OS SP'] in ['1','2','3','n/a']:
					print string.ljust('OS',30),string.ljust(self.HWInfo['OS']+' '+self.HWInfo['OS Version']+' SP '+self.HWInfo['OS SP'],25),string.ljust('OK',10)
		else:		
			print string.ljust('OS',30),string.ljust(self.HWInfo['OS']+' '+self.HWInfo['OS Version']+' SP '+self.HWInfo['OS SP'],25),string.ljust('not supported',10)							
#			rc=0
#			rc=0	
		f = self.HWInfo['Factor']
		if (self.HWInfo['Memory Total']) in [24576,49152,65536,131072,196608,262144,327680,393216,524288,1048544,1048576,2097152,4194304]:
			print string.ljust('Memory Total',30),string.ljust(str(f*(self.HWInfo['Memory Total']))+ ' MB',25),string.ljust('OK',10)
			if (self.HWInfo['Memory Total'] *f < 131072):
				
				if (self.HWInfo['Memory Total'] *f < 65536):
					print string.ljust('\n### WARNING!! Your amount of memory is far too low for normal HANA usage and may cause severe issues! ###\n',30)
				else:
					print string.ljust('\n#### WARNING!! Your amount of memory is very low for normal HANA usage! ###\n',30)
		else:		
			print string.ljust('Memory Total',30),string.ljust(str(self.HWInfo['Memory Total'])+ ' MB',25),string.ljust('not enough memory or wrong memory configuration!',10)							
#			rc=0
			print string.ljust('Memory Total',30),string.ljust(str(f*(self.HWInfo['Memory Total']))+ ' MB',25),string.ljust('OK',10)				
		if (f * self.HWInfo['Core count'])>=(f*(self.HWInfo['Memory Total']/16384)) or self.HWInfo['Memory Total'] >= 1048576:
			print string.ljust('Core count',30),string.ljust(str(f*(self.HWInfo['Core count'])),25),string.ljust('OK',10)
		else:	
			
			print string.ljust('Core count',30),string.ljust(str(f*(self.HWInfo['Core count'])),25),string.ljust('not enough CPU cores!',10)							
#			rc=0
		if self.HWInfo['CPU HTT']=='activated':
			print string.ljust('Hyper-threading',30),string.ljust('Activated',25),string.ljust('OK',10)
		else:
			print string.ljust('Hyper-threading',30),string.ljust('Not active',25),string.ljust('\n\n### WARNING: Hyper-threading not activated or determinable!! ###\n',10)
#			rc=0
		if int(self.HWInfo['CPU Numa'])>0:
			print string.ljust('Numa functionality',30),string.ljust('Activated',25),string.ljust('OK',10)
		else:
			print string.ljust('Numa functionality',30),string.ljust('Not active',25),string.ljust('Warning: Please activate Numa in your BIOS settings!!',10)
					
		if self.HWInfo['data device'] != 'M%&SS)=(':	
			if self.HWInfo[self.HWInfo['data device']+ ' mount']==self.HWInfo['data device']:
				print string.ljust('data device',30),string.ljust('Mounted',25),string.ljust('OK',10)
#			else:
#				print string.ljust('data device',30),string.ljust('NOT MOUNTED',25),string.ljust('data volume not mounted!',10)
#				self.HWInfo[self.HWInfo['data device']+ ' 1M-blocks']='0'
#				rc=0			
			if int(self.HWInfo[self.HWInfo['data device']+ ' Available'])>=((self.HWInfo['Memory Total']*3*f)-(int(self.HWInfo['Memory Total']*3*f)/5)):
				print string.ljust('data storage size',30),string.ljust(str(self.HWInfo[self.HWInfo['data device']+ ' Available'])+ ' MB',25),string.ljust('OK',10)
			else:		
				print string.ljust('data storage size',30),string.ljust(str(self.HWInfo[self.HWInfo['data device']+ ' Available'])+ ' MB',25),string.ljust('data volume not big enough! Minimum size is 3*memory!',10)							
#				rc=0
		if self.HWInfo['log device'] != 'M%&SS)=(':		
			if self.HWInfo[self.HWInfo['log device']+' mount']==self.HWInfo['log device']:
				print string.ljust('log device',30),string.ljust('Mounted',25),string.ljust('OK',10)
#			else:
#				print string.ljust('log device',30),string.ljust('NOT MOUNTED',25),string.ljust('log volume not mounted!',10)
#				self.HWInfo[self.HWInfo['log device']+' 1M-blocks']='0'
#				rc=0
			if int(self.HWInfo[self.HWInfo['log device']+' Available'])>=((self.HWInfo['Memory Total']*1*f)-(int(self.HWInfo['Memory Total']*4*f)/5)):
				print string.ljust('log storage size',30),string.ljust(str(self.HWInfo[self.HWInfo['log device']+' Available'])+ ' MB',25),string.ljust('OK',10)
			else:		
				print string.ljust('log storage size',30),string.ljust(str(self.HWInfo[self.HWInfo['log device']+' Available'])+ ' MB',25),string.ljust('log volume not big enough! Minimum size mountis 1*memory!',10)							
#				rc=0	
		
		
		
		return rc
	
	    except KeyError, key:
	    	print 'could not get Hardware Information:',key
		return 0
	
	
	
	def main(self, args):
#   		print args
		if '--help' in args:
			print 'Options:\n -v\t\tshow complete HW information\n -logpath=<base_path_log_volumes>\t\tlog location\n -datapath=<base_path_data_volumes>\t\tdata location'
			sys.exit(0)
   		print '\nperforming Hardware check......\n'	
   		
   		
   		if 'IDSPISPOPD' in os.environ.keys():
			
			print '\nNo clipping mode on....\n'
   			return 0
   			
   		cloudcheck=os.popen('dmesg | grep -i \'Xen virtual console\'').read().split('\n')

#   		print len(cloudcheck)
   		if len(cloudcheck)>1:
   			for line in cloudcheck:
#   				if string.find(line, 'Xen virtual console') and string.find(line, 'Xen version'):
#   					print 'The LINE:',line
#   				if string.find(line, ' Network Driver') != -1:
   					print 'Cloud configuration detected!\n'
   					rc=self.performCloudCheck()
   					if rc:
						print '\nCloud check successful!!\n'
						return 0
					if rc==0:
						print '\nCloud check failed!!\n'
						return -1
   		
   			
   		self.performCheck()

   		if '-datapath' in args.keys() and args['-datapath']:
   			self.HWInfo['data device']=args['-datapath']
   			self.performFilerCheck(self.HWInfo['data device'])
   		else:
   			self.HWInfo['data device']='M%&SS)=('
#   			datalines=os.popen('df -P| sort -k 4 -n -r').read().split('\n')
#   			datadev=datalines[0].split('%')
#   			self.HWInfo['data device']=datadev[1]
#   			print 'assuming largest storage device ' +self.HWInfo['data device']+' as data device....\n'
   		if '-logpath' in args.keys() and args['-logpath']:
   			self.HWInfo['log device']=args['-logpath']
   			self.performFilerCheck(self.HWInfo['log device'])
   		else:
			self.HWInfo['log device']='M%&SS)=('   		
#   			loglines=os.popen('df -P| sort -k 4 -n -r').read().split('\n') 
#   			logdev=loglines[1].split('%')
#   			self.HWInfo['log device']=logdev[1]
#   			print 'assuming 2nd largest storage device ' +self.HWInfo['log device']+' as log device....\n'		
#   		self.performFilerCheck(self.HWInfo['data device'])
#   		self.performFilerCheck(self.HWInfo['log device'])
   		
   		if '-v' in args.keys():
   			print '\n#############Check values########################'	
  			for i in self.HWInfo.iteritems():
				print i
			print '#############End values########################\n\n'
		if '-machine_utilization' in args.keys() and args['-machine_utilization']:
			if float(args['-machine_utilization'])/100>=1.0:
				args['-machine_utilization'] = 100
			if float(args['-machine_utilization']) <=0.0:
				args['-machine_utilization'] = 100	
			self.HWInfo['Factor']= float(args['-machine_utilization'])/100
		else:
			self.HWInfo['Factor']=1		
		rc = self.compareResults()
		
		
		
		if rc:
			print '\nHardware check successful!!\n'
			return 0
		if rc==0:
			print '\nHardware check failed!!\n'
			return -1
#    		return rc
    		
    		
if __name__ == '__main__':
    DBHwCheck().__init__()
    config = {}
    for params in sys.argv:

    	 params= params.split("=")
    	 if len(params)>1:
    	 	config[params[0]]=params[1]
    	 else:
    	    config[params[0]]=params[0]	
    	    	
    exit(DBHwCheck().main(config))
    
