shell calculate downtime with web monitoring

! # / bin / the bash 

fail_time () { 

startTime = `1000 checkfail.log tail -n | grep" $ URL "| grep" 1st "| tail -n 3 | head -n 1 | awk '{printf $ 1; printf ""; printf $ 2} ' `# hang time taken site 
endtime =` tail -n 1000 checkfail.log | grep "$ url" | grep " restored monitor" | tail -n 1 | awk' {printf $ 1 ; printf ""; printf $ 2 } ' `# recovery time taken site 

startm = $ (DATE --date =" $ startTime "% M +); 
ENDM = $ (DATE --date =" $ the endtime "+ M% ); 

starth = $ (DATE --date = "$ startTime"% + H); 
endh = $ (DATE --date = "the endtime $"% H +); 

the startd = $ (DATE --date = "$ startTime "% D +); 
ENDD = $ (DATE --date =" $ endtime "D +%); 

echo" The fault startTime start time $ " 
echo" ends the failure time $ endtime "

day = $ (($ ((10 # $ endd)) - $ ((10 # $ startd)))) 
hour = $ (($ ((10 # $ endh)) - $ ((10 # $ Homeh)) ))
minute = $ (($ ((10 # $ ENDM)) - $ ((10 # $ startm))))

Total = $ (($ (($ Day * 24 * 60)) + $ (($ hour * 60)) + $ minute)) 

echo "The fault duration: $ ((total / 60) ) h $ ( (% Total $ 60)) m " 

}

Enterprise micro-channel effect

image.png



Guess you like

Origin blog.51cto.com/junhai/2430313