Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2746 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs

  [Programmation] Linux et nb de connecté

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Programmation] Linux et nb de connecté

n°141467
Olivier51
Posté le 19-08-2002 à 15:03:25  profilanswer
 

Personne n'a réussi à me répondre sur le forum "Programmation", alors j'essaye ici ...
 
Après avoir parcouru vaguement un certain nombre de script pour comptabiliser le nombre de connecté sur son site, et avoir vu que pratiquement tout le monde utilisait une base de donnée en fixant approximativement un temps de visites pour chaques pages.  
Je trouve ces scripts un peu "sales", et je pense que le nombre de reqûete à la base de donnée est important.  
C'est pour ça que je me suis demandé si il était possible de connaitre le nombre de connecté sur son site Internet grâce à une commande Linux qu'on ferait exécuter grâce à la fonction PHP system() avec un petit grep ???  
Je dis peut-être des bétises mais à chaques connections au serveur Apache, le serveur crée un nouveau processus et ouvre une socket, donc avec la commande ps on pourrait alors savoir combien il y a de connecté.  
Où sinon j'ai vu la commande netstat qui affiche tous les sockets ouverts ainsi que leur états.  
 
Donc, j'ai testé ces deux commandes sur mon site, et voilà ce que ça donne :  
-> Pour "ps -ax" :  
PID TTY      STAT   TIME COMMAND  
   1 ?        S      0:14 init  
   2 ?        SW     0:27 [kflushd]  
   3 ?        SW     2:23 [kupdate]  
   4 ?        SW     1:15 [kswapd]  
   5 ?        SW     0:00 [keventd]  
   6 ?        SW<    0:00 [mdrecoveryd]  
 296 ?        S     26:12 syslogd -m 0  
 305 ?        S      0:00 klogd  
 335 ?        S      0:01 crond  
 449 ?        SN     0:58 /usr/bin/postmaster    
 485 ?        S      0:20 /sbin/lcdsleep  
 588 ?        S      0:00 sh /home/lseror/bb/runbb.sh  
 591 ?        SN     0:59 sh /home/lseror/bb18a/bin/bbrun /home/lseror/bb18a/bi  
18454 ?        S      0:00 /sbin/getty ttyS0 115200  
31633 ?        S      0:07 sendmail: accepting connections  
32378 ?        S      0:41 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
32382 ?        S      0:02 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
32391 ?        S      0:08 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
1302 ?        S      0:08 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
3366 ?        S      0:07 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
5209 ?        S      0:08 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
6141 ?        S      0:00 CROND  
6152 ?        S      0:00 /usr/sbin/sendmail -FCronDaemon -odi -oem root  
6153 ?        S      0:00 /usr/local/bin/topd  
7174 ?        S      0:06 /usr/sbin/httpd.admsrv -f /etc/admserv/conf/httpd.con  
3017 ?        S      0:00 sshd  
7522 ?        S      0:52 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7523 ?        S      0:41 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7524 ?        S      0:44 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7525 ?        S      0:51 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7526 ?        S      1:05 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7527 ?        S      0:56 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7552 ?        S      1:02 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
7633 ?        S      0:58 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
8288 ?        S      0:57 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
18370 ?        S      0:52 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
20154 ?        S      1:09 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
28618 ?        S      0:56 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
4511 ?        S      0:38 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
4513 ?        S      0:47 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
4515 ?        S      0:53 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
4517 ?        S      0:40 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
15643 ?        S      0:40 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
15865 ?        S      0:52 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
21669 ?        S      0:24 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
23061 ?        S      0:25 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
25178 ?        S      0:14 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
1377 ?        S      0:02 /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf  
4375 ?        S      0:00 inetd  
5324 ?        SN     0:00 sleep 298  
5398 ?        S      0:00 proftpd: om29017 - Mix-Reims-109-4-124.abo.wanadoo.fr  
5522 ?        R      0:00 ps -ax  
5522 ?        R      0:00 ps -ax  
 
