当前位置: 首页 > news >正文

购物网站线下推广办法企业网站如何优化

购物网站线下推广办法,企业网站如何优化,两学一做网站无法做题,广州自助建站http://blog.csdn.net/powerccna/article/details/8044222 在性能测试中#xff0c;监控被测试服务器的性能指标是个重要的工作#xff0c;包括CPU/Memory/IO/Network#xff0c;但大多数人估计都是直接在被测试服务器的运行监控程序。我们开始也是这样做的。但这样做带来一…http://blog.csdn.net/powerccna/article/details/8044222 在性能测试中监控被测试服务器的性能指标是个重要的工作包括CPU/Memory/IO/Network但大多数人估计都是直接在被测试服务器的运行监控程序。我们开始也是这样做的。但这样做带来一个问题是测试人员需要在每台被测试服务器上部署监控程序增加了部署的工作量而且经常因为Python版本的问题有些模块不兼容或者第三方模块需要再次安装。 改进性能测试监控工具 1. 能远程监控被测试服务器这样测试人员就不需要在每个被测试机器安装监控工具了。 2. 被测试服务器上不需要安装agent监控结果能取到本地。 3. 本地服务器上的python模块和兼容性问题可以通过Python virtualenv解决每个测试人员维护自己的一套Python环境。 Google了下找到了pymeterthttp://pymeter.sourceforge.net/ 看了下源代码很多工作还没完成但这个思路和我的是一样的。而且我在其他项目中已经实现了远程发送命令的模块。 所以不如直接在自己的项目上扩展。 远程发送命令的模块开始是基于Pexpect(http://www.noah.org/wiki/Pexpect)实现的, Pexpect很强大它是一个用来启动子程序并使用正则表达式对程序输出做出特定响应以此实现与其自动交互的 Python 模块。用他来可以很容易实现telnet,ftp,ssh的操作。 但Pexpect无windows下的版本这是我抛弃它的原因无法达到测试工具兼容所有系统的要求。 所以就用telent模块替换了Pexpect,实现了远程发送命令和获取结果。 #file name: telnetoperate.py #!/usr/bin/env python #codingutf-8 import time,sys,logging,traceback,telnetlib,socket class TelnetAction: def __init__(self,host,prompt,account,accountPasswd,RootPasswd): self.loglogging.getLogger() self.hosthost self.accountaccount self.accountPasswdaccountPasswd self.RootPasswdRootPasswd self.possible_prompt [#,$] self.promptprompt self.default_time_out20 self.child None self.login() def expand_expect(self,expect_list): try: resultself.child.expect(expect_list,self.default_time_out) except EOFError: self.log.error(No text was read, please check reason) if result[0]-1: self.log.error(Expect resultstr(expect_list) dont exist) else: pass return result def login(self): Connect to a remote host and login.try: self.child telnetlib.Telnet(self.host) self.expand_expect([login:]) self.child.write(self.account ) self.expand_expect([assword:]) self.child.write(self.accountPasswd ) self.expand_expect(self.possible_prompt) self.log.debug(swith to root account on host self.host) if self.RootPasswd!: self.child.write(su - ) self.expand_expect([assword:]) self.child.write(self.RootPasswd ) self.expand_expect(self.possible_prompt) #self.child.write(bash ) #self.expand_expect(self.possible_prompt) self.child.read_until(self.prompt) self.log.info(login host self.host successfully) return True except: print Login failed,please check ip address and account/passwd self.log.error(log in host self.host failed, please check reason) return False def send_command(self,command,sleeptime0.5): Run a command on the remote host. param command: Unix command return: Command output rtype: Stringself.log.debug(Starting to execute command: command) try: self.child.write(command ) if self.expand_expect(self.possible_prompt)[0]-1: self.log.error(Executed command command is failed, please check it) return False else: time.sleep(sleeptime) self.log.debug(Executed command command is successful) return True except socket.error: self.log.error(when executed command command the connection maybe break, reconnect) traceback.print_exc() for i in range(0,3): self.log.error(Telnet session is broken from self.host , reconnecting....) if self.login(): break return False def get_output(self,time_out2): reponseself.child.read_until(self.prompt,time_out) #print response:,reponse self.log.debug(reponse:reponse) return self.__strip_output(reponse) def send_atomic_command(self, command): self.send_command(command) command_output self.get_output() self.logout() return command_output def process_is_running(self,process_name,output_string): self.send_command(ps -ef | grep process_name | grep -v grep) output_list[output_string] if self.expand_expect(output_list)[0]-1: return False else: return True def __strip_output(self, response): #Strip everything from the response except the actual command output. #split the response into a list of the lines lines response.splitlines() self.log.debug(lines:str(lines)) if len(lines)1: #if our command was echoed back, remove it from the output if self.prompt in lines[0]: lines.pop(0) #remove the last element, which is the prompt being displayed again lines.pop() #append a newline to each line of output lines [item for item in lines] #join the list back into a string and return it return .join(lines) else: self.log.info(The response is blank:response) return Null response def logout(self): self.child.close() telnetoperate.py代码说明 1. __init__(self,host,prompt,account,accountPasswd,RootPasswd) 这里用到了多个登陆账号accountroot原因是我们的机器开始不能直接root登陆需要先用普通用户登陆才能切换到root账号所以这里出现了account, rootPasswd这2个参数如果你的机器可以直接root账号登陆或者你不需要切换到root账号可以就用account, accountPasswd就可以了。 prompt是命令行提示符机器配置不一样可能是$或者#,用来判断一个命令执行是否完成。 2. send_command(self,command,sleeptime0.5) 这里sleeptime0.5是为了避免很多机器性能不好命令执行比较慢命令还没返回会导致获取命令后的结果失败。如果你嫌这样太慢了可以调用的时候send_command(command,0) process_is_running( process_name 监控远程机器 #simplemonitor.py #!/usr/bin/env python #codingutf-8 import time import telnetoperate remote_servertelnetoperate.TelnetAction(192.168.23.235,#,user,passwd123) #get cpu information cpuremote_server.get_output(sar 1 1 |tail -1) memoryremote_server.get_output(top | head -5 |grep -i memory) ioremote_server.get_output(iostat -x 1 2|grep -v ^$ |grep -vi dev) 这样在任何一台机器上就可以实现监控远程多个机器了信息集中化管理方便进一步分析。如果你想cpu, memory, io独立的监控可以多线程或者起多个监控进程在多线程中需要注意的时候必须对每个监控实例建立一个telnet连接get_output是从telnet 建立的socket里面去获取数据如果多个监控实例用同一个socket会导致数据混乱。
http://www.pierceye.com/news/618872/

相关文章:

  • 东莞建站模板源码东莞注塑切水口东莞网站建设
  • 做文案策划需要看什么网站服装网站开发目的
  • 湖北定制型网站建设微信公众平台网页版
  • 需要做网站的公司有哪些免费网页模板之家
  • 淘客网站怎么备案合肥在线官网
  • 马上飞做的一些网站免费自助建站系统有哪些
  • 建网站投放广告赚钱wordpress全屏弹窗插件
  • 电子商务公司网站模版通辽网站建设公司
  • 国外社交网站建设苏州seo门户网
  • 小程序建站公司唐山网页搜索排名提升
  • 网站后台模板北京网络营销方案
  • 网站如何不被百度搜到浙江网站怎么做推广
  • 网站建设主机类型怎么选diy电子商城网站
  • 中文域名 怎么做网站门户网站建站系统
  • 网站上的个人词条怎么做的做网站推广有用吗
  • 定兴县住房和城乡建设局网站河南省新闻奖
  • 江西省建设工程协会网站查询郑州网站建设一汉狮网络
  • 网站是否含有seo收录功能素材下载平台网站源码
  • 西宁个人网站建设不错的网站建设
  • 海南综合网站两学一做电视夜校做网店网站
  • wordpress分类页面空白网站建设优化哪家好
  • 宁波模板建站哪家服务专业wordpress 神箭手
  • 一张图片网站代码视频生成链接在线工具
  • 网站品牌推广浙江手机版建站系统开发
  • 网站后台密码在哪个文件建站报价表
  • 昌乐营销型网站建设个人管理系统
  • 手机网站开发位置定位天津和平做网站公司
  • 搜搜提交网站入口国外wordpress空间
  • python 做网站 数据库做企业官网还有必要吗
  • 数据录入网站开发安阳县实验中学