<?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>Croc-Informatique.fr &#187; Perl</title>
	<atom:link href="http://www.croc-informatique.fr/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.croc-informatique.fr</link>
	<description>Le Blog Note d'Olivier Legras</description>
	<lastBuildDate>Wed, 18 Jan 2012 16:29:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>[MISE A JOUR] Synchroniser et superviser VULTURE</title>
		<link>http://www.croc-informatique.fr/2010/07/mise-a-jour-synchroniser-et-superviser-vulture/</link>
		<comments>http://www.croc-informatique.fr/2010/07/mise-a-jour-synchroniser-et-superviser-vulture/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 14:40:40 +0000</pubDate>
		<dc:creator>Olivier Legras</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Projet]]></category>
		<category><![CDATA[Réseau]]></category>
		<category><![CDATA[Sécurité]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[projet]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[reverse]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[supervision]]></category>
		<category><![CDATA[synchronisation]]></category>
		<category><![CDATA[Vulture]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.croc-informatique.fr/2010/07/mise-a-jour-synchroniser-et-superviser-vulture/</guid>
		<description><![CDATA[Après avoir ajouté des interfaces à mes serveurs Vulture pour prendre en charge mes certificats SSL par domaine, j’ai du mettre à jour mes scripts de synchronisation et de supervision. Pour rappel, la première version ainsi qu’une doc explicative se trouve à cette adresse : http://www.croc-informatique.fr/2009/07/synchronisation-et-monitoring-de-deux-reverse-proxy-vulture/ J’en ai profité pour remanier un peu mon code [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Après avoir ajouté des interfaces à mes serveurs Vulture pour prendre en charge mes certificats SSL par domaine, j’ai du mettre à jour mes scripts de synchronisation et de supervision. Pour rappel, la première version ainsi qu’une doc explicative se trouve à cette adresse : <a title="http://www.croc-informatique.fr/2009/07/synchronisation-et-monitoring-de-deux-reverse-proxy-vulture/" href="http://www.croc-informatique.fr/2009/07/synchronisation-et-monitoring-de-deux-reverse-proxy-vulture/">http://www.croc-informatique.fr/2009/07/synchronisation-et-monitoring-de-deux-reverse-proxy-vulture/</a></p>
<p>J’en ai profité pour remanier un peu mon code pour qu’il soit plus exploitable par tous. J’espère que ça servira à quelqu’un.</p>
<h3>Attention :</h3>
<p><span id="more-620"></span></p>
<p>J’ai transformé le script permettant la supervision de la synchronisation du shell en perl. Donc, à présent, il faut mettre dans le fichier /etc/sudoers la ligne :</p>
<blockquote><p>nagios   ALL = NOPASSWD: /usr/bin/perl /usr/lib/nagios/plugins/check_synchro_vulture.pl</p></blockquote>
<p>Au lieu de :</p>
<blockquote><p>nagios   ALL = NOPASSWD: /bin/sh /usr/local/nagios/libexec/check_synchro_vulture.sh</p></blockquote>
<p>Modifier également la commande utilisé par Nagios.</p>
<p>La supervision des sites Web hébergés a également changée. La commande s’exécute de cette manière :</p>
<blockquote><p>./check_vulture.pl -H 192.168.0.1</p></blockquote>
<p>Il vous faudra modifier les constantes dans la plupart des scripts.</p>
<p>Vous pouvez télécharger la dernière version <a href="http://crocodanser.free.fr/fichiers/synchro-vulture-072010.zip" target="_blank">ici</a></p>
<p>Mot de passe de l&#8217;archive : http://www.croc-informatique.fr</p>
<div class="shr-publisher-620"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2010%2F07%2Fmise-a-jour-synchroniser-et-superviser-vulture%2F' data-shr_title='%5BMISE+A+JOUR%5D+Synchroniser+et+superviser+VULTURE'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2010%2F07%2Fmise-a-jour-synchroniser-et-superviser-vulture%2F' data-shr_title='%5BMISE+A+JOUR%5D+Synchroniser+et+superviser+VULTURE'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.croc-informatique.fr/2010/07/mise-a-jour-synchroniser-et-superviser-vulture/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[Nagios] Visualiser la commande exécutée par Nagios</title>
		<link>http://www.croc-informatique.fr/2010/07/nagios-visualiser-la-commande-executee-par-nagios/</link>
		<comments>http://www.croc-informatique.fr/2010/07/nagios-visualiser-la-commande-executee-par-nagios/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 15:38:47 +0000</pubDate>
		<dc:creator>Olivier Legras</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Outils]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[debuggage]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.croc-informatique.fr/?p=609</guid>
		<description><![CDATA[J’ai passé la journée à rechercher pourquoi mon event handler ne voulait pas fonctionner. J’avais l’impression que certaines macros ne fonctionnaient pas. Mais sur Nagios, comment pouvons nous voir la commande qu’il exécute avec les valeurs des arguments? Et bien, la solution est ici : http://www.waggy.at/nagios/capture_plugin.htm Sur ce site, vous allez trouvez un plugin perl [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>J’ai passé la journée à rechercher pourquoi mon event handler ne voulait pas  fonctionner. J’avais l’impression que certaines macros ne fonctionnaient pas.  Mais sur Nagios, comment pouvons nous voir la commande qu’il exécute avec les  valeurs des arguments?</p>
<p>Et bien, la solution est ici : <a title="http://www.waggy.at/nagios/capture_plugin.htm" href="http://www.waggy.at/nagios/capture_plugin.htm">http://www.waggy.at/nagios/capture_plugin.htm</a></p>
<p>Sur ce site, vous allez trouvez un plugin perl qui est téléchargeable ici :  <a title="http://www.waggy.at/nagios/capture_plugin.txt" href="http://www.waggy.at/nagios/capture_plugin.txt">http://www.waggy.at/nagios/capture_plugin.txt</a></p>
<h3></h3>
<p><span id="more-609"></span></p>
<p>&nbsp;
<p />
<h3>Installation et configuration du plugin</h3>
<p>&nbsp;
<p />
Vous pouvez le placer avec vos autres plugins, le renommer en  capture_plugin.pl et lui donner les bons droits.</p>
<p>L’emplacement du fichier log est défini dans cette variable :</p>
<blockquote><p>my $LOG_FILE = &laquo;&nbsp;/tmp/captured-plugins.log&nbsp;&raquo;;</p></blockquote>
<h3></h3>
<p>&nbsp;
<p />
<h3>Utilisation du plugin</h3>
<p>&nbsp;
<p />
Si la commande que vous voulez debugger est la suivante :</p>
<blockquote><p>$USER1$/check_nrpe -H $HOSTADDRESS$ -c restart_service -a $SERVICESTATE$  $SERVICESTATETYPE$ $SERVICEATTEMPT$ &laquo;&nbsp;$ARG1$&nbsp;&raquo;</p></blockquote>
<p>Il vous suffi de la modifier en ajoutant le plugin comme ceci :</p>
<blockquote><p><strong>$USER1$/capture_plugin.pl</strong> $USER1$/check_nrpe -H  $HOSTADDRESS$ -c restart_service -a $SERVICESTATE$ $SERVICESTATETYPE$  $SERVICEATTEMPT$ &laquo;&nbsp;$ARG1$&nbsp;&raquo;</p></blockquote>
<p>Voilà, il ne vous reste plus qu’à tester et vérifier que votre commande est  bien lancée dans le fichier log.</p>
<h3></h3>
<p></p>
<h3>Exemple de fichier log :</h3>
<p>&nbsp;
<p />
Voici un exemple de log :</p>
<blockquote><p>2010-6-21 16:32:29 &#8212;&#8212; debugging<br />
cmd=[/usr/lib/nagios/plugins/check_nrpe '-H' '192.168.0.1' '-c'  'restart_service' '-a' 'OK' 'HARD' '4' 'mon service']<br />
output=[Restarting mon  service (3rd soft critical state)<br />
]<br />
retcode=0</p></blockquote>
<ul>
<li>cmd –&gt; Commande lancée par Nagios</li>
<li>output –&gt; retour de la commande check_nrpe</li>
<li>retcode –&gt; Code retour de la commande check_nrpe</li>
</ul>
<p>Si vous avez d’autres solutions, n’hésitez pas <img src='http://www.croc-informatique.fr/wp-includes/images/smilies/icon_wink.gif' alt="icon wink [Nagios] Visualiser la commande exécutée par Nagios" class='wp-smiley' title="[Nagios] Visualiser la commande exécutée par Nagios" />  J’ai essayé le mode debug,  mais ça n’a pas trop fonctionné. En même temps, j’ai pas cherché beaucoup…</p>
<h3></h3>
<p>&nbsp;
<p />
<h3>Code Sources :</h3>
<p>&nbsp;
<p />
Au cas où, je mets la source :</p>
<blockquote>
<pre>#!/usr/bin/perl -w
#
# Written 2007-03-24 by Wolfgang Wagner (aka wolle)
#
# $id: capture_plugin.pl v1.0
#
# Captures stdout&amp;stderr in a file and returns orginial results to Nagios (http://www.nagios.org)
#
# Copyright 2007 by Wolfgang Wagner. All rights reserved.
#
# This software is licensed under the terms of the GNU General Public License Version 2
# as published by the Free Software Foundation.
# It is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN,
# MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Check out http://www.waggy.at for possible future versions.
#

use strict;

# This plugin does not need any nagios utils. It just interfaces the original plugin.

my $LOG_FILE = "/tmp/captured-plugins.log";

my ($cmd, $ret_code, $output);
# First display all arguments
my ($numArgs, $argnum);
$numArgs = $#ARGV + 1;

# create the command-line

$cmd = $ARGV[0];
foreach $argnum (1 .. $#ARGV) {
  $cmd = $cmd . " '" . $ARGV[$argnum] . "'"
}

# prepare debug-output
# ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(time);
my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset) = localtime(time);
my $year = 1900 + $yearOffset;
my $theTime = " $year-$month-$dayOfMonth $hour:$minute:$second";
# now execute the command

$output = `$cmd 2&gt;&amp;1`;
$ret_code = $?&gt;&gt;8;

# log the start, output, retcode &amp; end

my $LogFile;
# open could be better: check success later; if unsuccessful return UNKNWON to Nagios
open (LogFile, "&gt;&gt;$LOG_FILE") || die ("Cannot open logfile");
print LogFile "$theTime ------ debugging\ncmd=[$cmd]\noutput=[$output]\nretcode=$ret_code\n-------\n";
close(LogFile);
# avoid access problems for others.
chmod 0777, $LOG_FILE;

# now return the original resutlt to Nagios
print $output;
exit "$ret_code";</pre>
</blockquote>
<div class="shr-publisher-609"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2010%2F07%2Fnagios-visualiser-la-commande-executee-par-nagios%2F' data-shr_title='%5BNagios%5D+Visualiser+la+commande+ex%C3%A9cut%C3%A9e+par+Nagios'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2010%2F07%2Fnagios-visualiser-la-commande-executee-par-nagios%2F' data-shr_title='%5BNagios%5D+Visualiser+la+commande+ex%C3%A9cut%C3%A9e+par+Nagios'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.croc-informatique.fr/2010/07/nagios-visualiser-la-commande-executee-par-nagios/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Afficher un fichier de configuration sans les commentaires</title>
		<link>http://www.croc-informatique.fr/2009/12/afficher-un-fichier-de-configuration-sans-les-commentaires/</link>
		<comments>http://www.croc-informatique.fr/2009/12/afficher-un-fichier-de-configuration-sans-les-commentaires/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 13:15:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Astuces]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[conf]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[fichier]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.croc-informatique.fr/2009/12/afficher-un-fichier-de-configuration-sans-les-commentaires/</guid>
		<description><![CDATA[Pour y voir plus claire, il est parfois nécessaire de voir seulement ce qui est activé dans les fichiers de configuration. Pour cela, je vous propose plusieurs commandes : Grep : grep -E -v &#8216;^(#&#124;$)&#8217; /etc/httpd/conf/httpd.conf egrep -v &#8216;^(#&#124;$)&#8217;&#160; /etc/httpd/conf/httpd.conf &#160; On peut ajouter des délimiteurs de cette manière : grep -E -v '^(#&#124;;&#124;$&#124;[ ]*#)' [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Pour y voir plus claire, il est parfois nécessaire de voir seulement ce qui est activé dans les fichiers de configuration. Pour cela, je vous propose plusieurs commandes :</p>
<p>Grep :</p>
<blockquote><p>grep -E -v &#8216;^(#|$)&#8217; /etc/httpd/conf/httpd.conf</p>
<p>egrep -v &#8216;^(#|$)&#8217;&#160; /etc/httpd/conf/httpd.conf</p>
</blockquote>
<p>&#160;</p>
<p>On peut ajouter des délimiteurs de cette manière :</p>
<blockquote><pre>grep -E -v '^(#|;|$|[ ]*#)' /etc/httpd/conf/httpd.conf</pre>
<p><span id="more-469"></span></p>
</blockquote>
<p>&#160;</p>
<p>Sed :</p>
<blockquote>
<pre>sed -e '/^[ ]*#/d' -e '/^$/d' /etc/httpd/conf/httpd.conf</pre>
</blockquote>
<p>On peut ajouter des délimiteurs :</p>
<blockquote>
<pre>sed -e '/^[ ]*#/d' -e '/^[ ]*;/d' -e '/^$/d' /etc/httpd/conf/httpd.conf</pre>
</blockquote>
<p>Perl :</p>
<blockquote>
<pre>perl -ne 'print unless /^\s*[;\$#]|^$/' /etc/httpd/conf/httpd.conf</pre>
</blockquote>
<div class="shr-publisher-469"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2009%2F12%2Fafficher-un-fichier-de-configuration-sans-les-commentaires%2F' data-shr_title='Afficher+un+fichier+de+configuration+sans+les+commentaires'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='false' data-shr_href='http%3A%2F%2Fwww.croc-informatique.fr%2F2009%2F12%2Fafficher-un-fichier-de-configuration-sans-les-commentaires%2F' data-shr_title='Afficher+un+fichier+de+configuration+sans+les+commentaires'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.croc-informatique.fr/2009/12/afficher-un-fichier-de-configuration-sans-les-commentaires/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