-> Et pour netstat :  
Active Internet connections (w/o servers)  
Proto Recv-Q Send-Q Local Address           Foreign Address         State        
tcp        0   5565 paris58.amenworld.c:www Mix-Reims-109-4-12:1276 ESTABLISHED  
tcp        0  23296 paris58.amenworld.c:www Mix-Lyon-308-3-211:1971 ESTABLISHED  
tcp        0      0 paris58.amenwo:ftp-data Mix-Reims-109-4-12:1275 TIME_WAIT    
tcp        0    281 paris58.amenworld.c:www 208.154.199.138:3437    ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www dyn-212-83-189-249:1402 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www ARouen-106-1-10-16:3055 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www ARouen-106-1-10-16:3054 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www 220.105-200-80.ads:2090 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www 220.105-200-80.ads:2089 ESTABLISHED  
tcp        0      0 paris58.amenworld.:2208 mysql4.amen.fr:mysql    TIME_WAIT    
tcp        0  13872 paris58.amenworld.c:www 208.154.199.138:3433    ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www monitor1.internet:59273 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www cache-loh-aa01.pro:7044 TIME_WAIT    
tcp        0      0 paris58.amenworld.:2207 mysql5.amenworld.:mysql TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.172:1151      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.172:1151      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.176:4004      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:4001 FIN_WAIT2    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:4000 FIN_WAIT2    
tcp        0      0 paris58.amenworld.c:www ABayonne-103-1-2-1:1602 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www ABayonne-103-1-2-1:1601 ESTABLISHED  
tcp        0      0 paris58.amenworld.:2206 mysql4.amen.fr:mysql    TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www cache-loh-aa02.pro:1522 TIME_WAIT    
tcp        0      0 paris58.amenworld.:2205 mysql5.amenworld.:mysql TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.174:4746      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www proxy-4m.club-int:26452 TIME_WAIT    
tcp        0  50384 paris58.amenworld.c:www Mix-Tours-102-1-11:1614 ESTABLISHED  
tcp        0      0 paris58.amenwo:ftp-data Mix-Reims-109-4-12:1273 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www cache-loh-ae08.pr:45176 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www spider-loh-te011.:41426 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 200-163-003-168-b:36146 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 200-163-003-168-b:36145 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www x1crawler1-1-0.x-e:4964 TIME_WAIT    
tcp        0      0 paris58.amenworld.:2204 mysql4.amen.fr:mysql    TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www Mix-Nancy-104-2-14:1871 TIME_WAIT    
tcp        0  59232 paris58.amenworld.c:www proxy-5v.club-int:48234 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www 142.100.131.5:2016      FIN_WAIT2    
tcp        0      0 paris58.amenworld.:2203 mysql5.amenworld.:mysql TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.175:2772      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 142.100.131.5:2015      FIN_WAIT2    
tcp        0      0 paris58.amenworld.c:www cache-loh-ab08.pr:48592 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.173:1468      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www 66.28.250.174:4908      TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:3995 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:3994 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:3992 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www bordeaux-1-a7-62-1:3991 TIME_WAIT    
tcp        0      0 paris58.amenworld.c:www d164084.lsb.PT.KPN:2200 TIME_WAIT    
tcp        0  12441 paris58.amenworld.c:www d164084.lsb.PT.KPN:2198 FIN_WAIT1    
tcp        0      0 paris58.amenworld.c:www Mix-Nancy-104-2-14:1870 FIN_WAIT2    
tcp        0    697 paris58.amenworld.c:www d164084.lsb.PT.KPN:2201 FIN_WAIT1    
tcp        0      0 paris58.amenworld.c:www Mix-Tours-102-1-11:1575 TIME_WAIT    
tcp        0  50384 paris58.amenworld.c:www Mix-Tours-102-1-11:1572 ESTABLISHED  
tcp        0      0 paris58.amenworld.c:www Mix-Nancy-104-2-14:1866 TIME_WAIT    
tcp        1  58656 paris58.amenworld.c:www proxy-5v.club-int:34487 CLOSE_WAIT    
tcp        0      0 paris58.amenworld.c:ftp Mix-Reims-109-4-12:1260 ESTABLISHED  
tcp        0      1 paris58.amenworld.c:www dyn-213-19-2-164.p:1344 FIN_WAIT1    
tcp        1     53 paris58.amenworld.:smtp 211.138.13.227:2450     CLOSING      
tcp        0  45099 paris58.amenworld.c:www celsius.noos.net:8848   FIN_WAIT1    
tcp        0  19840 paris58.amenworld.c:www nas-cbv-1-62-147-1:1831 FIN_WAIT1    
tcp        0  19840 paris58.amenworld.c:www nas-cbv-1-62-147-1:1831 FIN_WAIT1    
tcp        0  17308 paris58.amenworld.c:www nas-cbv-1-62-147-1:1823 FIN_WAIT1    
tcp        0  50385 paris58.amenworld.c:www Mix-Rennes308-4-53:1330 FIN_WAIT1    
tcp        0  50385 paris58.amenworld.c:www Mix-Rennes308-4-53:1331 FIN_WAIT1    
udp        0      0 paris58.amenworld.:4720 ns2.agarik.com omain   ESTABLISHED  
Active UNIX domain sockets (w/o servers)  
Proto RefCnt Flags       Type       State         I-Node Path  
unix  3      [ ]         DGRAM                    199    /dev/log  
unix  0      [ ]         STREAM     CONNECTED     15428981 @00002482  
unix  0      [ ]         DGRAM                    15431881  
unix  0      [ ]         DGRAM                    14139350  
unix  0      [ ]         DGRAM                    209      
unix  0      [ ]         DGRAM                    209  
 
