Sygus.net

Frédéric Guihéry

La mémoire sous Linux : analyse du fichier /proc/meminfo

Dans cet article, je vais tenter d'expliquer les différentes informations que le noyau Linux nous donne au travers du fichier /proc/meminfo. Comme support, je vais afficher les données qui concernent mon système. Il s'agit d'un noyau 2.6.24-1 dans une Debian unstable. Ma machine repose sur une architecure x86 en 32 bits et contient une barrette de 1 Go de mémoire RAM.

$ cat meminfo 
MemTotal:      1036256 kB
MemFree:        191256 kB
Buffers:         51824 kB
Cached:         468392 kB
SwapCached:           0 kB
Active:         398852 kB
Inactive:       404108 kB
HighTotal:      131008 kB
HighFree:          256 kB
LowTotal:       905248 kB
LowFree:        191000 kB
SwapTotal:      524280 kB
SwapFree:       524280 kB
Dirty:              44 kB
Writeback:           0 kB
AnonPages:      282736 kB
Mapped:          82108 kB
Slab:            22552 kB
SReclaimable:    14468 kB
SUnreclaim:       8084 kB
PageTables:       2232 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   1042408 kB
Committed_AS:   880596 kB
VmallocTotal:   114680 kB
VmallocUsed:      7540 kB
VmallocChunk:   105972 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
HugePages_Surp:      0
Hugepagesize:     4096 kB

Commençons par les premières lignes :

  • MemTotal : la quantité de mémoire vive utilisable (ma barrette fait 1 Go (1 073 742 Ko), mais il y a quelques Mo réquisitionnés par le noyau (visiblement 12 615 Ko)).
  • MemFree :la quantité de mémoire vive actuellement non allouée.
  • Buffers : la quantité de mémoire vive actuellement allouée dans des buffers.
  • Cached : la quantité de mémoire actuellement utilisée en tant que cache (par exemple, des caches pour les transferts vers et depuis le disque dur).
  • SwapCached : la quantité de mémoire actuellement sortie du swap, mais dont une copie est toujours présente dedans.
  • Active : la quantité de mémoire vive récemment utilisée.
  • Inactive : la quantité de mémoire qui n'a pas été utilisée depuis un certain temps (le noyau pioche d'abord dans ces pages s'il a besoin de mémoire).

Sur une architecture x86 32 bits, la mémoire physique est séparée en trois zones. D'une part, la zone ZONE_DMA, qui correspond aux adresses physiques de 0 à 16 Mo. D'autre part, la zone ZONE_NORMAL qui va de 16 à 896 Mo. Et enfin, la zone ZONE_HIGHMEM qui va de 896 à 4 Go (voire 64 Go avec l'extension PAE). Sur ma machine, la mémoire vive remplie donc les 2 premières zones, plus une partie de la ZONE_HIGHMEM.

  • HighTotal : la quantité de mémoire vive présente dans la zone ZONE_HIGHMEM.
  • HighFree : la quantité de mémoire vive non utilisée et présente dans la zone ZONE_HIGHMEM.
  • LowTotal : la quantité de mémoire vive présente dans le zone ZONE_NORMAL.
  • LowFree : la quantité de mémoire vive non utilisée et présente dans la zone ZONE_NORMAL.

Vérifions :

HighTotal + LowTotal = 131008 + 905248 = 1036256 = MemTotal
HighFree + LowFree = 252 + 57468 = 57720 = MemFree

Chouette, ça colle !

  • SwapTotal : la taille du swap.
  • SwapFree : la place disponible dans le swap.

Dans mon cas, le swap n'est pas du tout utilisé (en effet, OpenOffice n'est pas encore lancé... :). C'est également vérifiable avec l'utilitaire swapon :

$ sudo swapon -s
Filename           Type        Size    Used Priority
/dev/mapper/lvm-swap  partition  524280   0   -1
  • Dirty : la quantité de mémoire en attente d'être écrite sur le disque.
  • Writeback : la quantité de mémoire qui est actuellement en train d'être écrite sur le disque.
  • AnonPages : la quantité de mémoire allouée avec la fonction mmap() avec le flag MAP_ANONYMOUS.
  • Mapped : la quantité de mémoire allouée avec la fonction mmap() à partir de fichiers ou de devices.
  • Slab : la quantité de mémoire utilisée au sein du noyau, et allouée avec l'allocateur Slab, pour ses propres objets et structures.
  • PageTables : la quantité de mémoire utilisée en tant que table de pages pour gérer la pagination.
  • Committed_AS : la quantité maximale de mémoire utilisable avant que le noyau ne commence à swapper.

Linux sépare la mémoire virtuelle en deux partie. Une première, de 3 Go, et qui contient l'espace d'adressage virtuel d'un processus. La seconde, qui elle fait 1 Go, et qui contient l'espace d'adressage noyau. C'est dans cet espace que seront mappés les zones ZONE_DMA et ZONE_NORMAL. Or, celles-ci ont une taille maximale cumulée de 896 Mo. Il est donc nécessaire d'avoir un autre espace, l'espace d'adressage virtuel du noyau, qui permet d'atteindre les 1 Go évoqués juste avant. La valeur VmalloTotal donne la taille de cet espace.

  • VmallocTotal : la quantité totale de mémoire de l'espace d'adressage virtuel du noyau.
  • VmallocUsed : la quantité de mémoire utilisée dans l'espace d'adressage virtuel du noyau.
  • VmallocChunk : le plus grand bloc contigu de mémoire virtuelle (et non physique) disponible dans l'espace d'adressage virtuel du noyau.
  • HugePages_Total : le nombre de hugepage allouée. Une hugepage est une page d'une grande taille (sisi :), utilisée par des programmes qui ont des besoins précis de mémoire.
  • HugePages_Free : le nombre de hugepage disponibles.
  • Hugepagesize : la taille d'une hugepage.

Le libre-échange est-il libre ?

