FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


scripts:cron-for-performance.html



Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
scripts:cron-for-performance.html [2017/12/01 00:48]
kurihara removed
— (current)
Line 1: Line 1:
-[[os:info.html|]] 
-====== Performance survey of seconds interval on Cron ====== 
- 
-\\ 
-{{INLINETOC}} 
-\\ 
- 
-===== /etc/cron.d/performance ===== 
-<sxh bash toolbar:false gutter:false> 
-LANG=C 
-LOGDIR=/var/log/performance 
- 
- 
-# 86400sec = 1day = 24h x 60m x 60s 
-0 0 * * * root vmstat 1 86400 | awk '{print strftime("\%y/\%m/\%d \%H:\%M:\%S"), $0} { system(":") }' >> ${LOGDIR}/vmstat.`date +\%Y\%m\%d` 
-0 0 * * * root mpstat 1 86400 >> ${DIR}/mpstat.`date +\%Y\%m\%d` 
-0 0 * * * root iostat -xtm 10 8640 >> ${LOGDIR}/iostat.`date +\%Y\%m\%d` > /dev/null 2>&1 
-* * * * * root date >> ${DIR}/ps.`date +\%Y\%m\%d` ; ps auxwf >> ${LOGDIR}/ps.`date +\%Y\%m\%d` 
-* * * * * root top -b -n 4 -d 15 >> ${LOGDIR}/top.`date +\%Y\%m\%d 
- 
-5 0 * * * root find ${LOGDIR} -type f -name "*2*"  -mtime +30  -exec rm -rf {} \; 
-10 0 * * * root gzip ${LOGDIR}/*`date -d '1day ago' +\%Y\%m\%d` 
-</sxh> 
- 
->man 5 crontab 
->A  "%"  character  in the command, unless escaped with a backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. 
- 
- 
-\\ 
-\\ 
-===== vmstat.sh ===== 
-**memory, swap, io, system, cpu** 
- 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#0 0 * * * /home/fasthandle/scripts/vmstat.sh > /dev/null 2>&1 
-# daily about 60M 
- 
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-# 86400sec = 1day = 24h x 60m x 60s 
-vmstat 1 86400 | awk '{print strftime("%y/%m/%d %H:%M:%S"), $0} { system(":") }' >> ${DIR}/vmstat.`date +%Y%m%d` 
- 
-find ${DIR} -type f -name "vmstat*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
- 
-==Output Example== 
-<code> 
-# vmstat 1 3 | awk '{print strftime("%y/%m/%d %H:%M:%S"), $0} { system(":") }' 
-17/11/29 00:18:29 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- 
-17/11/29 00:18:29  r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 
-17/11/29 00:18:29  1  0      0 270248   1492 251820    0    0    85    36   64  117  0  0 99  0  0 
-17/11/29 00:18:30  0  0      0 270092   1492 251852    0    0          149  265  0  0 100  0  0 
-17/11/29 00:18:31  1  0      0 270092   1492 251852    0    0        21  139  236  0  0 100  0  0 
-</code> 
- 
-\\ 
-===== mpstat.sh===== 
-**CPU** 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#0 0 * * * /home/fasthandle/scripts/mpstat.sh > /dev/null 2>&1 
-  
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-# 86400sec = 1day = 24h x 60m x 60s 
-mpstat 1 86400 >> ${DIR}/mpstat.`date +%Y%m%d` 
-  
-find ${DIR} -type f -name "mpstat*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
-==Output Example== 
-<code> 
-# mpstat -P ALL 1 3 
-Linux 3.10.0-229.el7.x86_64 (centos7)   11/29/17        _x86_64_        (2 CPU) 
- 
-00:17:23     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle 
-00:17:24     all    0.00    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00   99.50 
-00:17:24          0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 
-00:17:24          0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 
- 
-00:17:24     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle 
-00:17:25     all    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00    0.00   99.50 
-00:17:25          0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00   99.00 
-00:17:25          0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00   99.00 
- 
-00:17:25     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle 
-00:17:26     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 
-00:17:26          0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 
-00:17:26          0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00 
- 
-Average:     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle 
-Average:     all    0.00    0.00    0.17    0.17    0.00    0.00    0.00    0.00    0.00   99.66 
-Average:          0.00    0.00    0.00    0.00    0.00    0.33    0.00    0.00    0.00   99.67 
-Average:          0.00    0.00    0.00    0.34    0.00    0.00    0.00    0.00    0.00   99.66 
-</code> 
-\\ 
-===== iostat.sh ===== 
-**IO** 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#0 0 * * * /home/fasthandle/scripts/iostat.sh > /dev/null 2>&1 
-# daily about 10M 
- 
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-# 86400sec = 1day = 24h x 60m x 60s 
-#iostat -xtm 1 86400 >> ${DIR}/iostat.`date +%Y%m%d` 
-iostat -xtm 10 8640 >> ${DIR}/iostat.`date +%Y%m%d` 
- 
-find ${DIR} -type f -name "iostat*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
-==Output Example== 
-<code> 
-# iostat -xtm 1 2 
-Linux 3.10.0-229.el7.x86_64 (centos7)   11/29/17        _x86_64_        (2 CPU) 
- 
-11/29/17 00:20:58 
-avg-cpu:  %user   %nice %system %iowait  %steal   %idle 
-           0.11    0.00    0.17    0.31    0.00   99.41 
- 
-Device:         rrqm/  wrqm/    r/    w/   rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util 
-sda               0.45     0.11    3.16    5.10     0.15     0.07    53.91     0.02    2.36    3.68    1.54   0.93   0.77 
-dm-0              0.00     0.00    3.12    4.35     0.14     0.07    58.00     0.02    2.61    3.70    1.83   1.02   0.76 
-dm-1              0.00     0.00    0.15    0.00     0.00     0.00     8.00     0.00    0.62    0.62    0.00   0.35   0.01 
-dm-2              0.00     0.00    0.02    0.00     0.00     0.00     8.00     0.00    0.25    0.25    0.00   0.25   0.00 
-dm-3              0.00     0.00    0.02    0.00     0.00     0.00     8.00     0.00    0.00    0.00    0.00   0.00   0.00 
- 
-11/29/17 00:20:59 
-avg-cpu:  %user   %nice %system %iowait  %steal   %idle 
-           0.00    0.00    0.00    0.00    0.00  100.00 
- 
-Device:         rrqm/  wrqm/    r/    w/   rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util 
-sda               0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00 
-dm-0              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00 
-dm-1              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00 
-dm-2              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00 
-dm-3              0.00     0.00    0.00    0.00     0.00     0.00     0.00     0.00    0.00    0.00    0.00   0.00   0.00 
- 
-</code> 
- 
-\\ 
-===== ps.sh ===== 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#* * * * * /home/fasthandle/scripts/ps.sh > /dev/null 2>&1 
- 
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-date >> ${DIR}/ps.`date +%Y%m%d` 
-ps auxwf >> ${DIR}/ps.`date +%Y%m%d` 
- 
-find ${DIR} -type f -name "ps*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
-\\ 
-===== top.sh ===== 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#* * * * * /home/fasthandle/scripts/top.sh > /dev/null 2>&1 
- 
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-top -b -n 4 -d 15 >> ${DIR}/top.`date +%Y%m%d` 
- 
-find ${DIR} -type f -name "top*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
- 
- 
-\\ 
-===== df.sh ===== 
- 
-<sxh bash toolbar:false gutter:false> 
-#!/bin/sh 
-#* * * * * /home/fasthandle/scripts/df-h.sh > /dev/null 2>&1 
- 
-DIR=/var/log/performance 
-[ -d "$DIR" ] || mkdir $DIR 
- 
-NUM=1 
-while [ "${NUM}" -le 6 ] 
-do 
-    df -h | awk '{print strftime("%y/%m/%d %H:%M:%S"), $0}' >> ${DIR}/df.`date +%Y%m%d` 
-    NUM=`expr ${NUM} + 1` 
-    sleep 10 
-done 
- 
-find ${DIR} -type f -name "df*"  -mtime +30  -exec rm -rf {} \; 
-</sxh> 
- 
- 
-\\ 
-\\ 
-[[os:info.html|]] 
- 
-\\ 
-<WRAP box 90%> 
-[[:index.html#OS Management|Top#OS Management]] 
-<catlist ..: -noAddPageButton -noHead -sortAscending> 
-</WRAP> 
  


scripts/cron-for-performance.html.1512056934.txt.gz ยท Last modified: 2017/12/01 00:48 by kurihara