Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: connected?


  • Subject: Re: lug-bg: connected?
  • From: Vladimir Vitkov <vvitkov@xxxxxxxxx>
  • Date: Mon, 26 Sep 2005 12:12:50 +0300
  • Delivered-to: lug-bg-list@xxxxxxxxxxxxxxxxxx
  • Delivered-to: lug-bg@xxxxxxxxxxxxxxxxxx

А това ми се върти през апачето за да ми е по красиво.

$ cat /var/www/htdocs/net/index.php
<?php
if(!isset($_GET['w'])){
        $t='194.145.63.12';
} else { $t=$_GET['w']; }
$command='ping -q -c3 -Ippp0 ';// pinging dir.bg
$command=$command . $t;
//echo $command;
$result=exec($command);
$result=trim($result);
$result=explode(' ',$result);
$result=$result[0];

if(!($result=='rtt')){ $color="red"; $text="DOWN"; } else {
$color="green"; $text="UP&Running"; }
?>
<html>
<head>
<title>Live Net Check</title>
<style type="text/css">
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: none}
A:hover {text-decoration: underline; color: red;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body bgcolor=white>
<center>
<BR><BR><BR><BR>
<h2>Checking connectivity with <?=$t; ?></h2>
<H1><b><font color=<?=$color; ?>>The internet connection is <?=$text;
?></font></b></h1>
<h3><a href=net.txt>Action Log</a> | <a href=?w=abv.bg>abv.bg
check</a> | <a href=?w=google.com>Google
Check</a> | <a href=http://4ek/cgi-bin/nph-tr.cgi?<?=$t; ?>>Trace
<?=$t; ?> from here</a>
</body></html>

On 26/09/05, Vladimir Vitkov <vvitkov@xxxxxxxxx> wrote:
> Аз ползвам следното
>
> #!/usr/bin/php
> <?php
> /*
> Script for recconecting the Internet conecction. Check the state with ping,
> then start killall and run ppp.
> */
>
> $command='ping -q -c3 -I ppp0 194.145.63.12';// pinging dir.bg
> $result=exec($command);
> $result=trim($result);
> $result=explode(' ',$result);
> $result=$result[0];
> //echo $result;
>
> if (!($result=='rtt')){ // ping failed
>        // start logging - write the log file
>        $time = date(" H:i:s",time());
>        $date = date("Y-m-d",time());
>        $data="$date --- $time --- Net is down\n";
>        $fp=fopen('/var/www/htdocs/net/net.txt','a+');
>        @fwrite($fp,$data);
>        @fclose($fp);
>        // end logging
>
>        $command='pppoe-stop';
>        exec($command);              // stop adsl
>        $command='ppp-off';
>        exec($command);              // stop ppp profilakti4no
>        $command='killall -9 pppd';
>        exec($command);              // cleanup
>        $command='killall -9 pppoe';
>        exec($command);              // cleanup
>        $command='pppoe-start';
>        exec($command);              //start adsl
>        $command='cp -f /etc/resolv1 /etc/resolv.conf 1>/dev/null 2>&1';
>        exec($command);              // restore name resolution
>                 // start logging - write the log file
>                 $time = date(" H:i:s",time());
>                 $date = date("Y-m-d",time());
>                 $data="$date --- $time --- Net recconected\n";
>                 $fp=fopen('/var/www/htdocs/net/net.txt','a+');
>                 @fwrite($fp,$data);
>                 @fclose($fp);
>                 // end logging
> //       }
> }
> return;
> ?>
>
> рънвам го през крон на всеки 5 мин
> Не е най-добрия но ми върши работа
> --
> С уважение,
> Владимир Витков
> ICQ: 7867203
> e-mail: vvitkov@xxxxxxxxx
> e-mail: vvitkov@xxxxxx
> Ако не отговарям на писмата ви: http://6lyokavitza.org/mail
>


--
С уважение,
Владимир Витков
ICQ: 7867203
e-mail: vvitkov@xxxxxxxxx
e-mail: vvitkov@xxxxxx
Ако не отговарям на писмата ви: http://6lyokavitza.org/mail



 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.