<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tech blog</title>
	<atom:link href="http://www.mobidyc.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mobidyc.net</link>
	<description>partage de scripts</description>
	<lastBuildDate>Mon, 23 Jan 2012 10:43:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>android connexion depuis le PC</title>
		<link>http://www.mobidyc.net/2012/01/android-connexion-depuis-le-pc/</link>
		<comments>http://www.mobidyc.net/2012/01/android-connexion-depuis-le-pc/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 10:38:55 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[adb]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=848</guid>
		<description><![CDATA[rÃ©sumÃ© des actions: 1/ activer le dÃ©bogage USB sur le terminal android 2/ crÃ©er une rÃ¨gle UDEV pour la connection avec ADB 3/ tÃ©lÃ©charger le SDK android 4/ identitifez votre device 5/ se connecter au device dÃ©tail: Pour pouvoir se connecter Ã  distance (Via un cable USB par exemple) sur un terminal Android depuis Linux. <a href='http://www.mobidyc.net/2012/01/android-connexion-depuis-le-pc/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>rÃ©sumÃ© des actions:<br />
1/ activer le dÃ©bogage USB sur le terminal android<br />
2/ crÃ©er une rÃ¨gle UDEV pour la connection avec ADB<br />
3/ tÃ©lÃ©charger le SDK android<br />
4/ identitifez votre device<br />
5/ se connecter au device</p>
<p>dÃ©tail:<br />
Pour pouvoir se connecter Ã  distance (Via un cable USB par exemple) sur un terminal Android depuis Linux. La premiÃ¨re chose Ã  faire est de modifier la rÃ¨gle de chargement du pÃ©riphÃ©rique en modifiant un paramÃ¨tre UDEV. UDEV est le daemon crÃ©ant les fichiers spÃ©ciaux de pÃ©riphÃ©riques comme /dev/sda, /dev/tty, etc&#8230;</p>
<p>tout est dynamique il n&#8217;y a donc pas grand chose Ã  faire si ce n&#8217;est de crÃ©er une rÃ¨gle dans un fichier. Vous trouverez les lignes Ã  mettre depuis <a href="http://wiki.cyanogenmod.com/wiki/Udev" target="_blank">http://wiki.cyanogenmod.com/wiki/Udev</a></p>
<pre class="brush: bash; title: ; notranslate">
$ sudo vi /etc/udev/rules.d/51-android.rules
$ cat /etc/udev/rules.d/51-android.rules
SUBSYSTEMS==&quot;usb&quot;, ATTRS{idVendor}==&quot;0bb4&quot;, ATTRS{idProduct}==&quot;0ff9&quot;, MODE=&quot;0666&quot;, GROUP=&quot;plugdev&quot; # ADB
</pre>
<p>Le terminal android lui aussi doit Ãªtre configurÃ© pour pouvoir autoriser les connexions distantes, allez dans <strong>paramÃ¨tres -> applications -> dÃ©veloppement -> cocher DÃ©bogage USB</strong></p>
<p>tÃ©lÃ©charger le SDK android : <a href="http://developer.android.com/sdk/index.html" target="_blank">http://developer.android.com/sdk/index.html</a> dÃ©compressez-le et allez dans le rÃ©pertoire tools, lancez le bianaire &laquo;&nbsp;android&nbsp;&raquo;, une fenÃªtre va s&#8217;ouvrir, sÃ©lectionner le tÃ©lÃ©chargement de ADB. Remontez d&#8217;un cran dans votre arborescence et allez dans le rÃ©pertoire platforms-tools.</p>
<p>maintenant branchez votre terminal via la connectique USB.</p>
<p>il ne reste plus qu&#8217;Ã  se connecter. identifiez votre terminal avec la commande :</p>
<pre class="brush: bash; title: ; notranslate">
$ ./adb devices
List of devices attached
HT04RG358426    device
</pre>
<p>lancez un shell sur votre terminal</p>
<pre class="brush: bash; title: ; notranslate">
$ ./adb -s HT04RG358426 shell
</pre>
<p>si votre terminal android est rootÃ©, une fois dans le shell vous pouvez taper la commande &laquo;&nbsp;su&nbsp;&raquo;, regardez ensuite l&#8217;Ã©cran du terminal pour autoriser la connection en root et voilÃ .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2012/01/android-connexion-depuis-le-pc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>migrer WordPress</title>
		<link>http://www.mobidyc.net/2011/12/migrer-wordpress/</link>
		<comments>http://www.mobidyc.net/2011/12/migrer-wordpress/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 14:58:12 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Non classÃ©]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=823</guid>
		<description><![CDATA[j&#8217;ai enfin pris le temps de migrer le portail de dÃ©veloppement. c&#8217;est du wordpress donc c&#8217;est pas forcÃ©ment intuitif, voici pour mÃ©moire la procÃ©dure Ã  suivre. au final, changement du nom de domaine et changement de rÃ©pertoire. voici la mÃ©thode utilisÃ©e. la premiÃ¨re chose Ã  faire est de copier l&#8217;arborescence de votre wordpress : ensuite <a href='http://www.mobidyc.net/2011/12/migrer-wordpress/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>j&#8217;ai enfin pris le temps de migrer le portail de dÃ©veloppement. c&#8217;est du wordpress donc c&#8217;est pas forcÃ©ment intuitif, voici pour mÃ©moire la procÃ©dure Ã  suivre. au final, changement du nom de domaine et changement de rÃ©pertoire. voici la mÃ©thode utilisÃ©e.</p>
<p>la premiÃ¨re chose Ã  faire est de copier l&#8217;arborescence de votre wordpress :</p>
<pre class="brush: bash; title: ; notranslate">
# cd /var/www/thesite
# tar cvpf â€“ . |gzip -c |(cd /var/www/newsite ; gunzip -d |tar xpf -)
</pre>
<p>ensuite on va crÃ©er une nouvelle base de donnÃ©e puis rÃ©pliquer l&#8217;ancienne dedans<br />
<span id="more-823"></span></p>
<pre class="brush: bash; title: ; notranslate">
# mysqladmin create NEW_BASE -u DBUSER --password=DBPASS
# mysqldump -u DBUSER --password=DBPASS OLD_BASE | mysql -u DBUSER --password=DBPASS -h localhost NEW_BASE
</pre>
<p>puis changer les rÃ©fÃ©rence Ã  l&#8217;ancien nom de domaine pour le nouveau</p>
<pre class="brush: bash; title: ; notranslate">
# mysql -u DBUSER -p
mysql&gt; use NEW_BASE
mysql&gt; UPDATE wp_posts SET guid = replace(guid, 'http://dev.mobidyc.net', 'http://www.mobidyc.net');
mysql&gt; UPDATE wp_posts SET post_content = replace(post_content, 'http://dev.mobidyc.net', 'http://www.mobidyc.net');
mysql&gt; UPDATE wp_anchors SET post_url = replace(post_url, 'http://dev.mobidyc.net', 'http://www.mobidyc.net');
mysql&gt; UPDATE wp_posts SET pinged = replace(pinged, 'http://dev.mobidyc.net', 'http://www.mobidyc.net');
mysql&gt; UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'http://dev.mobidyc.net', 'http://www.mobidyc.net');
mysql&gt; UPDATE wp_options SET option_value = replace(option_value, '/var/www/thesite', '/var/www/newsite');
mysql&gt; UPDATE wp_postmeta SET meta_value = replace(meta_value, '/var/www/thesite', '/var/www/newsite');
</pre>
<p>il reste Ã  modifier la configuration de wordpress (remplacez OLD_BASE et NEW_BASE par VOS valeurs)</p>
<pre class="brush: bash; title: ; notranslate">
# sed -i &quot;s@define('DB_NAME', 'OLD_BASE');@define('DB_NAME', 'NEW_BASE');@&quot; /var/www/newsite/wp-config.php
</pre>
<p>comme j&#8217;aime bien automatiser, voici un script tout fait, pensez Ã  bien</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash

# connexion Ã  mysql
USERMYSQL=adminsql
PASSWORDSQL=thepassword
HOST=localhost

# la source et destination de la base mysql
SRCSQL=SOURCE_DB_NAME
DSTSQL=DEST_DB_NAME

# la source et destination du rÃ©pertoire contenant wordpress
SRCDIR=/home/mobidyc/dev_mobidyc
DSTDIR=/home/mobidyc/www.mobidyc.net

# l'ancien et nouveau domaine
OLDFQDN=http://dev.mobidyc.net
NEWFQDN=http://www.mobidyc.net

[ -d &quot;${DSTDIR}&quot; ] &amp;&amp; {
  echo &quot;ERREUR: DESTINATION EXISTANTE&quot;
  exit 1
}

# copie du site de la source Ã  la destination
cd &quot;${SRCDIR}&quot;
tar cvpf â€“ . |gzip -c |(cd &quot;${DSTDIR}&quot; ; gunzip -d |tar xpf -)

# Creation de la nouvelle base de donnÃ©es
mysqladmin create $DESTSQL -u $USERMYSQL --password=$PASSWORDSQL

# duplication de l'ancienne base sur la nouvelle
mysqldump -u $USERMYSQL --password=$PASSWORDSQL $SRCSQL | mysql -u $USERMYSQL --password=$PASSWORDSQL -h $HOST $DSTSQL

# on modifie les valeurs rÃ©fÃ©rence de l'ancien site dans la nouvelle base de donnÃ©e (dupliquÃ©e) de wordpress
echo &quot;UPDATE wp_options SET option_value = replace(option_value, '${OLDFQDN}', '${NEWFQDN}') WHERE option_name = 'home' OR option_name = 'siteurl';&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_posts SET guid = replace(guid, '${OLDFQDN}', '${NEWFQDN}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_posts SET post_content = replace(post_content, '${OLDFQDN}', '${NEWFQDN}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_anchors SET post_url = replace(post_url, '${OLDFQDN}', '${NEWFQDN}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_posts SET pinged = replace(pinged, '${OLDFQDN}', '${NEWFQDN}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_comments SET comment_author_url = replace(comment_author_url, '${OLDFQDN}', '${NEWFQDN}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_options SET option_value = replace(option_value, '${SRCDIR}', '${DSTDIR}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL
echo &quot;UPDATE wp_postmeta SET meta_value = replace(meta_value, '${SRCDIR}', '${DSTDIR}');&quot; |mysql -u $USERMYSQL --password=$PASSWORDSQL $DSTSQL

# on dÃ©fini la nouvelle base Ã  utiliser dans la conf de wordpress
sed -i &quot;s@define('DB_NAME', '${SRCSQL}');@define('DB_NAME', '${DSTSQL}');@&quot; ${DSTDIR}/wp-config.php
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/12/migrer-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>convertir les extraits de compte de banque CIC pdf en csv</title>
		<link>http://www.mobidyc.net/2011/12/convertir-les-extraits-de-compte-de-banque-cic-pdf-en-csv/</link>
		<comments>http://www.mobidyc.net/2011/12/convertir-les-extraits-de-compte-de-banque-cic-pdf-en-csv/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 13:29:54 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Scripting and snippets]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=777</guid>
		<description><![CDATA[Il y a des fois ou on aimerait bien reprendre ses comptes en main, et analyser le tout au travers d&#8217;un tableur par exemple. je suis Ã  la banque CIC et Ã  ce titre j&#8217;ai accÃ¨s Ã  l&#8217;historique de mes comptes&#8230;en pdf. ce qui n&#8217;est pas forcÃ©ment le meilleur format Ã  insÃ©rer dans un tableur. <a href='http://www.mobidyc.net/2011/12/convertir-les-extraits-de-compte-de-banque-cic-pdf-en-csv/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Il y a des fois ou on aimerait bien reprendre ses comptes en main, et analyser le tout au travers d&#8217;un tableur par exemple.</p>
<p>je suis Ã  la banque CIC et Ã  ce titre j&#8217;ai accÃ¨s Ã  l&#8217;historique de mes comptes&#8230;en pdf.<br />
ce qui n&#8217;est pas forcÃ©ment le meilleur format Ã  insÃ©rer dans un tableur. voici une mÃ©thode pour convertir ces fichiers PDF en CSV, importables dans n&#8217;importe quel tableur.</p>
<p>premiÃ¨rement, installer pdftohtml, il existe des versions pour Windows ou Linux.<br />
deuxiÃ¨mement, tÃ©lÃ©charger les fichiers PDF contenant vos extraits de compte. Je vous conseille retirer les espaces dans le nom des fichiers afin de pouvoir les traiter plus facilement.<br />
<span id="more-777"></span><br />
pour convertir en html (Ã©tape nÃ©cessaire), on va lancer la commande suivante :</p>
<pre class="brush: bash; title: ; notranslate">
$ for i in *.pdf
do
pdftohtml.exe -c -i -noframes $i ${i}.html
done
</pre>
<p>sous windows, la commande est :</p>
<pre class="brush: bash; title: ; notranslate">
FOR /F &quot;tokens=*&quot; %G IN ('dir /b *.pdf') DO pdftohtml.exe -c -i -noframes &quot;%G&quot; &quot;%G.html&quot;
</pre>
<p>ensuite, on va convertir les fichiers HTML en CSV grÃ¢ce au script suivant</p>
<pre class="brush: bash; collapse: true; light: false; title: ; toolbar: true; notranslate">
#!/bin/bash

account=$1
shift 1

solde=&quot;0&quot;
thestart=&quot;CONTRAT PERSONNEL GLOBAL N.* ${account} en euros&quot;
end=&quot;&lt;b&gt;SOLDE&quot;

nbdate=0
linenbr=1
date1=
date2=
tmpone=tmp_1
tmptwo=tmp_2

function csvout () {
	# Important : this test must done first in this function
	if [ -z &quot;$fnbline&quot; ] ;then
		refsolde=$solde
	else
		refsolde=&quot;F${fnbline}&quot;
	fi

	fdate=&quot;$1&quot;
	fdateval=&quot;$2&quot;
	flibelle=&quot;$(echo &quot;$3&quot; |sed -e 's/[ ]*[ ]/ /g' -e 's/^[ ]*[ ]//' -e 's/&amp;quot;//g' -e 's/&amp;nbsp;//g' -e 's/;/,/g')&quot;
	flibelle2=&quot;$(echo &quot;$flibelle&quot; |sed -e 's/^PAIEMENT CB [0-9][0-9][0-9][0-9] //' -e 's/ CARTE [0-9]*[0-9]$//')&quot;
	fdebit=&quot;$(echo &quot;$4&quot; |sed 's/\.//g')&quot;
	fcredit=&quot;$(echo &quot;$5&quot; |sed 's/\.//g')&quot;
	fnbline=&quot;$6&quot;

	fsolde=&quot;=SOMME(${refsolde}+G${fnbline})&quot;
	fdiff=&quot;=SOMME(E${fnbline}-D${fnbline})&quot;
	echo &quot;${fdate};${fdateval};${flibelle2};${fdebit};${fcredit};${fsolde};${fdiff};${flibelle};&quot;
}

# header
echo &quot;Date;Date de valeur;Libelles;Debits;Credits;Solde;Differentiel;Full libelle;Categorie;&quot;

while [ &quot;${#}&quot; -ne &quot;0&quot; ]
do
	src=&quot;$1&quot;
	shift

	awk &quot;/${thestart}/,/${end}/&quot; &quot;$src&quot; | \
	sed 's/&lt;DIV style=&quot;position:absolute;top:[0-9]*[0-9];left://g' &gt; $tmpone

	# class name identification for interesting datas
	classname=&quot;$(egrep &quot;\&quot;&gt;[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]&lt;/span&gt;&quot; $tmpone |tail -1 |cut -d'&quot;' -f3)&quot;

	grep &quot;&lt;span class=\&quot;${classname}\&quot;&gt;&quot; $tmpone |\
	sed &quot;s/\&quot;&gt;&lt;nobr&gt;&lt;span class=\&quot;${classname}\&quot;&gt;/:/g&quot; |\
	sed 's@&lt;/span&gt;&lt;/nobr&gt;&lt;/DIV&gt;.*@@' &gt; $tmptwo

	while read theline
	do
		decalage=$(echo &quot;$theline&quot; |cut -d: -f1)
		contents=$(echo &quot;$theline&quot; |cut -d: -f2-)

		# date traitment
		if [ &quot;$(echo &quot;$contents&quot; |grep -c &quot;^[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]$&quot;)&quot; -ge &quot;1&quot; ]; then
			case $nbdate
			in
				0) # If nbdate is 0, we are in the start of datas
					nbdate=1

					# If date2 is set, we just are in a new line of datas, If not, it is the first line we work on in this script
					[ -n &quot;$date2&quot; ] &amp;&amp; csvout &quot;$date1&quot; &quot;$date2&quot; &quot;$data&quot; &quot;$debit&quot; &quot;$credit&quot; &quot;$linenbr&quot;

					linenbr=$(( $linenbr + 1 ))
					date1=&quot;$contents&quot;
					data=
					;;
				1) nbdate=0
					date2=&quot;$contents&quot;
				;;
			esac
		# label traitment
		elif [ &quot;$(echo &quot;$contents&quot; |egrep -c &quot;[- a-zA-Z]|^[0-9]*[0-9]$&quot;)&quot; -ge &quot;1&quot; ]; then
			[ -n &quot;$(echo &quot;$contents&quot; |grep &quot;^RÃ©f : [0-9]*[0-9]$&quot;)&quot; ] &amp;&amp; continue
			data=&quot;$data $contents&quot;
		# amount traitment
		else
			debit=
			credit=

			if [ &quot;$decalage&quot; -lt &quot;700&quot; ]; then
				debit=$contents
			else
				credit=$contents
			fi
		fi
	done &lt; $tmptwo
done

# flush of the last datas
csvout &quot;$date1&quot; &quot;$date2&quot; &quot;$data&quot; &quot;$debit&quot; &quot;$credit&quot; &quot;$linenbr&quot;

# cleaning
rm $tmptwo
rm $tmpone
</pre>
<p>Pour le lancer rien de plus simple, il vous faudra juste votre numÃ©ro de compte Ã  mettre en argument Ã©tant donnÃ©e qu&#8217;un extrait de compte peut contenir plusieurs de vos comptes, il faut bien les dÃ©limiter.<br />
vous trouverez votre numÃ©ro de compte dans le fichier PDF d&#8217;origine.<br />
exemple d&#8217;utilisation : </p>
<pre class="brush: bash; title: ; notranslate">$ ./convert.sh 00030051808 *.html |tee converted.csv</pre>
<p>vous noterez que le script prÃ©pare dÃ©jÃ  les donnÃ©es pour une insertion dans un tableur en calculant les diffÃ©rents champs Solde et DiffÃ©rentiel. facile ensuite d&#8217;utiliser l&#8217;outil groupe de pilote (LibreOffice) ou rapport de donnÃ©es croisÃ©es dynamique (Microsoft Office) pour gÃ©nÃ©rer des rapports complets ou mÃªme encore des graphiques toujours trÃ¨s parlant.</p>
<p>conseil: prenez le solde du premier fichier PDF que vous convertissez et intÃ©grez le dans le script en remplaÃ§ant la variable &laquo;&nbsp;solde&nbsp;&raquo;</p>
<p>PS: ce script est loin d&#8217;Ãªtre parfait mais il fonctionne chez moi, pour mon besoin.<br />
il se peut que vous ayez un problÃ¨me de reconnaissance du champs contenant la somme dÃ©bitÃ©e ou crÃ©ditÃ©e car au dÃ©but, j&#8217;ai trouvÃ© plus simple d&#8217;identifier ce champs par son contenu, mais il serait plus avisÃ© peut Ãªtre de calculer ce champs par rapport Ã  son emplacement (valeur de left: dans la ligne).<br />
au pire, si Ã§a ne fonctionne pas chez vous, laissez un petit message pour que je corrige ce qui ne va pas.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/12/convertir-les-extraits-de-compte-de-banque-cic-pdf-en-csv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>optimiser son raid5</title>
		<link>http://www.mobidyc.net/2011/12/optimiser-son-raid5/</link>
		<comments>http://www.mobidyc.net/2011/12/optimiser-son-raid5/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 10:54:58 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Operating System]]></category>
		<category><![CDATA[Scripting and snippets]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ext]]></category>
		<category><![CDATA[fs]]></category>
		<category><![CDATA[hdd]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[perf]]></category>
		<category><![CDATA[raid]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=799</guid>
		<description><![CDATA[raid5 optimisÃ©, au final, j&#8217;ai multipliÃ© par 4 les performances initales. maintenant, la copie d&#8217;un gros fichier depuis et vers le mÃªme filesystÃ¨me se fait Ã  environ 85Mo/s. la lecture d&#8217;un fichier se fait environ Ã  1Go/s l&#8217;Ã©criture environ Ã  190Mo/s pour tous les dÃ©tails c&#8217;est Ã  la page perfs x4 â€“ optimisation dâ€™un raid5 <a href='http://www.mobidyc.net/2011/12/optimiser-son-raid5/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>raid5 optimisÃ©, au final, j&#8217;ai multipliÃ© par 4 les performances initales.</p>
<p>maintenant,<br />
la copie d&#8217;un gros fichier depuis et vers le mÃªme filesystÃ¨me se fait Ã  environ 85Mo/s.<br />
la lecture d&#8217;un fichier se fait environ Ã  1Go/s<br />
l&#8217;Ã©criture environ Ã  190Mo/s</p>
<p>pour tous les dÃ©tails c&#8217;est Ã  la page <a href="http://www.mobidyc.net/perfs-x4-optimisation-dun-raid5-par-la-pratique-2/" title="perfs x4 â€“ optimisation dâ€™un raid5 par la pratique">perfs x4 â€“ optimisation dâ€™un raid5 par la pratique</a></p>
<p>vous y trouverez un rÃ©sumÃ© condensÃ© des diffÃ©rentes optimisations, toutes les modifications effectuÃ©es, des scripts de stress et de test et aussi le dÃ©tail trÃ¨s technique de toutes les opÃ©rations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/12/optimiser-son-raid5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nombre de CPU physique et logique</title>
		<link>http://www.mobidyc.net/2011/12/nombre-de-cpu-physique-et-logique/</link>
		<comments>http://www.mobidyc.net/2011/12/nombre-de-cpu-physique-et-logique/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 09:39:21 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[core]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[hpasm]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[thread]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=786</guid>
		<description><![CDATA[Pour voir le nombre de CPU logique : le nombre de CPU physique : nombre de core par CPU : sous redhat, on a les outils proliant qui peuvent nous donner quelques infos supplÃ©mentaire: d&#8217;aileurs, pour encore plus d&#8217;infos avec cet outil:]]></description>
			<content:encoded><![CDATA[<p>Pour voir le nombre de CPU logique :</p>
<pre class="brush: bash; title: ; notranslate">$ grep -c &quot;processor&quot; /proc/cpuinfo
16
</pre>
<p>le nombre de CPU physique :</p>
<pre class="brush: bash; title: ; notranslate">$ grep &quot;physical id&quot; /proc/cpuinfo |sort -u |wc -l
2
</pre>
<p>nombre de core par CPU :<br />
<span id="more-786"></span></p>
<pre class="brush: bash; title: ; notranslate">$ echo &quot;$(grep -c &quot;processor&quot; /proc/cpuinfo) / $(grep &quot;physical id&quot; /proc/cpuinfo |sort -u |wc -l)&quot; | bc
8
</pre>
<p>sous redhat, on a les outils proliant qui peuvent nous donner quelques infos supplÃ©mentaire:</p>
<pre class="brush: bash; title: ; notranslate">$ hpasmcli -s &quot;show ht&quot;

Processor hyper-threading is currently enabled.
</pre>
<p>d&#8217;aileurs,<br />
pour encore plus d&#8217;infos avec cet outil:</p>
<pre class="brush: bash; title: ; notranslate">
# hpasmcli -s &quot;show server&quot;

System        : ProLiant BL620c G7
Serial No.    : *********
ROM version   : I25 12/02/2010
iLo present   : Yes
Embedded NICs : 8
        NIC1 MAC: xx:xx:xx:xx:xx:xx
        NIC2 MAC: xx:xx:xx:xx:xx:xx
        NIC3 MAC: xx:xx:xx:xx:xx:xx
        NIC4 MAC: xx:xx:xx:xx:xx:xx
        NIC5 MAC: xx:xx:xx:xx:xx:xx
        NIC6 MAC: xx:xx:xx:xx:xx:xx
        NIC7 MAC: xx:xx:xx:xx:xx:xx
        NIC8 MAC: xx:xx:xx:xx:xx:xx

Processor: 0
        Name         : Intel Xeon MP
        Stepping     : 6
        Speed        : 2267 MHz
        Bus          : 133 MHz
        Core         : 8
        Thread       : 16
        Socket       : 1
        Level2 Cache : 2048 KBytes
        Level3 Cache : 24576 KBytes
        Status       : Ok

Processor: 1
        Name         : Intel Xeon MP
        Stepping     : 6
        Speed        : 2267 MHz
        Bus          : 133 MHz
        Core         : 8
        Thread       : 16
        Socket       : 2
        Level2 Cache : 2048 KBytes
        Level3 Cache : 24576 KBytes
        Status       : Ok

Processor total  : 2

Memory installed : 131072 MBytes
ECC supported    : Yes
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/12/nombre-de-cpu-physique-et-logique/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>choix de l&#8217;outil de compression</title>
		<link>http://www.mobidyc.net/2011/11/choix-de-loutil-de-compression/</link>
		<comments>http://www.mobidyc.net/2011/11/choix-de-loutil-de-compression/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 12:13:12 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[7zip]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=770</guid>
		<description><![CDATA[selon les donnÃ©es Ã  sauvegarder/archiver, il ne faut pas se jeter sur le premier outil de compression qui nous vient en tÃªte. voici un exemple concret concernant une sauvegarde mysql, vous serez tous d&#8217;accord avec moi pour dire que ce n&#8217;est finalement que du texte: l&#8217;algorithme utilisÃ© par 7z Ã  un rendu bien plus performant <a href='http://www.mobidyc.net/2011/11/choix-de-loutil-de-compression/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>selon les donnÃ©es Ã  sauvegarder/archiver, il ne faut pas se jeter sur le premier outil de compression qui nous vient en tÃªte.</p>
<p>voici un exemple concret concernant une sauvegarde mysql, vous serez tous d&#8217;accord avec moi pour dire que ce n&#8217;est finalement que du texte:</p>
<pre class="brush: bash; title: ; notranslate">
$ ls -lh backup.sql*
-rw-r--r-- 1 root root  25M 2011-11-30 13:03 backup.sql
-rw-r--r-- 1 root root 6,7M 2011-11-30 13:04 backup.sql.gz
-rw-r--r-- 1 root root 1,8M 2011-11-30 13:05 backup.sql.7z
</pre>
<p><span id="more-770"></span><br />
l&#8217;algorithme utilisÃ© par 7z Ã  un rendu bien plus performant sur des fichiers texte que la plupart des autres outils de compression, par contre, c&#8217;est un peu plus gourmand en cpu que gzip (je prend gzip en exemple car c&#8217;est celui que j&#8217;utilise le plus souvent).<br />
ceci dit, la diffÃ©rence est tellement Ã©norme que Ã§a vaut clairement le coup.</p>
<p>ATTENTION: 7-zip ne sait pas gÃ©rer les appartenances ou mÃªme les droits d&#8217;accÃ¨s Ã  un fichier, ne l&#8217;utilisez donc pas Ã  des fins de sauvegarde systÃ¨me, pas directement en tout cas.<br />
dans ce cas, prÃ©fÃ©rer une premiÃ¨re passe avec l&#8217;outil tar.</p>
<pre class="brush: bash; title: ; notranslate">cd dir_to_backup ; tar cvpf - . |p7zip -c &gt; /backups/mybackup.tar.7z</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/11/choix-de-loutil-de-compression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VxFS Fragmentation</title>
		<link>http://www.mobidyc.net/2011/10/vxfs-fragmentation/</link>
		<comments>http://www.mobidyc.net/2011/10/vxfs-fragmentation/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 09:30:34 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[HP-UX]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[fragmentation]]></category>
		<category><![CDATA[fs]]></category>
		<category><![CDATA[fsadm]]></category>
		<category><![CDATA[VxFS]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=561</guid>
		<description><![CDATA[We had performance issues on our NFS servers, very poor performances. after analyze we have seen that the bottleneck came from the disks, as always; but tuning the FS did not solve the problem. I talk about 1500 NFS mountpoint (running on 9 nodes from ServiceGuard cluster solution) as in my actual mission, everything works <a href='http://www.mobidyc.net/2011/10/vxfs-fragmentation/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>We had performance issues on our NFS servers, very poor performances.<br />
after analyze we have seen that the bottleneck came from the disks, as always;<br />
but tuning the FS did not solve the problem.</p>
<p>I talk about 1500 NFS mountpoint (running on 9 nodes from ServiceGuard cluster solution) as in my actual mission, everything works through NFS.<br />
The homedir of course but also the applications, the logs, libraries etc&#8230;<br />
<span id="more-561"></span><br />
so, i&#8217;ve wrote a script to obtain the fragmentation state of all VxFS filesystem on HP-UX.<br />
this script runs every weeks, send a mail with a high importance when fragmentation is detected, and indicates what to do to reduce the fragmentation.</p>
<p>here is the script:</p>
<div class="download">Download : <a href="http://www.mobidyc.net/wp-content/uploads/2011/10/fragmentation_vxfs_en1.sh">fragmentation_vxfs_en1.sh</a>
<pre class="brush: bash; collapse: true; light: false; title: ++ Voir le code; toolbar: true; notranslate">#! /bin/ksh
#
# vim:tabstop=3:syntax=sh:
#
# ---------
## Script  : fragmentation_vxfs.sh
## Objet   : envoie un rapport de fragmentation VXFS si besoin
##----------------------------------------------------------------------------
# 0.1 31-jul-09 - Cedrick Gaillard
# 1.1 01-sep-09 - plus d'analyse sur /tmp
#               - plus d'analyse sur les FS utilises a 5% ou moins
#               - cree le repertoire $MOUNTPOINT/lost+found pour le lock fsadm
#                 si besoin.
#               - les commandes a lancer pour defragmenter accompagnent
#                 maintenant les rapports.
#               - si plusieurs FS sont a defragmenter, une liste avec toutes
#                 les commandes a lancer est affichee en premier, suivi du
#                 detail.
#               - on peut maintenant s'envoyer un mail de rapport au lieu de
#                 l'envoyer a tout le monde.
#               - reecrit plus proprement.
# 1.2 16-sep-09 - utilise bdfa si bdf.pl sort en erreur
#               - un seul bdf.pl/bdfa est lance maintenant
#               - n'analyse plus les FS utilises &lt;= 15% d'utilisation
#               - leger changement sur l'output.
#               - n'analyse plus /tmp
# 1.5 24-sep-09 - gestion de seuils warnings et critiques.
#               - reecriture d'un partie du script awk.
# 1.6 20-oct-09 - on peut specifier des FS a analyser au lieu de tout analyser
# 1.7 03-nov-09 - correction du test de selection de l'importance des mails
#               - correction du test du % d'utilisation du FS.
# 1.8 12-avr-10 - affiche l'etat de fragmentation mme quand le FS n'est pas
#                 fragmente.
#               - legere modification du message de resume.
# 1.9 30-avr-10 - ajout de quelques commentaires.
#               - n'affiche plus que les fs a defragmenter dans le resume des
#                 commande a lancer.
#               - n'affiche plus les rapports, seulement les status.
#
#-----------------------------------------------------------------------------

SERVER_NAME=$(uname -n)
DEFRAG_COMMAND=&quot;/usr/sbin/fsadm -F vxfs -DEde -s&quot;

TMPFILE=&quot;/var/tmp/${0##*/}.VARS.$$&quot;

EXPEDITEUR=&quot;FRAGMENTATION REPORT&lt;root@$(hostname)&gt;&quot;
DESTINATAIRE=&quot;Operator&lt;operator@example.com&gt;&quot;
IMPORTANCE=&quot;Low&quot;

# Keep it to '0', It will be automatically set to '1' if a FS needs to be defragmented.
SEND=0

# css decoration
CSS='&lt;style type=&quot;text/css&quot;&gt;
	&lt;!--
	body { font-family:&quot;Courier New&quot;,Courier,sans-serif; font-size:8pt; }
	h1   { font-size:12pt; color:darkblue; }
	.Rouge { color:#FF0000; font-weight: bold }
	.Orang { color:#FF8C00; font-weight: bold }
	.Verte { color:#00CC00; }
	--&gt;
	&lt;/style&gt;
'

# arguments
while [ &quot;$#&quot; -ne &quot;0&quot; ]
do
	case $1
	in
		-mail) [ -n &quot;$2&quot; ] &amp;&amp; {
					DESTINATAIRE=&quot;$2&quot;
					shift 1
				}
				shift 1
				;;
		-v)	# Permits to show status event if there is no fragmentation.
				VERBOSE=true
				shift 1
				;;
		*)		FS_TO_ANALYZE=&quot;$FS_TO_ANALYZE $1&quot;
				shift 1
				;;
	esac
done

[ -x &quot;/usr/bin/perl&quot; ] &amp;&amp; BDF=&quot;$(/usr/local/bin/bdf.pl -t vxfs 2&gt;/dev/null |grep -v interpreter)&quot;
[ &quot;$?&quot; = &quot;0&quot; ] || BDF=&quot;$(/usr/local/bin/bdfa -t vxfs 2&gt;/dev/null)&quot;
[ &quot;$?&quot; = &quot;0&quot; ] || BDF=
BDF_HEAD=&quot;$(echo &quot;${BDF}&quot; |head -1)&quot;

if [ -n &quot;$FS_TO_ANALYZE&quot; ]
	then
		MOUNTPOINTS=&quot;$(bdf $FS_TO_ANALYZE |tail +2 |awk '{print $NF}')&quot;
	else
		MOUNTPOINTS=&quot;$(grep &quot; vxfs &quot; /etc/mnttab |cut -d&quot; &quot; -f 2)&quot;
fi

# grep &quot; vxfs &quot; /etc/mnttab |cut -d&quot; &quot; -f 2 |while read MOUNTPOINT
for MOUNTPOINT in $MOUNTPOINTS
do
	[ -d &quot;${MOUNTPOINT}/lost+found&quot; ] || mkdir &quot;${MOUNTPOINT}/lost+found&quot;
	chown 0:0 &quot;${MOUNTPOINT}/lost+found&quot;
	chmod 0700 &quot;${MOUNTPOINT}/lost+found&quot;
	[ &quot;$MOUNTPOINT&quot; = &quot;/tmp&quot; ] &amp;&amp; continue

	[ &quot;$BDF&quot; != &quot;&quot; ] &amp;&amp; {
	# We do not analyze FS used less than 15%
			[ &quot;$(echo &quot;$BDF&quot; |awk '{print $5 &quot; &quot; $10}' | grep &quot; ${MOUNTPOINT}$&quot; |cut -d'%' -f1)&quot; -le &quot;15&quot; ] &amp;&amp; continue
	}

	# raw state of the fragmentation
	FRAGMENTATION=&quot;$(/usr/sbin/fsadm -F vxfs -E $MOUNTPOINT)&quot;
	[ &quot;$?&quot; = &quot;0&quot; ] || {
		echo &quot;ERROR: wannot analyze the mountpoint: $MOUNTPOINT&quot;
		continue
	}

	# stack states by category
	unset ACTUAL_SMALL64 ACTUAL_SMALL8 ACTUAL_BLOCKS64
	ACTUAL_SMALL64=&quot;$( echo &quot;${FRAGMENTATION}&quot; |fgrep &quot;% Free blocks in extents smaller than 64 blks:&quot; |awk '{print $NF}')&quot;
	ACTUAL_SMALL8=&quot;$(  echo &quot;${FRAGMENTATION}&quot; |fgrep &quot;% Free blocks in extents smaller than  8 blks:&quot; |awk '{print $NF}')&quot;
	ACTUAL_BLOCKS64=&quot;$(echo &quot;${FRAGMENTATION}&quot; |fgrep &quot;% blks allocated to extents 64 blks or larger:&quot; |awk '{print $NF}')&quot;

	[ -z &quot;$ACTUAL_SMALL64&quot; -o -z &quot;$ACTUAL_SMALL8&quot; -o -z &quot;$ACTUAL_BLOCKS64&quot; ] &amp;&amp; {
		echo &quot;ERROR: at least one of the values is empty concerning the mountpoint: $MOUNTPOINT&quot;
		continue
	}

	STATUS=$(echo $ACTUAL_SMALL64 $ACTUAL_SMALL8 $ACTUAL_BLOCKS64 |awk 'BEGIN { RVAL=0 } {
		CRIT_SMALL64=70  ; WARN_SMALL64=50 ;
		CRIT_SMALL8=15   ; WARN_SMALL8=5 ;
		CRIT_BLOCKS64=4 ; WARN_BLOCKS64=6 ;

		ROUGE = &quot;&lt;span class=\&quot;Rouge\&quot;&gt;CRIT&quot; ;
		ORANG = &quot;&lt;span class=\&quot;Orang\&quot;&gt;WARN&quot; ;
		VERTE = &quot;&lt;span class=\&quot;Verte\&quot;&gt;GOOD&quot; ;

		MSG = sprintf(&quot;--&gt; %% Free blocks in extents smaller than 64 blks : %5.2f%%&lt;/span&gt;&quot;, $1) ;
		SEUIL = sprintf(&quot;&lt;span&gt;- WARN if &amp;gt;%s%% / CRIT if &amp;gt;%s%%&lt;/span&gt;&quot;, WARN_SMALL64, CRIT_SMALL64) ;
		if( $1 &gt; CRIT_SMALL64 ) {
			printf(&quot;%s %s %s\n&quot;, ROUGE, MSG, SEUIL ) ; RVAL=2 ;
		} else if ( $1 &gt; WARN_SMALL64 ) {
			printf(&quot;%s %s %s\n&quot;, ORANG, MSG, SEUIL ) ; RVAL=1 ;
		} else {
			printf(&quot;%s %s\n&quot;, VERTE, MSG ) ;
		}

		MSG = sprintf(&quot;--&gt; %% Free blocks in extents smaller than  8 blks : %5.2f%%&lt;/span&gt;&quot;, $2) ;
		SEUIL = sprintf(&quot;&lt;span&gt;- WARN if &amp;gt;%s%% / CRIT IF &amp;gt;%s%%&lt;/span&gt;&quot;, WARN_SMALL8, CRIT_SMALL8) ;
		if( $2 &gt; CRIT_SMALL8 ) {
			printf(&quot;%s %s %s\n&quot;, ROUGE, MSG, SEUIL ) ; RVAL = 2 ;
		} else if( $2 &gt; WARN_SMALL8 ) {
			printf(&quot;%s %s %s\n&quot;, ORANG, MSG, SEUIL ) ; RVAL = 1 ;
		} else {
			printf(&quot;%s %s\n&quot;, VERTE, MSG ) ;
		}

		MSG = sprintf(&quot;--&gt; %% blks allocated to extents 64 blks or larger : %5.2f%%&lt;/span&gt;&quot;, $3) ;
		SEUIL = sprintf(&quot;&lt;span&gt;- WARN if &amp;lt;%s%% / CRIT if &amp;lt;%s%%&lt;/span&gt;&quot;, WARN_BLOCKS64, CRIT_BLOCKS64) ;
		if( $3 &lt; CRIT_BLOCKS64 ) {
			printf(&quot;%s %s %s\n&quot;, ROUGE, MSG, SEUIL ) ; RVAL = 2 ;
		} else if( $3 &lt; WARN_BLOCKS64 ) {
			printf(&quot;%s %s %s\n&quot;, ORANG, MSG, SEUIL ) ; RVAL = 1 ;
		} else {
			printf(&quot;%s %s\n&quot;, VERTE, MSG ) ;
		}
	} END { exit RVAL ; }')

	RVAL=$?
	[ &quot;$RVAL&quot; -ne &quot;0&quot; ] &amp;&amp; {
		SEND=1
		if [ &quot;$RVAL&quot; -eq &quot;1&quot; -a &quot;$IMPORTANCE&quot; != &quot;High&quot; ]
			then
				IMPORTANCE=&quot;Normal&quot;
			else
				IMPORTANCE=&quot;High&quot;
		fi
	}

	if [ &quot;$BDF&quot; != &quot;&quot; ]
		then
			REPORT_BDF=&quot;${BDF_HEAD}&lt;br/&gt;$(echo &quot;${BDF}&quot; |awk -v M=${MOUNTPOINT} '{if($NF == M){print $0; break}else{next;}}')&quot;
		else
			REPORT_BDF=
	fi

	CONTENT=&quot;${CONTENT}
		&lt;hr/&gt;
		&lt;h1&gt;Fragmentation information on the mountpoint:&lt;/h1&gt;
		&lt;pre&gt;${REPORT_BDF}&lt;/pre&gt;&quot;
	[ &quot;$RVAL&quot; -ne &quot;0&quot; -o &quot;$VERBOSE&quot; = &quot;true&quot; ] &amp;&amp; {
		CONTENT=&quot;${CONTENT}&lt;pre&gt;$STATUS&lt;/pre&gt;&quot;
	}
#	[ &quot;$RVAL&quot; -ne &quot;0&quot; ] &amp;&amp; {
#		CONTENT=&quot;${CONTENT}
#			&lt;p&gt;lancer la commande suivante pour défragmenter si besoin:&lt;br/&gt;
#			${DEFRAG_COMMAND} $MOUNTPOINT
#			&lt;/p&gt;&quot;
#	}
#	[ &quot;$RVAL&quot; -ne &quot;0&quot; -o $VERBOSE = &quot;true&quot; ] &amp;&amp; {
#		CONTENT=&quot;${CONTENT}
#			&lt;h2&gt;STATUS:&lt;/h2&gt;
#			&lt;pre&gt;$STATUS&lt;/pre&gt;&quot;
#	}
#	[ &quot;$RVAL&quot; -ne &quot;0&quot; ] &amp;&amp; {
#		CONTENT=&quot;${CONTENT}
#			&lt;h2&gt;RAPPORT:&lt;/h2&gt;
#			&lt;pre&gt;$FRAGMENTATION&lt;/pre&gt;&quot;
#	}
done

# En tete
echo &quot;From: ${EXPEDITEUR}
To: ${DESTINATAIRE}
Importance: ${IMPORTANCE}
Subject:[${SERVER_NAME}] Fragmentation report
Content-Type: text/html
&lt;html&gt;&lt;head&gt;${CSS}&lt;/head&gt;&lt;body&gt;&quot; &gt; $TMPFILE

if [ &quot;$SEND&quot; = &quot;1&quot; -o &quot;$VERBOSE&quot; = &quot;true&quot; ]
	then
		# If more than one FS, commands on the header
		[ &quot;$(echo &quot;${CONTENT}&quot; |grep -c &quot;${DEFRAG_COMMAND} &quot;)&quot; -gt &quot;1&quot; ] &amp;&amp; {
		echo &quot;&lt;h1&gt; INFO: Fragmentation detected on more than one FS&lt;/h1&gt;&lt;p&gt;please run the following commands to optimize files access&lt;ul&gt;&quot; &gt;&gt; $TMPFILE
			echo &quot;${CONTENT}&quot; |grep &quot;${DEFRAG_COMMAND} &quot; |sed -e &quot;s/	//g&quot; -e &quot;s/^/&lt;li&gt;/&quot; -e &quot;s/$/&lt;\/li&gt;/&quot; &gt;&gt; $TMPFILE
			echo &quot;&lt;/ul&gt;&lt;/p&gt;&quot; &gt;&gt; $TMPFILE
		}

		FS_TO_ANALYZE=$(echo &quot;${CONTENT}&quot; |grep &quot;${DEFRAG_COMMAND} &quot; |awk '{printf $NF &quot; &quot;}')

		echo &quot;&lt;p&gt;The following command will permit you to verify the fragmentation state: &lt;br/&gt;
				$0 -v -mail $DESTINATAIRE $FS_TO_ANALYZE&lt;/p&gt;
				&lt;p&gt;d&amp;eacute;tails:&lt;/p&gt;&quot; &gt;&gt; $TMPFILE

		echo &quot;${CONTENT}&quot; &gt;&gt; $TMPFILE
	else
		/bin/rm -f $TMPFILE
		exit 0
fi

# footer
echo &quot;&lt;p&gt;Script: $0&lt;/p&gt; &lt;/body&gt;&lt;/html&gt;&quot; &gt;&gt; $TMPFILE

cat $TMPFILE |sendmail -t

/bin/rm -f $TMPFILE
</pre>
</div>
<p>and an example of the output:<br />
<a href="http://www.mobidyc.net/wp-content/uploads/2011/10/frg_scr.jpg"><img src="http://www.mobidyc.net/wp-content/uploads/2011/10/frg_scr-300x85.jpg" alt="" title="frg_scr" width="300" height="85" class="alignnone size-medium wp-image-563" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/10/vxfs-fragmentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>set a quota</title>
		<link>http://www.mobidyc.net/2011/10/set-a-quota/</link>
		<comments>http://www.mobidyc.net/2011/10/set-a-quota/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 15:37:46 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[HP-UX]]></category>
		<category><![CDATA[Scripting and snippets]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[edquota]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[quota]]></category>
		<category><![CDATA[quotaset]]></category>
		<category><![CDATA[setquota]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=554</guid>
		<description><![CDATA[Hi gents, after searching a script to massive set quota for users on HP-UX, i&#8217;ve found nothing, only people asking how to do it. of course you have the &#8216;edquota&#8217; command, which can copy a user&#8217;s quota template into another account, but this is not the best way. so, i&#8217;ve wrote a little script to <a href='http://www.mobidyc.net/2011/10/set-a-quota/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Hi gents,</p>
<p>after searching a script to massive set quota for users on HP-UX, i&#8217;ve found nothing, only people asking how to do it.<br />
of course you have the &#8216;edquota&#8217; command, which can copy a user&#8217;s quota template into another account, but this is not the best way.</p>
<p>so, i&#8217;ve wrote a little script to do the job, for all my NFS users.</p>
<p>this script will definitively not fit for an other person than me and my needs, but I think it can be a good basis.<br />
<span id="more-554"></span><br />
As usually, if you need a specific version to fit your needs, and you d&#8217;ont know how to do it, I can help.</p>
<div class="download">Download : <a href="http://www.mobidyc.net/wp-content/uploads/2011/10/quotasets.sh">quotasets.sh</a>
<pre class="brush: bash; collapse: true; light: false; title: ++ Voir le code; toolbar: true; notranslate">#!/bin/ksh -a

# MUST BE RUN FROM THE MOUNTROOT OF THE FS
# for example : from /nfsint1/export02

# USERS must be in the subdirectory users
# for example : /nfsint1/export02/users

V_TEMPFILE=/tmp/quotaset

DEFS_QUOTA=50000
DEFH_QUOTA=55000
DEFS_INODE=5000
DEFH_INODE=5500
V_DATE=$(date +&quot;%d-%m-%Y_%Hh%Mm%S&quot;)

if [ -f &quot;$1&quot; ]
	then
		# Important
		cp /dev/null ${V_TEMPFILE}

		function fct_quotaset {
			echo &quot;INFO: working on user $u_user&quot;

			while read a FS b c d SQ e f HQ g h i SI j k HI
			do
				[ &quot;$FS&quot; != &quot;$(pwd)&quot; ] &amp;&amp; {
					echo &quot;$a $FS $b $c $d $SQ $e $f $HQ $g $h $i $SI $j $k $HI&quot; &gt;&gt;${V_TEMPFILE}
					continue
				}

				softquota=$(echo $SQ |cut -d&quot;,&quot; -f1)
				if [ &quot;$softquota&quot; = &quot;0&quot; ]
					then
						realuse=$(du -ks users/${u_user} |awk '{print $1}')
						if [ &quot;$realuse&quot; -le &quot;$DEFS_QUOTA&quot; ]
							then
								echo &quot;INFO: ${u_user} uses ${realuse}ko space&quot;
								cp $1 quota-bck/${u_user}.${V_DATE}
								softquota=$DEFS_QUOTA
							else
								echo &quot;WARNING: ${u_user} exceeds the default QUOTA, can't set IT (${realuse}ko)&quot;
						fi
				elif [ &quot;$softquota&quot; -gt &quot;$DEFS_QUOTA&quot; ]
					then
						echo &quot;WARNING: the quota defined for $u_user exceeds the standard ($softquota &gt; $DEFS_QUOTA)&quot;
				fi
				hardquota=$(echo $HQ |cut -d&quot;)&quot; -f1)
				[ &quot;$hardquota&quot; = &quot;0&quot; ] &amp;&amp; {
					[ &quot;$realuse&quot; -le &quot;$DEFS_QUOTA&quot; ] &amp;&amp; {
						hardquota=$DEFH_QUOTA
					}
				}

				softinode=$(echo $SI |cut -d&quot;,&quot; -f1)
				[ &quot;$softinode&quot; = &quot;0&quot; ] &amp;&amp; {
					softinode=$DEFS_INODE
				}
				hardinode=$(echo $HI |cut -d&quot;)&quot; -f1)
				[ &quot;$hardinode&quot; = &quot;0&quot; ] &amp;&amp; {
					hardinode=$DEFH_INODE
				}

				echo &quot;$a $FS $b $c $d ${softquota}, $e $f ${hardquota}) $g $h $i ${softinode}, $j $k ${hardinode})&quot; &gt;&gt;${V_TEMPFILE}
			done &lt; $1

			cat ${V_TEMPFILE} &gt; quota-bck/${u_user}.new
			cat ${V_TEMPFILE} &gt; $1
		}

		fct_quotaset $1
	else
		# WANT a backup
		[ ! -d &quot;quota-bck&quot; ] &amp;&amp; {
			mkdir quota-bck
		}

		[ ! -f &quot;quotas&quot; ] &amp;&amp; {
			echo &quot;ERROR: no quotas file found !&quot;
			exit 1
		}

		[ ! -d &quot;users&quot; ] &amp;&amp; {
			echo &quot;ERROR: no 'users' dir found !&quot;
			exit 1
		}

		for v_user in users/*
		do
			[ ! -d &quot;$v_user&quot; ] &amp;&amp; continue
			u_user=&quot;${v_user##*/}&quot;

			[ &quot;$u_user&quot; = &quot;TT_DB&quot; ] &amp;&amp; continue

			id ${u_user} &gt;/dev/null 2&gt;&amp;1
			[ &quot;$?&quot; -ne &quot;0&quot; ] &amp;&amp; {
				echo &quot;ERROR: user $u_user does not exists in this system, you should maybe delete the '$v_user' directory&quot;
				continue
			}

			EDITOR=&quot;${0}&quot; edquota $u_user
		done
fi
</pre>
</div>
<p> &#8211; you can set the default quota in the header<br />
 &#8211; If an account has a quota greater than the standard, It will be reported (be not modified)<br />
 &#8211; If an account has no quota defined AND exceeds the standard, It will be reported (be not modified)<br />
 &#8211; If an account has no quota defined and uses normal space, quota will be set</p>
<p>PS:<br />
the quota utilization should be check through the command &#8216;quota -v&#8217; to obtain the best actual quota utilization.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/10/set-a-quota/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MULTI_PROC.sh</title>
		<link>http://www.mobidyc.net/2011/08/multi_proc-sh/</link>
		<comments>http://www.mobidyc.net/2011/08/multi_proc-sh/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 13:19:38 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Scripting and snippets]]></category>
		<category><![CDATA[Shell sh]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[multithread]]></category>
		<category><![CDATA[parellisation]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=542</guid>
		<description><![CDATA[voici une mise Ã  jour du script MULTI_PROC.sh ce script, permet de parallÃ©liser le lancement de scripts. attention, ce script a Ã©tÃ© conÃ§u pour fonctionner depuis Solaris uniquement. n&#8217;oubliez pas de changer les chemins Ã  diffÃ©rents binaires pour un autre OS. voici le script de parallÃ©lisation Download : MULTI_PROCESS.sh #!/bin/ksh # vim:tabstop=3:syntax=sh:foldmethod=marker # # --------- <a href='http://www.mobidyc.net/2011/08/multi_proc-sh/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>voici une mise Ã  jour du script MULTI_PROC.sh<br />
ce script, permet de parallÃ©liser le lancement de scripts.</p>
<p>attention, ce script a Ã©tÃ© conÃ§u pour fonctionner depuis Solaris uniquement.<br />
n&#8217;oubliez pas de changer les chemins Ã  diffÃ©rents binaires pour un autre OS.<br />
<span id="more-542"></span><br />
voici le script de parallÃ©lisation</p>
<div class="download">Download : <a href="http://www.mobidyc.net/wp-content/uploads/2011/08/MULTI_PROCESS.sh">MULTI_PROCESS.sh</a>
<pre class="brush: bash; collapse: true; light: false; title: ++ Voir le code; toolbar: true; notranslate">#!/bin/ksh
# vim:tabstop=3:syntax=sh:foldmethod=marker
#
# ---------
## Programme : if_error
## Version   : 1.6
## Objet     : paralellise le lancement d'un script au travers d'une fenetre
##             dtterm et analyse le code retour.
## Author    : Cedrick GAILLARD
## Email     : mobidyc @ gmail.com
##----------------------------------------------------------------------------
# 0.1 00-mar-09 - Creation
# 0.9 17-avr-09 - ajout de la limite de process lances en parallelisation.
#               - ajout de la possibilite de paralelliser un proramme donne en
#                 ligne de commande.
#               - possibilite de variabiliser un composant du script donne en
#                 ligne de commande.
#               - possibilite de ne pas exporter la variable ARGUMENT_TO_WORK.
#               - ajout de l'usage et d'exemples.
#               - ajout de controle d'erreurs.
#               - garde maintenant un log de tout ce qui se passe concernant
#                 l'argument concerne en cas d'erreur.
#               - ajout d'un resume des erreurs en fin de programme.
# 1.0 24-avr-09 - suppression du downtime nagios, mis dans le script d'arret.
# 1.1 11-jun-09 - Modification d'un message d'erreur
# 1.2 18-jun-09 - si limite n'est pas specifie, positionnement par defaut a 10
#                 ajout d'un parseur qui recherche les RVAL dans le script a
#               - modification du repertoire ou sont deposes les fichier .RVAL
#               - lancer pour les afficher avant le lancement du script.
# 1.3 09-sep-09 - ajout du chemin complet vers le binaire ps.
# 1.5 13-sep-10 - utilise maintenant le shell courant en tache de fond pour
#                 travailler, plus besoin d'exporter un DISPLAY.
#                 ajout de l'argument --dtterm pour utiliser dtterm.
# 1.6 09-mar-11 - modification du check display si ddterm n'est pas utilisé.
#
#-----------------------------------------------------------------------------

Usage () { #{{{
cat &lt;&lt;EOF
Usage:
   ${0} (-h | --help) (--dtterm) -e PROGRAM (-l LIMIT) (-n) [-f FILE ] [Argument1 ( ... ArgumentX ... )]&quot;

   -h             Display usage
   --help         Display usage
   -e PROGRAM     Paralellize the program PROGRAM
   -l LIMIT       limit the paralellization to this value
   -n             Does not export the \$ARGUMENT_TO_WORK variable to PROGRAM
   --dtterm       use dtterm windows instead of the terminal
   -x VAR_NAME    Substitue each VAR_NAME occurences by arguments
   -f FILE        FILE contains an argument list

PROGRAM must be only one program, eventually followed by args.
   in that case, you must quote it.

Utility:
   ${0} will run multiple forks of PROGRAM. there will be as many fork as arguments, each fork can use
        the \$ARGUMENT_TO_WORK variable, which is the current argument.

   The first utility for this script was to paralellize a script, which takes a server name in argument,
   establish a connection to this server an run some commands, need a complete log and a resume in case
   of errors.
   but this script can deserve you a lot of other needs.

Example:
   6 forks and a maximum of 4 simultaneous run of xterm, each xterm will have the current argument in title

   # ${0} -l 4 -e &quot;xterm -title FOOBAR -e sleep 2&quot; -x FOOBAR A B C D E F

Example:
    # SERVER_LIST=&quot;machineA machineB machineB.dev.par.emea.cib&quot;
    # ${0} -l 2 -e &quot;ssh -o StrictHostKeyChecking=no FOOBAR uname -n&quot; -x FOOBAR \$SERVER_LIST
    machineB : En erreur
    machineA : finished
    machineB.dev.par.emea.cib : Fait!

    Resume des erreurs :
    machineB : Erreur, Rval = 255 - voir le fichier /var/tmp/machineB.255.RVAL

    # cat machineB.RVAL
    ssh: machineB: node name or service name not known
    255

Example:
   using the --dtterm permits you oo interact with each telnet session
   SERVER_LIST=&quot;machineA machineB machineB.dev.par.emea.cib&quot;
   # ${0} --dtterm -e &quot;telnet TOTOTO-lc.adm&quot; -x TOTOTO -l 4 \$SERVER_LIST
EOF
} #}}}

#SIZE=&quot;-geometry 100x10&quot;
export SIZE=

[ -z &quot;$1&quot; ] &amp;&amp; { #{{{
	echo &quot;${0} (-h | --help) (--dtterm) -e PROGRAM (-l LIMIT) (-n) [-f FILE ] [Argument1 ( ... ArgumentX ... )]&quot;
	echo 

	echo &quot;to mass run a script on multiple servers :&quot;
	echo &quot;$0 -l 10 -e '${0%/*}/stop_server.sh' -f /tmp/server_liste.txt&quot;
	echo &quot;$0 -l 10 -e '${0%/*}/stop_server.sh' Server1 [ Server2 ... ServerX ]&quot;
	echo &quot;$0 -l 10 -e '${0%/*}/stop_server.sh' Server1 [ Server2 ... ServerX ]&quot;
	echo &quot;$0 -l 10 -e '${0%/*}/restart_server.sh' Serveur1 [ Serveur2 ... ServeurX ]&quot;
	echo &quot;$0       -e '${0%/*}/restart_server.sh' Serveur1 [ Serveur2 ... ServeurX ]&quot;
	echo &quot;$0       -e '${0%/*}/mass_downtime.sh' Serveur1 [ Serveur2 ... ServeurX ]&quot;
	echo
	echo &quot;To display detailed help :&quot;
	echo &quot;$0 -h&quot;
} #}}}

stop_prg () { #{{{
	[ -n &quot;$SERV_ERR&quot; ] &amp;&amp; {
		echo
		echo &quot;Errors detected :&quot;

		for SERV_IN_ERR in $SERV_ERR
		do
			Serv=&quot;${SERV_IN_ERR%:*}&quot;
			Rval=&quot;${SERV_IN_ERR#*:}&quot;

			if [ &quot;$Rval&quot; = &quot;BAD&quot; ]
				then
					echo &quot;$Serv : Unknown error&quot;
			elif [ -n &quot;$(echo $Rval |sed 's/[0-9]//g')&quot; ]
				then
					echo &quot;$Serv : look at the ${TMPRVAL}/${Serv}.RVAL file&quot;
				else
					echo &quot;$Serv : ERROR: Rval=$Rval - look at the ${TMPRVAL}/${Serv}.${Rval}.RVAL file&quot;
			fi
		done
	}

	if [ &quot;$DEBUG&quot; = &quot;true&quot; ]
		then
			echo &quot;Logs: $TMPDIR&quot;
		else
			rm -rf &quot;$TMPDIR&quot;
	fi

	exit
} #}}}

trap stop_prg 1 2 3 11 13 15
DEBUG=

echo -- &quot; --&gt; Analysing arguments&quot;
while [ &quot;$#&quot; -ne &quot;0&quot; ] #{{{
do
	case $1
	in
		-e)	COMMANDS=$2
				shift 2
				;;
		-h|--help) \
				Usage
				exit
				;;
		-l)	LIMIT=$2
				shift 2
				;;
		-n)	VAR_EXPORT=false
				shift
				;;
		--dtterm)	V_WINTERM=true
					shift
				;;
		-x)	VAR_TO_USE=$2
				shift 2
				;;
		-f)	ARGUMENTS=&quot;$ARGUMENTS $(&lt; $2)&quot;
				shift 2
				;;
		*)		ARGUMENTS=&quot;$ARGUMENTS $1&quot;
				shift
				;;
	esac
done #}}}
echo -- &quot; --&gt; End of analysing arguments&quot;

RACINE=&quot;$(cd ${0%/*} &amp;&amp; pwd)&quot; || {
	echo &quot;ERROR: can't get my racine directory&quot;
	exit 1
}

[ -z &quot;$DISPLAY&quot; -a &quot;$V_WINTERM&quot; = &quot;true&quot; ] &amp;&amp; {
	echo &quot;ERREUR : your DISPLAY is not set&quot;
	exit 1
}

DTTERM=&quot;/usr/dt/bin/dtterm&quot;
V_DATE=&quot;$(date +%Y%m%d-%Hh%Ms%S)&quot;

cd $RACINE

# default simultaneous limit
[ -z &quot;$LIMIT&quot; -o &quot;$LIMIT&quot; -lt &quot;1&quot; ] &amp;&amp; LIMIT=&quot;10&quot;

TMPDIR=&quot;/var/tmp/${0##*/}.${RANDOM}.${$}&quot;
[ -d &quot;${TMPDIR}&quot; ] &amp;&amp; {
	echo &quot;ERROR : The temporary folder alreacy exists : ${TMPDIR}&quot;
	exit 1
}
mkdir -p &quot;${TMPDIR}&quot;

TMPRVAL=&quot;/var/tmp&quot;
[ -d &quot;${TMPRVAL}&quot; ] || mkdir -p &quot;${TMPRVAL}&quot;

# if PROGRAM has defined RVAL in header, we display them
egrep &quot;^# RVAL - [0-9]*[0-9]  - &quot; &quot;$(echo ${COMMANDS} |awk '{print $1}')&quot; 2&gt;/dev/null
echo

[ -z &quot;$COMMANDS&quot; ] &amp;&amp; {
	echo &quot;no command found to execute!&quot;
	exit 1
}

run_thread () { #{{{
	ARGUMENT_TO_WORK=$1
	[ &quot;$VAR_EXPORT&quot; != &quot;false&quot; ] &amp;&amp; export ARGUMENT_TO_WORK

	if [ -n &quot;$VAR_TO_USE&quot; ]
		then
			COMMAND=&quot;$(echo &quot;$COMMANDS&quot; |sed &quot;s@$VAR_TO_USE@$ARGUMENT_TO_WORK@g&quot;)&quot;
		else
			COMMAND=&quot;$COMMANDS&quot;
	fi

	echo &quot;#! /bin/ksh&quot; &gt; &quot;${TMPDIR}/${ARGUMENT_TO_WORK}.sh&quot;
	echo &quot;$COMMAND&quot;   &gt;&gt; &quot;${TMPDIR}/${ARGUMENT_TO_WORK}.sh&quot;
	echo &quot;echo \$?&quot;   &gt;&gt; &quot;${TMPDIR}/${ARGUMENT_TO_WORK}.sh&quot;
	echo &quot;exit&quot;       &gt;&gt; &quot;${TMPDIR}/${ARGUMENT_TO_WORK}.sh&quot;
	chmod +x &quot;${TMPDIR}/${ARGUMENT_TO_WORK}.sh&quot;

	cp /dev/null ${TMPRVAL}/${ARGUMENT_TO_WORK}.RVAL
	if [ &quot;$V_WINTERM&quot; = &quot;true&quot; ]
		then
			${DTTERM} -kshMode $SIZE \
				-title ${ARGUMENT_TO_WORK} \
				-l -lf ${TMPRVAL}/${ARGUMENT_TO_WORK}.RVAL -geometry 100x10 \
				-e ${TMPDIR}/${ARGUMENT_TO_WORK}.sh &amp;
		else
			(exec ${TMPDIR}/${ARGUMENT_TO_WORK}.sh ${ARGUMENT_TO_WORK}) &gt; ${TMPRVAL}/${ARGUMENT_TO_WORK}.RVAL 2&gt;&amp;1 &amp;
	fi

	PIDS=&quot;$PIDS $ARGUMENT_TO_WORK:$! &quot;
	CURRENT=&quot;$(( $CURRENT + 1 ))&quot;
} #}}}

check_thread () { #{{{
	SHIFT_TO_DO=0
	for PID in ${PIDS}
	do
		# If the PID is still running, go next
		[ -n &quot;$(/bin/ps -e -o pid |grep &quot;^[ ]*${PID#*:}$&quot;)&quot; ] &amp;&amp; continue

		# from here, the process is finished, we can restart another
		[ -n &quot;$1&quot; ] &amp;&amp; {
			run_thread $1
			shift 1
			SHIFT_TO_DO=$(( $SHIFT_TO_DO + 1 ))
		}

		INDEX=&quot;$(( $INDEX + 1 ))&quot;
		CURRENT=&quot;$(( $CURRENT - 1 ))&quot;

		RVAL=&quot;$(tail -1 ${TMPRVAL}/${PID%:*}.RVAL)&quot;
		[ &quot;$V_WINTERM&quot; = &quot;true&quot; ] &amp;&amp; RVAL=&quot;$(echo &quot;$RVAL&quot; |awk '{print $1}' |sed 's///')&quot;

		if [ &quot;$RVAL&quot; = &quot;0&quot; ]
			then
				echo &quot;${PID%:*} (${INDEX}/${NBR_ARGS} - $(echo &quot;${INDEX} ${OPER}&quot; |/usr/bin/bc)%) : finished&quot;
				rm -f ${TMPRVAL}/${PID%:*}.RVAL
			else
				mv &quot;${TMPRVAL}/${PID%:*}.RVAL&quot; &quot;${TMPRVAL}/${PID%:*}.${RVAL}.RVAL&quot;
				echo &quot;${PID%:*} (${INDEX}/${NBR_ARGS} - $(echo &quot;${INDEX} ${OPER}&quot; |/usr/bin/bc)%) : ERROR: Rval=$RVAL - take a look at the ${TMPRVAL}/${PID%:*}.${RVAL}.RVAL file&quot;
				SERV_ERR=&quot;$SERV_ERR ${PID%:*}:${RVAL}&quot;
		fi

		PIDS=&quot;$(echo &quot;${PIDS}&quot; |sed -e &quot;s@\&lt;${PID}\&gt;@@&quot; -e 's@  @ @g')&quot;
	done
} #}}}

set -- $ARGUMENTS

NBR_ARGS=${#}
if [ &quot;$NBR_ARGS&quot; -eq &quot;100&quot; ]
	then
		OPER=&quot;&quot;
elif [ &quot;$NBR_ARGS&quot; -lt &quot;100&quot; ]
	then
		OPER=&quot;* $(echo &quot;scale=2 ; 100 / ${NBR_ARGS}&quot; |bc -l)&quot;
	else
		OPER=&quot;/ $(echo &quot;scale=2 ; ${NBR_ARGS} / 100&quot; |bc -l)&quot;
fi
INDEX=0
CURRENT=0
LOOP=0

echo -- &quot; --&gt; We have ${NBR_ARGS} Args to run&quot;
echo -- &quot; --&gt; LIMIT defined to ${LIMIT}&quot;

while [ : ]
do
	[ &quot;${#}&quot; -ne &quot;0&quot; -a &quot;$CURRENT&quot; -le &quot;$LIMIT&quot; ] &amp;&amp; {
		run_thread $1
		shift 1
	}

	NBR_PIDS=$(echo &quot;${PIDS}&quot; |wc -w)
	[ &quot;${NBR_PIDS}&quot; -eq &quot;0&quot; ] &amp;&amp; break

	[ &quot;${#}&quot; -eq &quot;0&quot; ] &amp;&amp; /usr/bin/perl -e 'select(undef,undef,undef,.1)'
	[ &quot;$CURRENT&quot; -eq &quot;${LIMIT}&quot; ] &amp;&amp; /usr/bin/perl -e 'select(undef,undef,undef,.1)'

	[ &quot;${#}&quot; -gt &quot;${LIMIT}&quot; -a &quot;${NBR_PIDS}&quot; -lt &quot;$(echo &quot;${LIMIT} / 2&quot; |/usr/bin/bc)&quot; ] &amp;&amp; {
		while [ &quot;${#}&quot; -ne &quot;0&quot; -a &quot;$CURRENT&quot; -lt &quot;$LIMIT&quot; ]
		do
			run_thread $1
			shift 1
		done
	}

	check_thread ${*}

	[ &quot;$SHIFT_TO_DO&quot; -gt &quot;0&quot; ] &amp;&amp; shift $SHIFT_TO_DO
done

stop_prg
</pre>
</div>
<p>et voici 1 exemple de script a donner en argument Ã  MULTI_PROC.sh<br />
ce dernier permet d&#8217;arrÃªter un serveur Sun, Linux ou HP-UX</p>
<div class="download">Download : <a href="http://www.mobidyc.net/wp-content/uploads/2011/08/stop_server.sh">stop_server.sh</a>
<pre class="brush: bash; collapse: true; light: false; title: ++ Voir le code; toolbar: true; notranslate">#!/bin/ksh
# ce programme est cense etre lance par le programme multi_remote.sh
#
# codes retour:
# RVAL - 150  -  I didn't received the server name
# RVAL - 200  -  you must modify the nagios downtime end time
# RVAL - 170  -  the first disk sync is failed
# RVAL - 172  -  the second disk sync is failed
# RVAL - 212  -  ping HS

[ -z &quot;$ARGUMENT_TO_WORK&quot; ] &amp;&amp; {
	echo &quot;ERROR : the ARGUMENT_TO_WORK variable is not set&quot;
	exit 150
}

/usr/sbin/ping $ARGUMENT_TO_WORK 2 &gt;/dev/null 2&gt;&amp;1
if [ &quot;$?&quot; = &quot;0&quot; ]
	then
		/usr/bin/ssh -q -o PreferredAuthentications=publickey -o StrictHostKeyChecking=no -n ${ARGUMENT_TO_WORK} &quot;PATH=\$PATH:/bin:/sbin:/usr/bin:/usr/sbin
				export PATH
				case \`uname -s\`
				in
					SunOS)	eeprom \&quot;auto-boot?\&quot;=true || exit 4
								sync || exit 170
								sync || exit 172
								init 5 2&gt;&amp;1 || exit 3 ;;
					Linux)	shutdown -h now 2&gt;&amp;1 || exit 3 ;;
					HP-UX)	cd /
								setboot -b on
								/usr/sbin/shutdown -h -y now |while read line
								do
									echo \&quot;\${line}\&quot;
									[ -n \&quot;\$(echo \&quot;x\${line}\&quot; |grep \&quot;xTransition to run-level 0 is complete\&quot;)\&quot; ] &amp;&amp; exit 0
								done
								;;
					*)	echo \&quot;\`uname -s\` non supporte\&quot;
						exit 1
						;;
				esac
				&quot;
		REMOTE_VAL=$?

		exit $REMOTE_VAL
	else
		echo &quot;ERROR: can't ping $ARGUMENT_TO_WORK&quot;
		exit 212
fi
</pre>
</div>
<p>explication du fonctionnement:</p>
<pre class="brush: plain; title: ; notranslate"># ./MULTI_PROC.sh -e './stop_server.sh' -f /tmp/server_liste.txt</pre>
<p>le script &#8216;stop_server.sh&#8217; va Ãªtre lancÃ© autant de fois que le nombre de serveurs Ã  traiter dans le fichier /tmp/server_liste.txt.<br />
et pour chaque lancement, stop_server.sh va rÃ©cupÃ©rer l&#8217;argument (le nom du serveur) en cours sous la forme de la variable ARGUMENT_TO_WORK.</p>
<p><strong>stop_server.sh est donc simplement un script qui va se connecter en ssh sur le serveur $ARGUMENT_TO_WORK et l&#8217;arrÃªter.<br />
</strong></p>
<p>il est conseillÃ© de gÃ©rer les erreurs dans le script qui va Ãªtre parallÃ©lisÃ© en sortant avec un numÃ©ro d&#8217;erreur prÃ©dÃ©fini cat MULTI_PROC.sh sait gÃ©rer les codes retour, et garde l&#8217;historique de tout le script si le code retour n&#8217;est pas zÃ©ro.</p>
<p>tout au long du dÃ©roulement du programme, Ã  chaque fois qu&#8217;un thread se termine, Ã§a s&#8217;affiche Ã  l&#8217;Ã©cran, avec un rapport sur l&#8217;Ã©volution de la totalitÃ© du traitement.<br />
Ã  chaque fois qu&#8217;une erreur est dÃ©tectÃ©e, elle s&#8217;affiche et est logguÃ©e.</p>
<p>lorsque tout les traitements sont terminÃ©s, un rÃ©sumÃ© de toutes les erreurs rencontrÃ©es s&#8217;affiche.</p>
<p>exemple de sortie:</p>
<pre class="brush: bash; title: ; notranslate">
# ./MULTI_PROCESS.dev.sh -e './test_ssh_cnx.sh' -f /tmp/list_of_3_servers.txt
--  --&gt; Analysing arguments
--  --&gt; End of analysing arguments
# RVAL - 150  -  I didn't received the server name
# RVAL - 212  -  ping HS

--  --&gt; We have 3 Args to run
--  --&gt; LIMIT defined to 10
machine_1 (1/3 - 33.33%) : ERROR: Rval=212 - take a look at the /var/tmp/machine_1.212.RVAL file
machine_3 (2/3 - 66.66%) : ERROR: Rval=212 - take a look at the /var/tmp/machine_3.212.RVAL file
machine_2 (3/3 - 99.99%) : finished

Errors detected :
machine_1 : ERROR: Rval=212 - look at the /var/tmp/machine_1.212.RVAL file
machine_3 : ERROR: Rval=212 - look at the /var/tmp/machine_3.212.RVAL file
#
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/08/multi_proc-sh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sleep dÃ©cimal</title>
		<link>http://www.mobidyc.net/2011/08/sleep-decimal/</link>
		<comments>http://www.mobidyc.net/2011/08/sleep-decimal/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 15:42:07 +0000</pubDate>
		<dc:creator>mobidyc</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripting and snippets]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[millisecond]]></category>
		<category><![CDATA[milliseconde]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.mobidyc.net/?p=536</guid>
		<description><![CDATA[la commande &#171;&#160;sleep x&#160;&#187; sous Unix permet de faire une pause de x secondes. je viens de trouver une commande perl assez satisfaisante permettant de faire des pause de moins d&#8217;une seconde. intÃ©ressant par exemple lorsque l&#8217;on fork des process. en effet, s&#8217;il n&#8217;y a pas de pause dans le script, lorsque les forks se <a href='http://www.mobidyc.net/2011/08/sleep-decimal/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>la commande &laquo;&nbsp;sleep x&nbsp;&raquo; sous Unix permet de faire une pause de x secondes.</p>
<p>je viens de trouver une commande perl assez satisfaisante permettant de faire des pause de moins d&#8217;une seconde.<br />
intÃ©ressant par exemple lorsque l&#8217;on fork des process.<br />
en effet, s&#8217;il n&#8217;y a pas de pause dans le script, lorsque les forks se terminent, ils restent en Ã©tat zombie.<br />
<span id="more-536"></span><br />
la commande magique est : </p>
<pre class="brush: plain; title: ; notranslate">perl -e 'select(undef,undef,undef,.1)'</pre>
<p>&#8216;.1&#8242; signifie 0,1 secondes</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mobidyc.net/2011/08/sleep-decimal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

