Windows Server 指令碼記錄Apache、Mysql 每分鐘並發數

來源:互聯網
上載者:User

標籤:

開啟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 offsetlocal enabledelayedexpansionecho %date:~0,4%%date:~5,3%%date:~8,6% %time:~0,2%:%time:~3,2%:%time:~6,2% >d:\monitor\apache\anetstat -ant |find /i "ESTABLISHED"|find /i ":80 " /c >d:\monitor\apache\bcd d:cd monitorcd apachefor /f "tokens=*" %%i in (a) do (set /a n+=1set #!n!=%%i)set n=(for /f "tokens=*" %%i in (b) do (set /a n+=1call echo %%#!n!%%%%i))>>apacheResultdel a bcd C:\Program Files\MySQL\MySQL Server 5.6\binset user_mysql=dbmonitorset password_mysql=dbPasswordmysql -u%user_mysql% -p%password_mysql% < d:\monitor\mysql\sql.sqlecho %date:~0,4%%date:~5,2%%date:~8,6% %time:~0,2%:%time:~3,2%:%time:~6,2% >d:\monitor\mysql\acd d:cd monitorcd mysqlfor /f "tokens=*" %%i in (a) do (set /a n+=1set #!n!=%%i)set n=(for /f "tokens=*" %%i in (b) do (set /a n+=1call echo %%#!n!%%%%i))>>mysqlResultdel a b:end  
Monitor Code

備忘:BAT指令碼在計劃任務中不執行,是計劃任務設定有問題,若指令碼未執行,請安裝修改:

Windows Server 指令碼記錄Apache、Mysql 每分鐘並發數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.