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

 

начало

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

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

семинари ...

документи

как да ...

 

 

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

Re: lug-bg: Pomosht malko za edna "glupost"


  • Subject: Re: lug-bg: Pomosht malko za edna "glupost"
  • From: vlk@xxxxxxxxxxxxxxxxx (Vesselin Kolev)
  • Date: Wed, 3 Jul 2002 10:46:08 +0300



Iskam da kazha neshto, koeto osmislih predi da napisha i e po temata...

Sybitieto, chiato davnost traibva da se opisva v HTML documenta e
s grubo presmetnata otnositelna greshka +/- 1 den. Viarno, che se 
izpisvat chasovete i minutite, no te sa malka velichina na fona na goliamata 
(osven ako niakoi ne operira s MS server i go rebootva za shtialo i neshtilo)
i mozhe da se izpisvat samo broia dni.

Ima dva varianta, po koito mozhe da se trygne... 

Ako web-servera osbluizhva kym 1000-da zaiavki na den e napylno
dopustimo da se vika instrumenta uptime i da se izvezhda directno
ot nego statisticata za vremeto sled poslednoto restartirane na 
sistemata. 

Ako web-servera osbluzhva po 1000 zaiavki na minuta mozhe bi tova
ne e nai-dobria podhod. V tozi sluchai mozhe da se izpulniava na
vsiaka edna minuta script, izvikvash uptime i zapisvasht rezultatite v
promenliva v pametta.. naprimer CURRENT_UPTIME. Tazi promenliva
da se podava posle na generirashtia HTML documenta script i da se
izpisva v izhodnia kod, koito se podava kato otgovor na zaiavkata....
Taka se pesti mashinno vreme, koeto za natovarenite web-serveri e
kritichen factor za proizvoditelnostta. Vse pak e po-dobre neshtoto
da se startira po vednyzh v minuta, otkolkoto da se startira po
1000 pyti v minuta... Kolkoto i proizvoditelni da se syvremennite serveri
vinagi stoi factora svobodni resursi i razpredeliane na natovarvaneto.

Fakticheski crond mozhe da izpylniava zadacha nai-malko na 1 minuta,
a tova syvpada s minimalnata otnositelna greshka na sybitieto "vreme
sled poslednoto restartirane na servera" (+/- 1 minuta).

Tova e variant pri koito HTML documenta se generira pri vsiaka zaiavka
na potrebitel... 

Ako traibva syvsem da se optimizira natovarvaneto e nuzhno da se reshi
dali HTML documenta shte se generira pri vsiaka zaiavka ili vremeto mezhdu
dve negovi generacii shte syvpadne s minimalnata otnositelna greshka na 
otchitanoto sybitie.... Po-udobno e na crond da se podade zadacha pri
koiato na vsiaka edna minuta toi da generira HTML document, koito da
ima vreme na zhivot 1 minuta i sled iztichane na vremeto na zhivot da se
generira nov document. Po tozi nachin v prodylzhenie na 1 minuta natovarvaneto
na web-servera shte e malko, zashtoto shte se izpylniavat statichni zaiavki,
t.e. podavane na fail kato otgovor na zaiavkata bez dopylnitelno izpylnenie
na generacionni procesi ot strana na scriptove i instrumenti.

Razbira se, tova e edin elementaren podhod za po-nachinaeshti administratori.

Po-pregmatichnia podhod pochiva na izpolzvaneto na Perl constructori na 
HTML documenti.

  Blagodaria na vsichki za vnimanieto;))

     Vesselin

On Tuesday 02 July 2002 18:18, you wrote:
> ajde stiga s toq thread,
> prikachil sam nqkakav kod deto sam se upraznqval
> za obsd e taka che naglasi si komandite
> zapishi go primerno kato stats.php
>
> i cheti, cheti, cheti
>
> <?php
>
> $posix_uname = posix_uname ();
> $sysname     = $posix_uname['sysname'];
> $nodename    = $posix_uname['nodename'];
> $release     = $posix_uname['release'];
> $version     = $posix_uname['version'];
> $machine     = $posix_uname['machine'];
> $domainname  = $posix_uname['domainname'];
>
> $posix_times = posix_times ();
> $uptime = $posix_times ['ticks'];
>
> echo "<p><b> $sysname $release $version $machine $nodename $domainname
> </b><hr> \n";
>
>
>     if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != ""){
>         $IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
>         $proxy = $HTTP_SERVER_VARS["REMOTE_ADDR"];
>         $host =
> @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]);
>     }else{
>         $IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];
>         $host = @gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]);
>     }
>
> echo "<p>$HTTP_USER_AGENT Connected from: $host \n";
>
> $today = getdate();
> $month =   $today['month']; $mday =    $today['mday'];    $year =
> $today['year'];
> $hours =   $today['hours']; $minutes = $today['minutes']; $seconds =
> $today['seconds'];
> $weekday = $today['weekday'];
>
> echo "<p> $mday $month $year $weekday $hours:$minutes:$seconds \n";
>
>
> //uptime
> exec("uptime", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
> //who -uH /var/log/wtmp
> exec("who -uH /var/log/wtmp", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
> // df
> exec("df -h", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
> // swapctl -lk
> exec("swapctl -lk", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
> // vmstat
> exec("vmstat", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
> exec("vmstat -i", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
>
>
> //netstat  -s -ib -r -q -d
> //netstat -f encap -r -q -d
> exec("netstat  -s -ib -r -q -d ", $output);
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
> exec("netstat -f encap -r -q -d ", $output);
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
> // ps -axu -ww -S -m
> exec("ps -axu -ww -S ", $output);
> // format each line of output
>  print "<pre>";
> while (list(,$val) = each($output)) :
>  print "$val<br>";
> endwhile;
>  print "</pre><hr>";
>
>
>
> $STAT_PAGE = "<html><body>$Output</body></html>";
>
> print $STAT_PAGE;
>
> ?>
> ===========================================================================
>= A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
> http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara
> Zagora To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
> ===========================================================================
>=
============================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers).
http://www.linux-bulgaria.org - Hosted by Internet Group Ltd. - Stara Zagora
To unsubscribe: http://www.linux-bulgaria.org/public/mail_list.html
============================================================================



 

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

 

линукс за българи
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.