"""
auth : wenshan
time :
version : v1.0.0
"""
import main
import time
if __name__ == "__main__":
while True:
try:
inputName = raw_input("""
1.reboot
:reboot the PC.
2.service_stop -name
:stop service.
service_start -name
:start service.
3.customer_stop -name
:run customer command.
customer_start -name
:run customer command.
4.cpu_limit_start -processName -rate
:limit the process under the rate.
cpu_limit_stop
:stop the service cpulimt.
cpu_nervous -rate
:cpu nervous,havn't recover funtion.
5.mem_leak
:mem nervous,havn't recover funtion.
6.process_leak
:loop create process.havn't recover funtion.
thread_lead
:loop create thread.havn't recover funtion.
7.disk_full_all
:fill all disk.
disk_full_all_recover
:recover
disk_full_customer -filename -mbytes
:create a file.havn't recover funtion.
disk_slow -swapname -gbytes -seconds
:disk slow.havn't recover funtion.
8.network_delay -msdelaytime
:delay the network
network_delay_stop -msDelayTime
:recover
network_wave_delay -startMsDelayTime -endMsDelayTime
:wave delay
network_wave_delay_stop -startMsDelayTime -endMsDelayTime
:recover
network_limit -kbit
:limit network
network_limit_stop -kbit
:recover
network_package_corrupt -rate
:package corrupt
network_package_corrupt_stop -rate
:recover
network_package_lost -rate
:package lost
network_package_lost_stop -rate
:recover
network_package_duplicate -rate
:package duplicate
network_package_duplicate_stop -rate
:recover
9.ulimit -number
:limit the file handler
apache_maxclients
:change the apache max clients
10.exit\n\nplease choice=""")
command = inputName.split(' ')
if command[0] == 'reboot':
main.downtime()
elif command[0] == 'service_stop':
serviceName = command[1].replace('-', '')
main.service_stop(serviceName)
elif command[0] == 'service_start':
serviceName = command[1].replace('-', '')
main.service_start(serviceName)
elif command[0] == 'customer_stop':
serviceName = command[1].replace('-', '')
main.customer_stop(serviceName)
elif command[0] == 'customer_start':
serviceName = command[1].replace('-', '')
main.customer_start(serviceName)
elif command[0] == 'cpu_limit_start':
processName = command[1].replace('-', '')
rate = command[2].replace('-', '')
main.cpu_limit_start(processName, rate)
elif command[0] == 'cpu_limit_stop':
main.cpu_limit_stop()
elif command[0] == 'cpu_nervous':
rate = command[1].replace('-', '')
main.cpu_nervous(rate)
elif command[0] == 'mem_leak':
main.mem_leak()
elif command[0] == 'process_leak':
main.process_leak()
elif command[0] == 'thread_lead':
main.thread_lead()
elif command[0] == 'disk_full_all':
main.disk_full_all()
elif command[0] == 'disk_full_all_recover':
main.disk_full_all_recover()
elif command[0] == 'disk_full_customer':
filename = command[1].replace('-', '')
d = command[2].replace('-', '')
main.disk_full_customer(filename, d)
elif command[0] == 'disk_slow':
s = command[1].replace('-', '')
g = command[2].replace('-', '')
se = command[3].replace('-', '')
main.disk_slow(s, g, se)
elif command[0] == 'network_delay':
m = command[1].replace('-', '')
main.network_delay(m)
elif command[0] == 'network_delay_stop':
m = command[1].replace('-', '')
main.stop_network_delay(m)
elif command[0] == 'network_wave_delay':
s = command[1].replace('-', '')
e = command[2].replace('-', '')
main.network_wave_delay(s, e)
elif command[0] == 'network_wave_delay_stop':
s = command[1].replace('-', '')
e = command[2].replace('-', '')
main.stop_network_delay(s, e)
elif command[0] == 'network_limit':
k = command[1].replace('-', '')
main.network_limit(k)
elif command[0] == 'network_limit_stop':
k = command[1].replace('-', '')
main.stop_network_limit(k)
elif command[0] == 'network_package_corrupt':
m = command[1].replace('-', '')
main.network_package_corrupt(m)
elif command[0] == 'network_package_corrupt_stop':
m = command[1].replace('-', '')
main.stop_network_package_corrupt(m)
elif command[0] == 'network_package_lost':
m = command[1].replace('-', '')
main.network_package_lost(m)
elif command[0] == 'network_package_lost_stop':
m = command[1].replace('-', '')
main.stop_network_package_lost(m)
elif command[0] == 'network_package_duplicate_stop':
m = command[1].replace('-', '')
main.stop_network_package_duplicate(m)
elif command[0] == 'network_package_duplicate':
m = command[1].replace('-', '')
main.network_package_duplicate(m)
elif command[0] == 'ulimit':
m = command[1].replace('-', '')
main.ulimit(m)
elif command[0] == 'apache_maxclients':
main.apache_maxclients()
elif command[0] == 'exit':
break
else:
print 'order error'
time.sleep(2)
except Exception, e:
print e