[ Voici une copie de l'article qui a été publié sur Agoravox il y a quelques jours et dans lequel je voulais avant tout remettre en cause la logique de la PAC ]

A l’heure du libre-échange et de l’ouverture des frontières, le protectionnisme américain et la politique agricole commune en Europe sont-elles bénéfiques pour la planète ?

Lire la suite...

Construire un système de commentaires pertinent

En parcourant les différents sites de médias, on peut noter qu'il existe une multitude de gestions des commentaires. Certains affichent les commentaires de façon linéaire, d'autres sous la forme d'arbre ou encore individualisés. Se pose alors le problème de la lisibilité lorsqu'un nombre important de contributions est envoyé. Tous ces systèmes ont leurs avantages et leurs défauts. Voici quelques exemples de systèmes de gestion de commentaires :

Lire la suite...

RMLL - Le logiciel libre s'impose en France

[ Article paru sur Rue89 ]

Du 10 au 14 juillet, avaient lieu à l'université d'Amiens les rencontres mondiales du logiciel libre, connues également sous le diminutif RMLL. Une grande manifestation qui rassemblait, pour la 8ème édition, les différents acteurs du domaine. Ici, le monde associatif côtoie le monde de l'entreprise, le monde universitaire, le monde éducatif, les collectivités locales, les grandes administrations ainsi que les simples utilisateurs comme les passionnés. Bref, une vaste communauté où chacun y trouve son intérêt et tiens compte de l'intérêt des autres. Car c'est bien ça le logiciel libre : tout le monde a la liberté de contribuer, et chacun dispose des contributions des autres. Le parallèle avec l'encyclopédie Wikipédia est inévitable. D'ailleurs, les deux communautés sont très proches et sont liées par une même philosophie, celle du partage et de la création de biens communs.

Lire la suite...

La concurrence appliquée aux télécoms (1)

A la fin de mon précédent billet sur le libéralisme, j'avais terminé en pointant du doigt quelques termes moteurs de l'économie actuelle et fondateurs du néolibéralisme. Entre autre, j'avais initié une remise en cause du modèle économique basé sur la sacro-sainte concurrence. Cette bonne vieille concurrence qui, selon d'éminents économistes et prix nobels (Friedrich Hayek, Jean-Baptiste Say, Adam Smith... pour ne pas les citer), amène à une harmonie sociale et à un équilibre économique, à la condition, biensur, qu'aucun contrôle et qu'aucune régulation étatique n'aient lieu. Dans le cas contraire, chômage et inflation seraient alors inévitables. Voilà pour la théorie. En pratique, on en connaît plus ou moins les limites. On peut alors se poser la question de l'efficacité de la libre concurrence. Est-elle d'ailleurs saine dans tous les domaines ? dans les transports ? dans la santé ? dans l'éducation ? et dans... les télécoms ? Tiens donc, parlons des télécoms ! En plus, c'est un domaine qui est particulièrement riche en exemples (et puis je connais un peu mieux son histoire que celle de la santé).

Lire la suite...

SSTIC 2007 - Ou comment bourrer un amphi

Cette année, le SSTIC avait lieu à l'Université de Rennes 1 dans l'amphi Louis Antoine. Question dépaysement, j'ai vu pire... Car j'ai passé l'année dans le bâtiment d'en face. Coïncidence amusante sachant que la conférence doit normalement avoir lieu dans les locaux de l'ESAT. Mais, faute de place et voulant assurer un minimum de sécurité, un autre lieu a été choisi. A ce propos, la répartition des responsabilités a été finement choisi : l'ESAT, pour la co-organisation; Supelec, pour les repas; et l'Université pour l'infrastructure d'accueil. L'année prochaine, si nous allons prendre le pot à l'ENST et dormir à l'INSA, je crois qu'on aura presque fait le tour du campus :)

Lire la suite...

La main invisible existe !

Non pas celle d'Adam Smith, à travers laquelle le marché s'autorégulerait de manière naturelle, sans l'action de l'état. Une croyance fondatrice du monde néolibéral actuel et présente jusqu'à la tête de notre pays. Sarkozy croit en effet en l'éthique du capitalisme. Notre nouveau président espère ainsi que les patrons des grandes entreprises arrêteront, de façon volontaire, d'abuser des stock-options, de délocaliser pour maximiser les profits ou de piller les richesses naturelles.

Lire la suite...

OLPC : how about security ?

During the last week of February, I spent three days in Brussels, for the FOSDEM event. This is the biggest european meeting about free and open source software and it was the second time I went there (the first one was in 2005). The first track I had the chance to see, and not the least, was about the project One Laptop Per Child (known as OLPC). A project which has the ambition to propose a laptop for each child in the development world. The cost, 100$ per computer, would be paid by countries, societies and international organizations. A huge project in fact, because the product is not only seen as a way to make profit (for the campanies involved), but has for aim to provide a tool "desgned for learning learning". By this way, it might be able for them to get the knowledge to develop themself.

Lire la suite...

DumbSpam : a dotclear plugin to stop spam in comments

I have written a small script which try to avoid the spam in comments posted in Dotclear blogs. It uses JavaScript events to detect any human activity (move of the mouse or press of a key) and send, using AJAX, a data to the server in order to inform it that the user is human. Then, the entire form is displayed and can be submitted. If no human activity is detected, the user is considered as a bot and can't see the entire form. It can't fill all the inputs and it will be rejected automatically by the server when the submit will take place because of a lack of informations.

The way to install this script is quite simple :

  • Get the file http://www.sygus.net/atwork/dumbspam/dumbspam-1.0.zip
  • Extract it and put the file form_ajax.php in the directory in which the current theme is. For example : /dotclear/themes/currentTheme/
  • Open the file /dotclear/themes/currentTheme/post.php and replace the line which call form.php :

<?php include dirname(FILE).'/form.php'; ?>

by

<?php include dirname(FILE).'/form_ajax.php'; ?>

It should work for the new bots which try to post spam. If the bot has already come, and has saved the form's page in his memory before the installation of the script, it can go beyond this protection. In this case, another modification is needed. If the weblog is new, obviously this problem doesn't exist.

So the modification is the following : in the file form_ajax.php, replace the line :

<input name="c_nom" id="c_nom" type="text" ...

by

<input name="c_nomform" id="c_nom" type="text" ...

And in the file /dotclear/layout/prepend.php, replace the line :

$c_nom = trim($_POST'c_nom');

by

$c_nom = trim($_POST'c_nomform');

Yes, you need to modify the core of dotclear ! I don't see any other solution.

Bot detection with AJAX

A really pain aspect of managing a website is the constant influx of bots which are dedicated to spam. Even a website with low traffic can be the target of a bot, since this website is linked by another one. The result is that the comments are wasted by spam and the read of an article with its responses become awful. Moreover, the situation is getting worst because of the increase of the number of bots and the ease of use of the programs behind these bots.

Many solutions are used to fight against bots, but each one has its own advantages/disavantages and efficiency. We can make two categories : solutions that try to avoid the bot for posting (captcha audio, video and text for example), and solutions that analyze the text submitted in a form in order to find out that it wasn't written by a human (bayesian filter for example).

The solution I am currently thinking about and I have tried to implement is part of the first category. It tries to detect the presence of a bot by using AJAX and Javascript technologies. Let's try to explain how it should work : by default, when a new connection is made, it is categorized as a bot until a human event is detected. This kind of event can be a move of the mouse or a press of a key. This is detected by the JavaScript event onMouseMove and onKeyPress. If such an event is made, we categorized the connection as being performed by a human. Then, we can allow it to post a comment, to keep surfing on our website or whatever we want.

The first implementation tells us who is human or not. Bots appear in red. It works by adding a new entry in a database when a new connection is made. And when a human event occurs, it updates this entry by telling that it's not a bot. I have made another implementation in which a form appears when the user moves the mouse or presses a key. I will try to adapt this script to Dotclear in order to make an antispam.

After two days of work on this website, the first script seems to work quite good, but I wonder how it could handle a high traffic website. Finally, to be critical, we can made two objections against this solution. The first one, which actually fits many other solutions, is that it works until a bot counter attacks. How can it do that ? By simulating the move of the mouse or the press of a key. In this case, maybe we which should analyze the speed of the mouse to detect how human it is... The other objection is that if JavaScript is not activated on the client browser, then our solution is useless. But fortunately, many browsers allow JavaScript by default.

The concurrence of such a solution with text analysis could be an even better solution as it doesn't affect accessibility (the main reproach of captchas), and if Javascript is not activated on the browser, there is another filter (on the text).

I will provide the full source code soon.

How to mount a remote partition

Since I turned back on my server, I wanted to be able to mount its partitions on my laptop. I first tried nfs, but this program couldn't share each partition. Indeed, one of them was a fat32 partition and it appeared that nfs was not capable to share it. Actually, I couldn't see any files. The other problem I met with nfs is that I was not able to mount the partition through internet, in the aim to acces to my movie/music/share directory everywhere. I didn't find any solution to that, so I gave up.

After some research, I found a new way to share partition : by using a ssh filesystem. The implementation I installed is sshfs which is based on the API fuse. It can be found on the package list of Debian, or here It works very well and has the advantage to be secure because of the use of the protocole SSH. The latency is quite good and the bandwith depends naturally of the rate of the both endpoints of the connection.

Currently, I'm listening music 130km away from the server.

Let's talk french in english

During my year in Ireland, I tried to write down all the french words I could hear or read in an english context. These words could have been collected from TV programs, magazine sections or books. I found about 20 french words in the english language, but there are a lots more of course. Let's take a look at them :

  • Bouquet
  • Rendez-vous
  • Objet d'art
  • Cul-de-sac
  • Souvenir
  • Coulis
  • Coup d'état
  • Fiancé
  • Décolleté
  • Déjà-vu
  • Débat
  • Grotesque
  • Ennui
  • Camouflage
  • Espionnage
  • Réveil
  • Argot
  • Réverie
  • Gourmet
  • Promenade
  • Ballustrade
  • Soupe du jour

The funniest is Cul-de-sac which can be found on many road signs ! The first time I saw one like that, I was amazed. Coup d'état is quite surprising as well.

Trip in Donegal and Nothern Ireland

The last sunday, I made a one-day trip in the north of Ireland. We were seven to go : one spanish, one german and the rest of french. Our two cars first stopped in Londonderry, in Nothern Ireland, for the morning. Before to be there, I thought it was an ugly city because of the fight between catholic and protestant. Remember you that Londonderry is on the borderline between Ireland and Nothern Ireland (yeah like Dundalk), and this city is known to have a not so beautiful history (Bloody Sunday for example). I was therefore surprised to see a city with ramparts, gates and the town center between these ramparts seemed to be a very nice place. I was wondering why this city is sometimes called Derry and some other times called Londonderry. This is again because of the opposition between catholic and protestant. The first one call this city Derry and for the other one, it's Londonderry. But we were here at 11:00 on a sunday and everything was closed. Absolutely everything ! Impossible to find any open pub or café. Fortunately, after 20 minutes of walk, we found an hotel (4 stars hotel with limousine in front of, but not for us...) and we took a coffee. 6 pounds for seven coffee and tea, that could be worst :)

After this break, we left the Nothern Ireland and we came back in our Ireland, in the county Donegal. We made the next stop in a little beach called Inishowen Head. A lovely place, and nobody was there except us. The sun was shining and we felt a little bit warm ! We went then to the highest point of Ireland : Malin Head. A nice place with cliffs, but it began to rain and to snow. We didn't care about that and we were fighting against the strong wind. This remember me the Pointe-Du-Raz in France, in Bretagne. This is the westest place of France and there are also cliffs and strong wind and rain :) We tried to eat outside between two showers. It was a half-success because after a while, we decided to finish eating in the cars.

Then we went, with a bit of difficulty due to the bad irish roads and indications, to Grianan Aileach which is a moutains, or maybe a only bump (it's so difficult to call something a moutain when the top is only at 250 meters...), and on the top there is a stone fort. From this position, we had a pretty good vue of the surrounding landscape. But, it began again to snow and we felt awfully cold. So we came back home. We were in Dundalk at almost 21:00.

Finally it was a very nice trip. And in spite of the weather, we all enjoyed this day. But the next time, I should avoid making a party at home the day before to make a trip. Because sleeping 2 hours is not really sufficient !

Hugo Délire is back

Do you remember Hugo Délire ? It was a french emission, during the beginning of the 90's, presented by Karen Chéryl. Now, you remember ? No yet ? The aim of this game was to drive Hugo and to avoid obstacles. We could see this emssion on the third channel FR3. It was a pretty good success, and i used to watch this game a lot. But, since ten years, Hugo Délire disappeared and we didn't know what happened to him.

Now we know where he is living : on the irish channel TG4 on an emission in gaelic language for children. These are two pictures of the emission on which we can see Hugo accompanied with a strange character. I don't know who is the last character, i don't speak gaelic (not yet :-).

HugoHugo

My house in Dundalk

Today, i present you my irish house. I live in a quiet district close to the sea (ok ok, at least 3km to the sea). These are some pictures of my house.

One bedroomThe kitchenThe living room
The saloonThe entire house

There are five bedrooms, but actually only four are used. I live with one spanish (Manolo) and two germans (Mélanie and Christian). The last bedroom is used sometimes by family or friends.

Simuler une infection virale

Symantec vient de sortir un utilitaire permettant de simuler diverses infections virales, et ainsi de de voir la vitesse de propagation et d'expansion des worms. Six faux vers sont livrés avec la programme : MyDoom, Netsky, Sasser, Slammer, Blaster, et SoBig. Il est assez intéressant de voir les différentes phases de propagation et d'élimination dans le temps. Blaster semble le plus rapide en terme de propagation sur la toile. Pas étonnant lorsqu'on voit celle saloperie atterrir sur notre PC tout beau tout neuf, sans firewall car récemment acheté chez Carrefour, dès le lancement du net. En revanche Sasser à l'air d'être le virus le plus pénible à éradiquer. On comprend donc pourquoi son auteur allemand vient d'être lourdement condamné :)

http://enterprisesecurity.symantec.com/content.cfm?articleid=5479

Vous aimez les graphs ? En voici, en voilà :)