Pour compter le nombre de visiteurs ce ne sera pas compliquer, j'associerait une de ces commandes avec la commande grep et je compterais après le nombre de ligne.  
MAIS, le problème c'est qu'elle ligne comptabiliser pour savoir combien de visiteurs sont sur mon site sachant que je dois sûrement partager le serveur avec d'autres sites ????
 

mood
Publicité
Posté le 19-08-2002 à 15:03:25  profilanswer
 

n°141468
246tNt
Resistance is futile
Posté le 19-08-2002 à 15:06:13  profilanswer
 

c pas possible.

n°141469
asphro
Posté le 19-08-2002 à 15:10:57  profilanswer
 

ben chez moi sur apache ca marche pas comme ca il lance pas un proccesus pour chaque connexion !!
 
il en lance une puis 2 puis en ferme une en reouvre 2 etc !!!
 
teste locale avec 10 connexion !!!

n°141471
kadreg
profil: Utilisateur
Posté le 19-08-2002 à 15:13:22  profilanswer
 

asphro a écrit a écrit :

ben chez moi sur apache ca marche pas comme ca  




 
Encore heureux, puisque de base, apache ne fonctionne pas comme ça.


---------------
brisez les rêves des gens, il en restera toujours quelque chose...  -- laissez moi troller sur discu !
n°141472
asphro
Posté le 19-08-2002 à 15:14:34  profilanswer
 

non mais je dis ca car chez lui ca marche comme ca !!!
 
ca me semble bizarre !!

n°141478
246tNt
Resistance is futile
Posté le 19-08-2002 à 15:27:22  profilanswer
 

non chez lui ca ne marche surement pas comme ca ...
 
Mais étant donné qu'il est hébergé chez un "vrai" hebergeur, c'est un gros serveur avec de nombreux process httpd c tout.
 
Mais pour netstat, pas moyen de compter parce que tu peut pas differencier tes connexion de celle des autres.

n°141479
Olivier51
Posté le 19-08-2002 à 15:28:04  profilanswer
 

Peut-être parce qu'il y a plusieurs site sur le serveur ...
 
Mais pour les sockets ça marche non ??? Il auvre une socket à chaque connection ?

n°141480
Olivier51
Posté le 19-08-2002 à 15:28:31  profilanswer
 

En même temps ...

n°141487
Olivier51
Posté le 19-08-2002 à 15:31:43  profilanswer
 

Si je viens de trouver comment je peux faire pour les différencier, à chaque nouvelle connection sur mon site, j'ajoute dans un fichier texte la Foreign Address qui est donnée dans une variable apache, puis j'exécute la commande netstat avec la fonction system, je stoque le résultat dans une variable, puis je comptablise ceux qui viennent de chez moi en comparant les deux résultats (celui du fichier texte et celui de netstat).
 
Je mettrais les source de mon script sur mon site pour ceux que ça intéressera ...

n°141489
asphro
Posté le 19-08-2002 à 15:33:34  profilanswer
 

et tu coris que plus rapid ete meiux qu avec des requete sql ?

mood
Publicité
Posté le 19-08-2002 à 15:33:34  profilanswer
 

n°141490
asphro
Posté le 19-08-2002 à 15:34:31  profilanswer
 

en plus pour une question de secu je suis perso en safe_mode avec php !!!
 
docn toute commande systeme desactivé

n°141608
246tNt
Resistance is futile
Posté le 19-08-2002 à 19:56:46  profilanswer
 

Et puis la connection ne reste ouverte que lors de la requete (un tout petit peu avant, un tout petit peu apres ). Donc je prend une page je suisc ompté, qq seconde plutard je suis plus compté parce que je suis en train de lire la page et que la connection s'est fermé ...

n°142089
PinG
Rooteur
Posté le 20-08-2002 à 17:22:01  profilanswer
 

Il n'y a pas de solution ultime.
la meilleure étant aujourd'hui celle que tout le monde utilise : DB + temps moyen de visite par page...


---------------
-- NO SLACKERS - violators will be fsck'd & tar'd

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs

  [Programmation] Linux et nb de connecté

 

Sujets relatifs
bootable diskett kestion of linux's lamerpour partager l adsl avec 2 ou 3 PC quel distrib linux choisir???
[Linux] Le topic du xinitrcNewbi Linux : Config Apache + Logiciel de visualisation d'AVI
Never Winter Nights GNU/Linux = ça prend forme !Linux sur Compaq 732
AIdez moi a virer LinuxConnexion rezo Linux->Win98
Linux newbie inside : config réseau ?? 
Plus de sujets relatifs à : [Programmation] Linux et nb de connecté


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR