写了个小工具FaultTestTools,专用于服务端故障注入

"""
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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那美那美

失业了,写文章求吃碗炒面

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值