#!/usr/bin/perl # $Revision: 2 $ # $Date: 2008-09-12 15:11:40 +0300 (Fri, 12 Sep 2008) $ my %opt = ( # http link to nginx stub_status, be sure turn on stub_status in nginx conf nginx_status => 'http://localhost:80/nginx_status', # path for program what may dump web page, normaly lynx -dump # lynx => 'lynx -dump', lynx => 'wget -q -Y off -O -', ); $opt{var} = $ARGV[0] if $ARGV[0]; $opt{nginx_status} = $ARGV[1] if $ARGV[1] and $ARGV[1]=~/^http:\/\/\w+/; $opt{var} ||= ''; my $do = `$opt{lynx} $opt{nginx_status}`; if ($opt{var} eq 'req') { $do=~/^Active connections:\s*(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do"; $opt{d2} = $opt{d1} = $1; } elsif ($opt{var} eq 'con') { $do=~/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do"; $opt{d2} = $opt{d1} = $3; } #elsif { $do=~/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/; } else { $opt{var} = 'ERROR'; $opt{d2} = $opt{d1} = 0; warn "Error! Please read the help and set (req|con)\n"; } print "$opt{d1}\n"; print "$opt{d2}\n"; #print "$opt{up}\n" if $opt{up}; print "Nginx $opt{var}\n";