Monitor page load with PhantomJS, Nagios and Ruby

Used PhantomJS Nagios plugin on CentOS machine with Nagios installed.
  1. Install prerequisites:
    yum install glibc fontconfig freetype freetype-devel fontconfig-devel wget bzip2
  2. Download, unpack and install PhantomJS:
    tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
    ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
    phantomjs –version
  3. Install Ruby and prerequisites:
    yum install ruby ruby-devel gcc
    gem install json
  4. Install nagios plugin (usually it could be placed in nagios plugins directory):
    mkdir page-load-test
    cd page-load-test/
    git clone
    cp check_http_load_time.rb /usr/local/nagios/libexec/
  5. Test page load speed:
    ./check_http_load_time.rb --perf -c 60 -w 30 -u -p /usr/local/bin/phantomjs --perf
  6. The output should be like this one:
    OK: load time: 0.56 | load_time=556.0ms size=4882 requests=4 dom_elements=23 load_time_initial_req=384ms
  7. Setup command in nagios:
    define command {
    command_name    check_http_load_time
    command_line    $USER1$/check_http_load_time.rb --perf -p /usr/local/bin/phantomjs -u $ARG1$ -w $ARG2$ -c $ARG3$
  8. Setup service notification (it will email me if page will load more than 8 seconds):
    define service {
        use                     local-service
        host_name               localhost
        service_description     check_http_load_time
        check_command           check_http_load_time!!8!10
        notifications_enabled   1
        contact_groups          admins