Je me suis lancé dans un script permettant de connaître tout un tas d'informations relatif à l'utilisation d'un serveur hlds (hl, cstrike and co). Pour le moment, il est possible d'obtenir un graph d'utilisation du processeur et de la mémoire. Comme pour ScanGraph, le graph obtenu est totalement paramétrable (en longueur, en largeur, en précision, etc.). Et puis, comme je suis à fond dans le perl en ce moment, les graphiques sont biensur réalisés par l'API GD de perl. Vous pouvez voir la démo ici : HLGraph en action ! (si vous voyez rien, c'est que le serveur hlds ne tourne pas ;)

Scanlan v3 + Scangraph = ?

Scanlan v3,5

Marre de MRTG, de Smokeping et autres RRDtool ?

Voici ScanGraph, un programme réalisé en perl qui permet de connaitre d'un coup d'oeil les temps de latence de certaines machines. Une démo de ScanGraph est visible. Cette page fait une simple requete sur le repertoire des images créées par le module GD de perl. Biensur ce programme n'a pas la prétention de concurrencer les outils de Tobias Oetiker, je l'ai simplement réalisé pour compléter le programme ScanLan. En effet, je préfére réaliser un programme qui gère tout lui même, plutot que de dépendre d'outils tels que Smokeping, fping, weathermap ou encore mrtg. Non pas que ces outils soient mauvais, au contraire, mais il n'est pas commode de devoir tous les installer pour profiter de ScanLan.

ScanLan v3 RC2 débarque

fluo) pour indiquer la qualité de la connexion. Le rouge indque une erreur (celle-ci s'affiche au survol de la case concernée). Et le bleu signifie que le PC ne répond pas au ping.

Il est toujours possible d'éditer les infos d'un joueur en cliquant dessus.

Les nouveautés :
- affichage d'un graph de latence des dernières heures pour chaque PC qui ping. Ainsi on peut voir si le joueur pompe beaucoup => ca se repercutera sur la courbe.
- affichage de la bande passante utilisée par les switchs + graph de bande passante.

ScanLan est maintenant basé sur Weathermap, Smokeping, la librarie GD de php et s'appuie également sur du perl pour le scan réseau.

- page 1 de 2