标签:
打开windows server 计划任务管理器。定时执行如下的Bat脚本即可。
在D盘新建一个monitor文件夹,创建ApacheMysql.bat文件。内容如下:
在monitor文件夹中新建mysql、apache文件夹
进入mysql文件夹,创建sql.sql文件,保存如下内容:
select count(*) from information_schema.processlist into outfile ‘d:/monitor/mysql/b‘;
执行后,脚本会生成日志文件。记录当前时间与当前并发数,保存在各自文件夹中。
@echo off setlocal enabledelayedexpansion echo %date:~0,4%%date:~5,3%%date:~8,6% %time:~0,2%:%time:~3,2%:%time:~6,2% >d:\monitor\apache\a netstat -ant |find /i "ESTABLISHED"|find /i ":80 " /c >d:\monitor\apache\b cd d: cd monitor cd apache for /f "tokens=*" %%i in (a) do ( set /a n+=1 set #!n!=%%i) set n= (for /f "tokens=*" %%i in (b) do ( set /a n+=1 call echo %%#!n!%%%%i))>>apacheResult del a b cd C:\Program Files\MySQL\MySQL Server 5.6\bin set user_mysql=dbmonitor set password_mysql=dbPassword mysql -u%user_mysql% -p%password_mysql% < d:\monitor\mysql\sql.sql echo %date:~0,4%%date:~5,2%%date:~8,6% %time:~0,2%:%time:~3,2%:%time:~6,2% >d:\monitor\mysql\a cd d: cd monitor cd mysql for /f "tokens=*" %%i in (a) do ( set /a n+=1 set #!n!=%%i) set n= (for /f "tokens=*" %%i in (b) do ( set /a n+=1 call echo %%#!n!%%%%i))>>mysqlResult del a b :end
备注:BAT脚本在计划任务中不执行,是计划任务设置有问题,若脚本未执行,请安装下图修改:
Windows Server 脚本记录Apache、Mysql 每分钟并发数
标签:
原文地址:http://www.cnblogs.com/Mrhuangrui/p/4563823.html