User Tools

Site Tools


execution_time_and_notify

Differences

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

Link to this comparison view

execution_time_and_notify [2011/05/25 18:51]
k2patel
execution_time_and_notify [2020/08/10 02:35]
Line 1: Line 1:
-====== Check execution time and notify if exceed ====== 
-One Liner 
  
-<code bash> 
-s=`date +%s`; /​usr/​local/​bin/​php index.php ; e=`date +%s`; if [ $(( $e - $s )) -gt 10 ]; 
-then /​usr/​bin/​mail -s "​[Notice] `hostname` Time is More then 10 second"​ status@k2.com ; fi 
-</​code>​ 
- 
-Script 
- 
-<code bash> 
-#!/bin/bash 
-# Monitor execution of process 
- 
-export receipients="​status@k2.com"​ 
- 
-output="​.BxJ04o1k2lcTURK"​ 
- 
-notify(){ 
-   for n in $receipients;​ do 
-      echo $1 | /​usr/​bin/​mail -s "​[Notice] `hostname` Time is More then 10 second"​ $n 
-   done 
-} 
- 
-cd /​usr/​www/​virtual/​sf/​www.xyz.com/​ 
-/​usr/​bin/​time -h -p -o $output /​usr/​local/​bin/​php index.php >/​dev/​null 2>&1 
-count=0 
- 
-for i in `cat $output | awk '​{print $2}'` 
-do 
-case=`echo "$i > 10.0" | bc` 
-if [ $case -eq '​1'​ ] 
-then 
-        count=1; 
-fi 
-done 
-if [[ count -eq '​1'​ ]] 
-then 
-notify "​index.php is taking more then 10 second to execute"​ 
-fi 
- 
-rm $output 
-</​code>​ 
execution_time_and_notify.txt ยท Last modified: 2020/08/10 02:35 (external edit)