Website load time test

Discussion in 'Programming/Scripts' started by admins, May 28, 2013.

  1. admins

    admins Member

    Hi all
    I want to monitor my loadtime of an website. If the loadtime is bigger than 30s the apache2 should restart.

    For the loadtime found this:
    Code:
    (time wget -p --no-cache --delete-after www.linuxweblog.com -q ) 2>&1 | awk '/real/ {print $2}'
    output
    Code:
    0m0.207s
    
    How could I do the rest?
    Thanks
    admins
     
  2. smartbloggger

    smartbloggger New Member

    @ Admin what is the ideal time of loading a website.
     
  3. moegeler

    moegeler New Member

    I don't know wich Linux Distri do you have but try some like this:

    Code:
    #!/bin/sh
    VAR_TIME="$( TIMEFORMAT='%R';time (wget -p --no-cache --delete-after www.linuxweblog.com -q) 2>&1 1>/dev/null )"
    
    float_test() {
         echo | awk 'END { exit ( !( '"$1"')); }'
    }
    
    float_test "$VAR_TIME > 30.000" && /etc/init.d/apache2 restart
    
    save this as a shell file like monitor.sh an then make a cronjob for this...

    I don't have tried it, so i don't know if it works...
     
    Last edited: Jun 13, 2013

Share This Page