MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: MV3.x How to find out mv IS working?



******    message to minivend-users from Marius Schaefer <maillist@b-p-a.com>     ******

Hi,

thanks. I will try this one out.

Robert Hutchinson wrote:

> ******    message to minivend-users from hutch@cix.compulink.co.uk (Robert Hutchinson)     ******
>
> In-Reply-To: <372EE648.3A6A5EA7@b-p-a.com>
> In article <372EE648.3A6A5EA7@b-p-a.com>, maillist@b-p-a.com
> (Marius Schaefer) wrote:
>
> > ******    message to minivend-users from Marius Schaefer
> > <maillist@b-p-a.com    ******
> >
> > Hi,
> >
> > I have the a problem with one of my minivends. More than one
> time a day
> > the MV is not working anymore (no response). If I take a
> look with "ps
> > x" I can see a pid with minivend. But it is not working. So
> how can I
> > found out (with a perl-script eg. instead of my browser) if
> mv is woking
> > or not?
> >
> > thanx.
> > Marius
> >
>
> here is a perl script that I wrote.
> It works for me both as a cron job on my linux box checking my
> local version as well as checking my online mv on the remote
> server where I don't have cron privs. I haven't run it through
> a modem to be honest.
> Edit the variables at the top to suit your needs.
>
> it requires Expect.pm which I think you will find at
> ftp://ftp.habit.com/pub/perl
>
> ######################################
> #!/usr/bin/perl
>
> use LWP::Simple;
> use Expect;
>
> # checks if webserver is up and if it is
> # gets the page to see if database server is up
> # If there are any problems emails $mail_recip
>
> # user vars
> $debug        = 0;
> $host         = "myhost.com";
> $user         = "$ENV{'USER'}"."\@"."myhost.com";
> $mail_recip   = "me\@mymail.com";
> $mailprog     = "/usr/bin/sendmail";
> $prot         = "http://";
> $path_to_prog = "/cgibin/";
> $prog         = "simple.cgi";
> $site         = $prot.$host.$path_to_prog.$prog;
> $login        = "mylogin";
> $login_prompt = "ogin: ";
> $passw        = "mypassword";
> $passw_prompt = "word:";
> $prompt       = "myprompt ";
> $process      = "telnet";
> $delay        = "0.5";                  # used if $modem=1
> $timeout      = "60";
> $modem        = 0;                              # 1 if modem
> is used, will go slow
> $command1     = "/my/path/to/minivend/bin/restart\r\n";
>
> # no need to edit below here
>
> $match_number=$error_if_any=$match_string=$before_match=$after
> _match="";
> ######################
> # start program
>
> print "\nDEBUG.. HOST=$host\nSITE=$site\nUSER=$user\n"
> if($debug);
>
> print "\nDEBUG.. Check if $site is up...\n"     if($debug);
> # check if server is up
> if (head($site)) {
>   # ok document exists
>   print "\nDEBUG.. Webserver on $site is UP\n"  if($debug);
>   # get it
>   $got  = get $site;
>   if (!$got){
>     &error_log("No Content from $site\n");
>   }
>   print "\nDEBUG.. GOT $site\nLENGTH=".length($got)."\n"
> if($debug);
>   # look for phrase <TITLE>No response</TITLE>
>   $lookfor="<TITLE>No response<\/TITLE>";
>   if ($got =~ /$lookfor/io){
>     # database server is down, so
>     # restart minivend
>     use Expect;
>     # Debugging anyone?
>     $Expect::Log_Stdout   = $debug;
>     if ($debug){
>       $Expect::Exp_Internal = 1;
>       $Expect::Debug        = 2;
>       print "\nDEBUG.. No response from database server,
> restarting\n";
>     }
>     # telnet to host
>     print "\nDEBUG.. telnet to $host\n" if($debug);
>     $remote = Expect->spawn("$process $host");
>     # login
>     $remote->expect($timeout,$login_prompt)
>     || &error_log("Never got login prompt $login_prompt on
> $host\n");
>     if ($modem){
>       $remote->send_slow($delay,"$login\r");
>     }
>     else{
>       print $remote "$login\r";
>     }
>     if($debug){
>     print "\nDEBUG.. Sent $login\n";
>     $out .= $remote->clear_accum();
>     }
>     else{       $remote->clear_accum();
>     }
>     # password
>     $remote->expect($timeout,$passw_prompt)
>     || &error_log("Never got password prompt $passw_prompt on
> $host\n");
>     if ($modem){
>     $remote->send_slow($delay,"$passw\r");
>     }
>     else{
>     print $remote "$passw\r";
>     }
>     if($debug){
>       print "\nDEBUG.. Sent $passw\n";
>       $out .= $remote->clear_accum();
>     }
>     else{       $remote->clear_accum();
>     }
>     # find prompt
>     $remote->expect($timeout,$prompt)
>     || &error_log("Never got prompt $prompt on $host\n");
>     # right, we are in
>     if($debug){
>     print "\nDEBUG.. Logged on\n";
>     $out .= $remote->clear_accum();
>     }
>     else{       $remote->clear_accum();
>     }
>     if ($modem){
>       $remote->send_slow($delay,"$command1");
>     }
>     else{
>       print $remote "$command1";
>     }
>     print "\nDEBUG.. Sent $command1\n"  if($debug);
>     ($match_number,
>         $error_if_any,
>         $match_string,
>         $before_match,
>         $after_match) =
>     $remote->expect($timeout,$prompt);
>     if ($error_if_any){
>       &error_log("Never got prompt after sending $command1
> command\n");
>     }
>     # exit telnet session
>     if($debug){
>       print "\nDEBUG.. Exiting telnet\n";
>       $out .= $remote->clear_accum();
>     }
>     else{$remote->clear_accum();
>     }
>     if ($modem){
>       $remote->send_slow($delay,"exit\r\n");
>     }
>     else{
>       print $remote "exit\r\n";
>     }
>     # end session
>     $remote->hard_close();
>     print "\nDEBUG.. Session closed\n"  if($debug);
>     # parse output of restart to find out what happened
>     # $before_match should contain the screen output
>     # log result
>     &error_log("\nMinivend server
> restarted\nOUTPUT:\n$before_match\nEND OUTPUT\n");
>     }
>     else{
>       print "Minivend server is UP on $site\n"  if($debug);
>     }
> }
> else{
>   # no response at all from server. log it.
>   &error_log("No header received from $site.\nWebserver may be
> down");
> }
> print "\nEXITING PROGRAM\n"             if ($debug);
> exit;
> ##END OF MAIN##
>
> #----------------------------------------------------------
> sub send_mail {
>
> #       my $content = @_;
>     # Open The Mail Program
>     open(MAIL,"|$mailprog -t");
>     print MAIL "To: $mail_recip\n";
>     print MAIL "From: $user (Watching $site)\n";
>         print MAIL "Subject: Result $0\n";
>     print MAIL "@_\n";
>     print MAIL "-" x 75 . "\n\n";
>     close (MAIL);
> }
> #----------------------------------------------------------
> sub error_log{
>         if ($debug){
>                 print "@_";
>                 print "\nDONE\n";
>         }
>         else{
>                 &send_mail("@_");
>         }
>         exit;
> }
> #----------------------------------------------------------
>
> ##########################
> ##EOF##
>
> good luck
> bye :-)=
>
> R.R.Hutchinson
> Western Hills Software
> 12 Great Oak Street
> Llanidloes
> Powys SY18 6BU
> Wales UK
> 01686 411181
> hutch@cix.co.uk
>
> web space provider
> Linux specialist
> cgi scripts
> web databases
>
> > -
> > To unsubscribe from the list, DO NOT REPLY to this message.
>  Instead,
> > send
> > email with 'UNSUBSCRIBE minivend-users' in the body to
> > Majordomo@minivend.com.
> > Archive of past messages:
> http://www.minivend.com/minivend/minivend-list
> >
> >
>
> -
> To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
> email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
> Archive of past messages: http://www.minivend.com/minivend/minivend-list

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: