<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Blog de Mathieu Chateau</title>
	
	<link>http://www.lotp.fr</link>
	<description>Architecture / Microsoft / Réseau / Sécurité</description>
	<lastBuildDate>Mon, 13 May 2013 22:15:02 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/lotp" /><feedburner:info uri="lotp" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Nagios: Superviser la santé Hyper-V 2012 – BPA &amp; VM</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/HjqPJfHVuGE/</link>
		<comments>http://www.lotp.fr/2013/05/nagios-superviser-la-sante-hyper-v-2012-bpa-vm/#comments</comments>
		<pubDate>Sat, 11 May 2013 08:41:58 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[nagios]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Windows 2012]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1496</guid>
		<description><![CDATA[Ce plugin Nagios vérifie la santé d&#8217;un serveur Hyper-V via un script PowerShell + NRPE (nsclient++):

Exécute et récupère le résultat du scan BPA (Best Practice Analyzer)
Vérifie que toutes les VM sont en cours d&#8217;exécution
Vérifie qu&#8217;aucune VM n&#8217;a un état de fonctionnement autre que normal

Les  [...]]]></description>
				<content:encoded><![CDATA[<p>Ce plugin Nagios vérifie la santé d&rsquo;un serveur Hyper-V via un script PowerShell + NRPE (nsclient++):</p>
<ul>
<li><span style="line-height: 12.796875px;">Exécute et récupère le résultat du scan BPA (Best Practice Analyzer)</span></li>
<li>Vérifie que toutes les VM sont en cours d&rsquo;exécution</li>
<li>Vérifie qu&rsquo;aucune VM n&rsquo;a un état de fonctionnement autre que normal</li>
</ul>
<p>Les états avertissements et critiques sont déclenchés par la somme des:</p>
<ul>
<li><span style="line-height: 12.796875px;">Quantité d&rsquo;alertes BPA</span></li>
<li>Nombre de VM dans un état autre que sain</li>
</ul>
<p>Certaines VM (modèles&#8230;) peuvent être ignorées via un argument</p>
<p>Un nouveau scan BPA est lancé à chaque exécution, mais le résultat n&rsquo;est récupéré que la fois suivante (async) (prend trop de temps).</p>
<p>Les données de performances suivantes sont fournies:</p>
<ul>
<li><span style="line-height: 12.796875px;"># VM arrêtées,</span></li>
<li># VM avec problème de santé,</li>
<li># Erreurs BPA</li>
<li># Avertissements BPA</li>
</ul>
<h2>Configuration testée</h2>
<p><strong>Linux:</strong></p>
<ul>
<li>Centos 6.4 x64</li>
<li>Nagios 3.4.4</li>
<li>check_nrpe 2.13</li>
<li>Centreon 2.4.2</li>
</ul>
<p><strong>Windows:</strong></p>
<ul>
<li>Windows Server 2012 (nécessaire pour avoir le module PowerShell Hyper-V)</li>
<li>nsclient++ 0.4.1 x64</li>
</ul>
<h2>Arguments du script</h2>
<ul>
<li>excludeVM (séparées par des virgules)</li>
<li>maxWarn (Avertissement si supérieur) (1 par défaut)</li>
<li>maxError (Critique si supérieur) (5 par défaut)</li>
</ul>
<p>maxWarn et maxCrit doivent être des entiers</p>
<h2>Exemples d’utilisation</h2>
<p>Exemple en exécution directe PowerShell:</p>
<pre>PS C:\Program Files\NSClient++\scripts&gt;. .\lotp_check_hyper-v.ps1
WARNING: 'VM Not Running:'2 'VM issues:'0 BPA Error:1 BPA Warning:12|VM_Not_Running=2 VM_issues=0 BPA_Error=1 BPA_Warning=12
PS C:\Program Files\NSClient++\scripts&gt;</pre>
<p>Exécution NRPE:</p>
<pre>[root~]# /usr/lib64/nagios/plugins/check_nrpe -H myMonitoredServer -n -c check_hyper-v
WARNING: 'VM Not Running:'2 'VM issues:'0 BPA Error:1 BPA Warning:12|VM_Not_Running=2 VM_issues=0 BPA_Error=1 BPA_Warning=12
[root~]#</pre>
<h2>Installation:</h2>
<p>Sur les Windows:</p>
<ul>
<li>Activer l’exécution de scripts PowerShell non signés : Set-ExecutionPolicy RemoteSigned</li>
<li>copier le script dans C:\Program Files\NSClient++\scripts</li>
<li>Ajouter dans le fichier nsclient.ini:
<ul>
<li>[/settings/external scripts/wrapped scripts]<br />
check_hyper-v=lotp_check_hyper-v.ps1 -excludeVM $ARG1$ -maxWarn $ARG2$ -maxError $ARG3$</li>
</ul>
</li>
</ul>
<h2>Configuration:</h2>
<p>Par exemple, sur Centreon, en ajoutant la commande:</p>
<pre>$USER1$/check_nrpe -H $HOSTADDRESS$ -n -t 60 -c check_hyper-v -a $ARG1$ $ARG2$ $ARG3$</pre>
<h2>Téléchargement</h2>
<p><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_hyper-v.ps1_.txt">lotp_check_hyper-v.ps1</a></p>
<p>Code source en direct:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><caption><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_hyper-v.ps1_.txt">/wp-content/uploads/2013/05/lotp_check_hyper-v.ps1_.txt</a></caption><tr><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># ====================================================================</span>
<span style="color: #008000;"># Ping a list of targets through NRPE</span>
<span style="color: #008000;"># Author: Mathieu Chateau - LOTP</span>
<span style="color: #008000;"># mail: mathieu.chateau@lotp.fr</span>
<span style="color: #008000;"># version 0.1</span>
<span style="color: #008000;"># ====================================================================</span>
&nbsp;
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Require Set-ExecutionPolicy RemoteSigned.. or sign this script with your PKI </span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #008000;"># ============================================================</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;">#  Do not change anything behind that line!</span>
<span style="color: #008000;">#</span>
<span style="color: #0000FF;">param</span> 
<span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$targets</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxWarn</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxError</span> <span style="color: pink;">=</span> <span style="color: #804000;">5</span>
<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #800080;">$countOK</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countKO</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$targetsArray</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$targetsArray</span><span style="color: pink;">=</span><span style="color: #800080;">$targets</span> <span style="color: pink;">-</span>split<span style="color: #000000;">&#40;</span><span style="color: #800000;">' '</span><span style="color: #000000;">&#41;</span>
Remove<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: pink;">*</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span> <span style="color: #008080; font-style: italic;">-Force</span>
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$t</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$targetsArray</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	Start<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$t</span> <span style="color: #008080; font-style: italic;">-ArgumentList</span> <span style="color: #800080;">$t</span> <span style="color: pink;">-</span>ScriptBlock <span style="color: #000000;">&#123;</span><span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$t</span><span style="color: #000000;">&#41;</span>;<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span>Test<span style="color: pink;">-</span>Connection <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$t</span>  <span style="color: #008080; font-style: italic;">-Count</span> <span style="color: #804000;">2</span> <span style="color: #008080; font-style: italic;">-Quiet</span> <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #0000FF;">return</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #0000FF;">return</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span><span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">while</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Job <span style="color: pink;">-</span>State Running<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Start-Sleep</span> <span style="color: #008080; font-style: italic;">-Milliseconds</span> <span style="color: #804000;">500</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span> <span style="color: #0000FF;">in</span> Get<span style="color: pink;">-</span>Job<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=</span>Receive<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$job</span>.Name
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$countOK</span><span style="color: pink;">++</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$countKO</span><span style="color: pink;">++</span>
		<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800080;">$job</span>.Name<span style="color: pink;">+</span><span style="color: #800000;">&quot; - &quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$countKO</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxError</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;CRITICAL&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">elseif</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$countKO</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxWarn</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;WARNING&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">1</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;OK&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800080;">$state</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countOK</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; online&quot;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; - &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countKO</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; offline - &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$output</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">'|'</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">&quot;online=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countOK</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxError</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; &quot;</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">&quot;offline=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countKO</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxError</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$output</span>
exit $exitcode</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/lotp/~4/HjqPJfHVuGE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/nagios-superviser-la-sante-hyper-v-2012-bpa-vm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/nagios-superviser-la-sante-hyper-v-2012-bpa-vm/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-superviser-la-sante-hyper-v-2012-bpa-vm</feedburner:origLink></item>
		<item>
		<title>dcdiag – VerifyEnterpriseReferences – msDFSR-ComputerReferenceBL – Q312862</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/XVFLoEKjWeA/</link>
		<comments>http://www.lotp.fr/2013/05/dcdiag-verifyenterprisereferences-msdfsr-computerreferencebl-q312862/#comments</comments>
		<pubDate>Sat, 11 May 2013 08:05:08 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[windows 2008]]></category>
		<category><![CDATA[Windows 2008 R2]]></category>
		<category><![CDATA[Windows 2012]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1494</guid>
		<description><![CDATA[Depuis Windows 2008, la réplication AD est censée se faire via DFS-R et non plus FRS. Cependant, cela implique de n'avoir plus que des DC > Windows Server 2003.
Donc si vos DC sont à jours, il faut utiliser dfsrmig dont les principales commandes sont:]]></description>
				<content:encoded><![CDATA[<p>En préparant un plugin nagios sur la santé AD, dcdiag /e /c a eu la bonne idée de remonter cette alerte:</p>
<pre>Starting test: VerifyEnterpriseReferences

The following problems were found while verifying various important DN

references. Note, that these problems can be reported because of

latency in replication. So follow up to resolve the following

problems, only if the same problem is reported on all DCs for a given

domain or if the problem persists after replication has had

reasonable time to replicate changes. 

 [1] Problem: Missing Expected Value

Base Object: CN=myDC,OU=Domain Controllers,DC=mydomain,DC=net

Base Object Description: "DC Account Object"

Value Object Attribute Name: msDFSR-ComputerReferenceBL

Value Object Description: "SYSVOL FRS Member Object"

Recommended Action: See Knowledge Base Article: Q312862</pre>
<p>&nbsp;</p>
<p>L&rsquo;article <a href="http://support.microsoft.com/kb/312862" target="_blank">Q312862</a> n&rsquo;est plus vraiment d&rsquo;actualité, mais le problème sous-jacent est bien réel.</p>
<p>Depuis Windows 2008, la réplication AD est censée se faire via DFS-R et non plus FRS. Cependant, cela implique de n&rsquo;avoir plus que des DC &gt; Windows Server 2003.</p>
<p>Donc si vos DC sont à jours, il faut utiliser <a href="http://technet.microsoft.com/en-us/library/dd641227(v=ws.10).aspx" target="_blank">dfsrmig</a> dont les principales commandes sont:</p>
<h3>Vérifier l&rsquo;état global:</h3>
<pre>PS C:\users\mchateau\Desktop&gt; <strong>dfsrmig /GetGlobalState</strong>

Current DFSR global state: 'Start'

Succeeded.</pre>
<p>Les différents états possibles sont:</p>
<pre>0 'Start'
1 'Prepared'
2 'Redirected'
3 'Eliminated'</pre>
<p>==&gt;Si vous êtes déjà en DFS-R, l&rsquo;état est <strong>Eliminated</strong>.</p>
<p>&nbsp;</p>
<h3>Vérifier l&rsquo;état de la migration:</h3>
<pre>PS C:\users\mchateau\Desktop&gt; dfsrmig /GetMigrationState

All domain controllers have migrated successfully to the Global state ('Start').
Migration has reached a consistent state on all domain controllers.
Succeeded.</pre>
<p>&nbsp;</p>
<h3>Passer à l&rsquo;état Prepared:</h3>
<pre>PS C:\users\mchateau\Desktop&gt; dfsrmig /SetGlobalState 1

Current DFSR global state: 'Start'

New DFSR global state: 'Prepared'

Migration will proceed to 'Prepared' state. DFSR service will copy the contents of SYSVOL to SYSVOL_DFSR folder.
If any domain controller is unable to start migration, try manual polling.
Or run with option /CreateGlobalObjects.
Migration can start anytime between 15 minutes to 1 hour.
Succeeded.</pre>
<p>&nbsp;</p>
<h3>Vérifier l&rsquo;état (en cours):</h3>
<pre>PS C:\users\mchateau\Desktop&gt; dfsrmig /GetMigrationState

The following domain controllers have not reached Global state ('Prepared'):

Domain Controller (Local Migration State) - DC Type
<em id="__mceDel"></em><em id="__mceDel">===================================================

</em><em id="__mceDel">myDC01 ('Start') - Writable DC
</em><em id="__mceDel"></em><em id="__mceDel">myDC02 ('Start') - Writable DC
</em><em id="__mceDel"></em><em id="__mceDel"></em><em id="__mceDel">myDC03 ('Start') - Primary DC
</em><em id="__mceDel"></em><em id="__mceDel"></em><em id="__mceDel"></em><em id="__mceDel">myDC04 ('Start') - Writable DC

</em><em id="__mceDel">Migration has not yet reached a consistent state on all domain controllers.
</em><em id="__mceDel"></em><em id="__mceDel">State information might be stale due to Active Directory Domain Services latency.
</em><em id="__mceDel"></em><em id="__mceDel"></em><em id="__mceDel">PS C:\users\mchateau\Desktop&gt;</em></pre>
<p>&nbsp;</p>
<p>Il ne reste plus qu&rsquo;à faire les 2 états suivants tour à tour:</p>
<pre>dfsrmig /SetGlobalState 2
<em id="__mceDel">dfsrmig /SetGlobalState 3</em></pre>
<p>&nbsp;</p>
<h3>Au final:</h3>
<pre>PS C:\users\mchateau\Desktop&gt; dfsrmig /GetMigrationState
<em id="__mceDel">All domain controllers have migrated successfully to the Global state ('Eliminated').
</em><em id="__mceDel"></em><em id="__mceDel">Migration has reached a consistent state on all domain controllers.
</em><em id="__mceDel"></em><em id="__mceDel"></em><em id="__mceDel">Succeeded.</em></pre>
<img src="http://feeds.feedburner.com/~r/lotp/~4/XVFLoEKjWeA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/dcdiag-verifyenterprisereferences-msdfsr-computerreferencebl-q312862/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/dcdiag-verifyenterprisereferences-msdfsr-computerreferencebl-q312862/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dcdiag-verifyenterprisereferences-msdfsr-computerreferencebl-q312862</feedburner:origLink></item>
		<item>
		<title>Nagios: multithreaded multi ping via nrpe</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/rijag9LpoDM/</link>
		<comments>http://www.lotp.fr/2013/05/nagios-multithreaded-multi-ping-nrpe/#comments</comments>
		<pubDate>Thu, 09 May 2013 09:46:38 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[nagios]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1489</guid>
		<description><![CDATA[L&#8217;objectif de ce plugin est tester via ping plusieurs cibles depuis un serveur via nrpe. Ce n&#8217;est donc pas le serveur nagios, mais bien un serveur supervisé par celui-ci qui fait le test.
Le plugin est exécuté localement, appelé via NRPE (et donc nsclient++ par exemple).
Etant multi threadé, la  [...]]]></description>
				<content:encoded><![CDATA[<p>L&rsquo;objectif de ce plugin est tester via ping plusieurs cibles depuis un serveur via nrpe. Ce n&rsquo;est donc pas le serveur nagios, mais bien un serveur supervisé par celui-ci qui fait le test.</p>
<p>Le plugin est exécuté localement, appelé via NRPE (et donc nsclient++ par exemple).</p>
<p>Etant multi threadé, la vitesse d&rsquo;exécution est presque constante (1.75s par cible en moyenne).</p>
<h2>Configuration testée</h2>
<p><strong>Linux:</strong></p>
<ul>
<li>Centos 6.4 x64</li>
<li>Nagios 3.4.4</li>
<li>check_nrpe 2.13</li>
<li>Centreon 2.4.2</li>
</ul>
<p><strong>Windows:</strong></p>
<ul>
<li>Windows Server 2008 R2 / 2012</li>
<li>nsclient++ 0.4.1 x64 et x86</li>
<li>Serveurs Core et normaux</li>
</ul>
<h2>Arguments du script</h2>
<ul>
<li>targets (séparées par des virgules, <strong>obligatoire</strong>)</li>
<li>maxWarn (Avertissement si le nombre de cible offline est supérieur) (1 par défaut)</li>
<li>maxError (Critique si le nombre de cible offline est supérieur) (5 par défaut)</li>
</ul>
<p>maxWarn et maxCrit doivent être des entiers</p>
<h2>Exemples d’utilisation</h2>
<p>Exemple en exécution directe PowerShell:</p>
<pre>PS C:\Program Files\NSClient++\scripts&gt;. .\lotp_check_multiping.ps1 www.google.com,www.lotp.fr 1 2 
OK:2 online - 0 offline - |online=2;1;2; offline=0;1;2;
PS C:\Program Files\NSClient++\scripts&gt;</pre>
<p>Exécution NRPE:</p>
<pre>[root~]# /usr/lib64/nagios/plugins/check_nrpe -H myMonitoredServer -n -c check_multiping -a www.google.com,www.lotp.fr 1 2
OK:2 online - 0 offline - |'online'=2;1;2 'offline'=0;1;2
[root~]#</pre>
<h2>Installation:</h2>
<p>Sur les Windows:</p>
<ul>
<li>Activer l’exécution de scripts PowerShell non signés : Set-ExecutionPolicy RemoteSigned</li>
<li>copier le script dans C:\Program Files\NSClient++\scripts</li>
<li>Ajouter dans le fichier nsclient.ini:
<ul>
<li>[/settings/external scripts/wrapped scripts]<br />
check_multiping=lotp_check_multiping.ps1 -targets $ARG1$ -maxWarn $ARG2$ -maxError $ARG3$</li>
</ul>
</li>
</ul>
<h2>Configuration:</h2>
<p>Par exemple, sur Centreon, en ajoutant la commande:</p>
<pre>$USER1$/check_nrpe -H $HOSTADDRESS$ -n -t 60 -c check_multiping -a $ARG1$ $ARG2$ $ARG3$</pre>
<h2>Téléchargement</h2>
<p><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_multiping.ps1_.txt">lotp_check_multiping.ps1</a></p>
<p>(enlever le .txt à la fin)</p>
<p>code source en direct:</p>

<div class="wp_syntax"><table><caption><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_multiping.ps1_.txt">/wp-content/uploads/2013/05/lotp_check_multiping.ps1_.txt</a></caption><tr><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># ====================================================================</span>
<span style="color: #008000;"># Ping a list of targets through NRPE</span>
<span style="color: #008000;"># Author: Mathieu Chateau - LOTP</span>
<span style="color: #008000;"># mail: mathieu.chateau@lotp.fr</span>
<span style="color: #008000;"># version 0.1</span>
<span style="color: #008000;"># ====================================================================</span>
&nbsp;
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Require Set-ExecutionPolicy RemoteSigned.. or sign this script with your PKI </span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #008000;"># ============================================================</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;">#  Do not change anything behind that line!</span>
<span style="color: #008000;">#</span>
<span style="color: #0000FF;">param</span> 
<span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$targets</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxWarn</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxError</span> <span style="color: pink;">=</span> <span style="color: #804000;">5</span>
<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #800080;">$countOK</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countKO</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$targetsArray</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$targetsArray</span><span style="color: pink;">=</span><span style="color: #800080;">$targets</span> <span style="color: pink;">-</span>split<span style="color: #000000;">&#40;</span><span style="color: #800000;">' '</span><span style="color: #000000;">&#41;</span>
Remove<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: pink;">*</span> <span style="color: #008080; font-style: italic;">-Confirm</span>:<span style="color: #800080;">$false</span> <span style="color: #008080; font-style: italic;">-Force</span>
<span style="color: #0000FF;">foreach</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$t</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$targetsArray</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	Start<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$t</span> <span style="color: #008080; font-style: italic;">-ArgumentList</span> <span style="color: #800080;">$t</span> <span style="color: pink;">-</span>ScriptBlock <span style="color: #000000;">&#123;</span><span style="color: #0000FF;">param</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$t</span><span style="color: #000000;">&#41;</span>;<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span>Test<span style="color: pink;">-</span>Connection <span style="color: #008080; font-style: italic;">-ComputerName</span> <span style="color: #800080;">$t</span>  <span style="color: #008080; font-style: italic;">-Count</span> <span style="color: #804000;">2</span> <span style="color: #008080; font-style: italic;">-Quiet</span> <span style="color: #008080; font-style: italic;">-ErrorAction</span> SilentlyContinue<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #0000FF;">return</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#125;</span><span style="color: #0000FF;">else</span><span style="color: #000000;">&#123;</span><span style="color: #0000FF;">return</span> <span style="color: #800080;">$false</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span><span style="color: #008080; font-weight: bold;">Out-Null</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">while</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Job <span style="color: pink;">-</span>State Running<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008080; font-weight: bold;">Start-Sleep</span> <span style="color: #008080; font-style: italic;">-Milliseconds</span> <span style="color: #804000;">500</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span> <span style="color: #0000FF;">in</span> Get<span style="color: pink;">-</span>Job<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=</span>Receive<span style="color: pink;">-</span>Job <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800080;">$job</span>.Name
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$countOK</span><span style="color: pink;">++</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$countKO</span><span style="color: pink;">++</span>
		<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800080;">$job</span>.Name<span style="color: pink;">+</span><span style="color: #800000;">&quot; - &quot;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$countKO</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxError</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;CRITICAL&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">elseif</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$countKO</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxWarn</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;WARNING&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">1</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;OK&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800080;">$state</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countOK</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; online&quot;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; - &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countKO</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; offline - &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$output</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">'|'</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">&quot;online=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countOK</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxError</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; &quot;</span>
<span style="color: #800080;">$output</span><span style="color: pink;">+=</span><span style="color: #800000;">&quot;offline=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$countKO</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxError</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$output</span>
exit $exitcode</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/lotp/~4/rijag9LpoDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/nagios-multithreaded-multi-ping-nrpe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/nagios-multithreaded-multi-ping-nrpe/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-multithreaded-multi-ping-nrpe</feedburner:origLink></item>
		<item>
		<title>SharePoint: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/Ta0r5tzk-qg/</link>
		<comments>http://www.lotp.fr/2013/05/sharepoint-local-farm-accessible-cmdlets-featuredependencyid-registered/#comments</comments>
		<pubDate>Wed, 08 May 2013 18:00:22 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sharepoint 2013]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1485</guid>
		<description><![CDATA[Top des possibilités:

le prompt Powershell n&#8217;est pas lancé en mode administrateur (prompt UAC)
Vous n&#8217;êtes pas administrateur local
Vous n&#8217;avez pas accès aux bases SQL. Le snapin doit se connecter à la base de configuration de la ferme.

Histoire de ne pas faire le post le plus court de l&#8217;année,  [...]]]></description>
				<content:encoded><![CDATA[<p>Top des possibilités:</p>
<ul>
<li><span style="line-height: 12.796875px;">le prompt Powershell n&rsquo;est pas lancé en mode administrateur (prompt UAC)</span></li>
<li>Vous n&rsquo;êtes pas administrateur local</li>
<li>Vous n&rsquo;avez pas accès aux bases SQL. Le snapin doit se connecter à la base de configuration de la ferme.</li>
</ul>
<p>Histoire de ne pas faire le post le plus court de l&rsquo;année, vous pouvez vérifier avec Process Explorer si vous êtes vraiment administrateur (aka UAC elevated):</p>
<ul>
<li><span style="line-height: 12.796875px;">Deny : vous êtes membres mais UAC vous bloque. Il faut relancer en run as administrator</span></li>
<li>Owner: vous êtes bien administrateur avec UAC elevated. Donc c&rsquo;est SQL le problème <img src='http://www.lotp.fr/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<p style="text-align: center;"><a href="http://www.lotp.fr/wp-content/uploads/2013/05/06-05-2013-22-52-21.jpg"><img class="aligncenter  wp-image-1486" alt="06-05-2013 22-52-21" src="http://www.lotp.fr/wp-content/uploads/2013/05/06-05-2013-22-52-21.jpg" width="646" height="564" /></a></p>
<p style="text-align: center;"><a href="http://www.lotp.fr/wp-content/uploads/2013/05/06-05-2013-22-53-32.jpg"><img class="aligncenter  wp-image-1487" alt="06-05-2013 22-53-32" src="http://www.lotp.fr/wp-content/uploads/2013/05/06-05-2013-22-53-32.jpg" width="649" height="568" /></a></p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/lotp/~4/Ta0r5tzk-qg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/sharepoint-local-farm-accessible-cmdlets-featuredependencyid-registered/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/sharepoint-local-farm-accessible-cmdlets-featuredependencyid-registered/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sharepoint-local-farm-accessible-cmdlets-featuredependencyid-registered</feedburner:origLink></item>
		<item>
		<title>page sur mon outillage</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/OP3Zp3XxDZo/</link>
		<comments>http://www.lotp.fr/2013/05/page-sur-mon-outillage/#comments</comments>
		<pubDate>Mon, 06 May 2013 17:29:42 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1483</guid>
		<description><![CDATA[Pour les distraits ou féru de flux RSS, je viens pour info de publier une page sur les outils que j&#8217;utilise 
Enjoy
]]></description>
				<content:encoded><![CDATA[<p>Pour les distraits ou féru de flux RSS, je viens pour info de publier une page sur les<a title="Outillages" href="http://www.lotp.fr/outillages/"> outils que j&rsquo;utilise </a></p>
<p><a title="Outillages" href="http://www.lotp.fr/outillages/">Enjoy</a></p>
<img src="http://feeds.feedburner.com/~r/lotp/~4/OP3Zp3XxDZo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/page-sur-mon-outillage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/page-sur-mon-outillage/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=page-sur-mon-outillage</feedburner:origLink></item>
		<item>
		<title>Nagios: Superviser les horloges Windows</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/xSK6ODniHMw/</link>
		<comments>http://www.lotp.fr/2013/05/nagios-superviser-les-horloges-windows/#comments</comments>
		<pubDate>Mon, 06 May 2013 13:48:01 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[nagios]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1472</guid>
		<description><![CDATA[L’objectif de ce plugin pour Nagios est de superviser l&#8217;heure sur les serveurs Windows non DC.
Les serveurs membres ne peuvent pas par défaut être interrogé en ntp comme les DC pour vérifier leur horloge.
J’utilise l’agent nsclient++ sur les serveurs afin de pouvoir exécuter des scripts PowerShell  [...]]]></description>
				<content:encoded><![CDATA[<p>L’objectif de ce plugin pour Nagios est de superviser l&rsquo;heure sur les serveurs Windows non DC.</p>
<p>Les serveurs membres ne peuvent pas par défaut être interrogé en ntp comme les DC pour vérifier leur horloge.</p>
<p>J’utilise l’agent <a title="site officiel nsclient++" href="http://www.nsclient.org/nscp/" target="_blank">nsclient++</a> sur les serveurs afin de pouvoir exécuter des scripts PowerShell entre autre. On a donc:</p>
<p>Nagios =&gt; check_nrpe =&gt; script powershell =&gt; retour nagios</p>
<p>Cela fonctionne également sur les serveurs Core.</p>
<p>Si aucun serveur de référence n&rsquo;est fourni, le script fonctionne ainsi:</p>
<ul>
<li>Si un serveur de référence est fourni, utilisation de celui-ci</li>
<li>Sinon:
<ul>
<li><span style="line-height: 12.796875px;">Si joint à un domaine, essaye de récupérer la variable logonserver. Si cela échoue, prend un DC au hasard. en cas d&rsquo;erreur, essaye avec pool.ntp.org</span></li>
<li>Si n&rsquo;est pas joint à un domaine, essaye avec pool.ntp.org</li>
</ul>
</li>
</ul>
<p>Fourni la &laquo;&nbsp;jigue&nbsp;&raquo; en temps que performance pour les graphes.</p>
<h2>Configuration testée</h2>
<p><strong>Linux:</strong></p>
<ul>
<li>Centos 6.4 x64</li>
<li>Nagios 3.4.4</li>
<li>check_nrpe 2.13</li>
<li>Centreon 2.4.2</li>
</ul>
<p><strong>Windows:</strong></p>
<ul>
<li>Windows Server 2003 / 2008 R2 / 2012</li>
<li>nsclient++ 0.4.1 x64 et x86</li>
<li>Serveurs Core et normaux</li>
</ul>
<h2>Arguments du script</h2>
<ul>
<li>refTimeServer (AD find ou pool.ntp.org par défaut)</li>
<li>maxWarn (Avertissement si supérieur, en secondes) (1 par défaut)</li>
<li>maxError (Critique si supérieur, en secondes) (5 par défaut)</li>
</ul>
<p>&nbsp;</p>
<p>maxWarn et maxCrit doivent être des entiers</p>
<h2>Exemples d’utilisation</h2>
<p>Exemple en exécution directe PowerShell:</p>
<pre>PS C:Program FilesNSClient++scripts&gt; . .\lotp_check_time.ps1 
OK:-00.0307684s - checked against pool.ntp.org|offset=-00.0307684s;1;5;
PS C:Program FilesNSClient++scripts&gt;</pre>
<p>Exécution NRPE:</p>
<pre>[root~]# /usr/lib64/nagios/plugins/check_nrpe -H myserver -n -c check_time -a "myPDCServer" 1 5 
OK:+00.0671837s - checked against myPDCServer|'offset'=0.06718s;1;5
[root~]#</pre>
<h2>Installation:</h2>
<p>Sur les Windows:</p>
<ul>
<li>Activer l’exécution de scripts PowerShell non signés : Set-ExecutionPolicy RemoteSigned</li>
<li>copier le script dans C:\Program Files\NSClient++\scripts</li>
<li>Ajouter dans le fichier nsclient.ini:
<ul>
<li>[/settings/external scripts/wrapped scripts]<br />
check_time=lotp_check_time.ps1 -refTimeServer $ARG1$ -maxWarn $ARG2$ -maxError $ARG3$</li>
</ul>
</li>
</ul>
<h2>Configuration:</h2>
<p>Par exemple, sur Centreon, en ajoutant la commande:</p>
<pre>$USER1$/check_nrpe -H $HOSTADDRESS$ -n -c check_time -a \"$ARG1$\" $ARG2$ $ARG3$</pre>
<h2>Téléchargement</h2>
<p>(enlever le .txt à la fin)</p>
<p><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_time.ps1_.txt">lotp_check_time.ps1</a></p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><caption><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_time.ps1_.txt">/wp-content/uploads/2013/05/lotp_check_time.ps1_.txt</a></caption><tr><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># ====================================================================</span>
<span style="color: #008000;"># Check time against DC or specified server through NRPE / w32tm</span>
<span style="color: #008000;"># Author: Mathieu Chateau - LOTP</span>
<span style="color: #008000;"># mail: mathieu.chateau@lotp.fr</span>
<span style="color: #008000;"># version 0.1</span>
<span style="color: #008000;"># ====================================================================</span>
&nbsp;
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Require Set-ExecutionPolicy RemoteSigned.. or sign this script with your PKI </span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #008000;"># ============================================================</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;">#  Do not change anything behind that line!</span>
<span style="color: #008000;">#</span>
<span style="color: #0000FF;">param</span> 
<span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">string</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$refTimeServer</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxWarn</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxError</span> <span style="color: pink;">=</span> <span style="color: #804000;">5</span>
<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #800080;">$random</span><span style="color: pink;">=</span>
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot; &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$refTimeServer</span><span style="color: pink;">=</span><span style="color: #800080;">$env</span>:LOGONSERVER <span style="color: #FF0000;">-replace</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">'\\'</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;^$|^ $&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$env</span>:LOGONSERVER <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$refTimeServer</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">gwmi</span> win32_computersystem<span style="color: #000000;">&#41;</span>.partofdomain <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$true</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #008000;">#Must use select and not .Name directly. If some DC are down, command will be empty with .Name</span>
			<span style="color: #800080;">$fromAD</span><span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>System.DirectoryServices.ActiveDirectory.Domain<span style="color: #000000;">&#93;</span>::GetCurrentDomain<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: pink;">|</span> <span style="color: pink;">%</span> <span style="color: #000000;">&#123;</span> <span style="color: #000080;">$_</span>.DomainControllers <span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> Name 
			<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$entry</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$fromAD</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$env</span>:COMPUTERNAME <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$entry</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$entry</span> <span style="color: #FF0000;">-match</span> <span style="color: #800080;">$env</span>:COMPUTERNAME<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #008000;">#this server is a DC, can't check time against itself</span>
					<span style="color: #800080;">$fromAD</span>.Remove<span style="color: #000000;">&#40;</span><span style="color: #800080;">$entry</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$fromAD</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #008000;">#get a random DC from AD, as no server provided and no logon server could be found</span>
				<span style="color: #800080;">$refTimeServer</span><span style="color: pink;">=</span><span style="color: #000000;">&#40;</span>Get<span style="color: pink;">-</span>Random <span style="color: #008080; font-style: italic;">-InputObject</span> <span style="color: #800080;">$fromAD</span><span style="color: #000000;">&#41;</span>.Name
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0000FF;">else</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #008000;">#only one DC, defaulting to internet</span>
				<span style="color: #800080;">$refTimeServer</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;pool.ntp.org&quot;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#125;</span>
		<span style="color: #0000FF;">else</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #008000;">#Workgroup but no server to check time against provided. Defaulting to internet to do something</span>
			<span style="color: #800080;">$refTimeServer</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;pool.ntp.org&quot;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$refTimeServer</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">&quot; &quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #008000;">#Something bad happened. Should never happen</span>
	<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800000;">&quot;CRITICAL: can't auto detect logon server to check against. Need to specify manually using refTimeServer argument&quot;</span>
	exit <span style="color: #804000;">2</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$temp</span><span style="color: pink;">=</span>w32tm <span style="color: pink;">/</span>stripchart <span style="color: pink;">/</span>computer:<span style="color: #800080;">$refTimeServer</span> <span style="color: pink;">/</span>period:<span style="color: #804000;">1</span> <span style="color: pink;">/</span>dataonly <span style="color: pink;">/</span>samples:<span style="color: #804000;">1</span>
<span style="color: #800080;">$temp</span><span style="color: pink;">=</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> <span style="color: #008080; font-style: italic;">-Last</span> <span style="color: #804000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-replace</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;.*, &quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #800080;">$temp</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span> <span style="color: #FF0000;">-replace</span> <span style="color: #000000;">&#40;</span><span style="color: #800000;">&quot;s$&quot;</span><span style="color: pink;">,</span><span style="color: #800000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span> <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;^(\+|\-)[0-9]+\.[0-9]+$&quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;s - checked against &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$refTimeServer</span>
	<span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::abs<span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxError</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;CRITICAL&quot;</span>
		<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">elseif</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#91;</span>math<span style="color: #000000;">&#93;</span>::abs<span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxWarn</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;WARNING&quot;</span>
		<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">1</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">else</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;OK&quot;</span>
		<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;Error: - used $refTimeServer as time server - output:$temp&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800080;">$state</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$output</span><span style="color: pink;">+</span><span style="color: #800080;">$random</span><span style="color: pink;">+</span><span style="color: #800000;">'|'</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;offset=&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$temp</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;s&quot;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$maxError</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;;&quot;</span>
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$output</span>
exit $exitcode</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/lotp/~4/xSK6ODniHMw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/nagios-superviser-les-horloges-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/nagios-superviser-les-horloges-windows/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-superviser-les-horloges-windows</feedburner:origLink></item>
		<item>
		<title>SharePoint – event 8311 – SSL policy errors have been encountered.  Error code 0×2</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/KtgBHwDwjSY/</link>
		<comments>http://www.lotp.fr/2013/05/sharepoint-event-8311-ssl-policy-errors-encountered-error-code-0x2/#comments</comments>
		<pubDate>Mon, 06 May 2013 10:54:53 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[sharepoint 2013]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1469</guid>
		<description><![CDATA[&#160;
&#160;
&#160;
&#160;
SharePoint n&#8217;est pas avare en message, et ils ont presque toujours une origine, reste à trouver laquelle&#8230;
Cette fois, le message suivant est apparu sur la ferme 2010 et 2013:

Ce qui donne:
Log Name: Application
Source: Microsoft-SharePoint Products-SharePoint Foundation
Event ID:  [...]]]></description>
				<content:encoded><![CDATA[<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>SharePoint n&rsquo;est pas avare en message, et ils ont presque toujours une origine, reste à trouver laquelle&#8230;</p>
<p>Cette fois, le message suivant est apparu sur la ferme 2010 et 2013:<br />
<a href="http://www.lotp.fr/wp-content/uploads/2013/05/sharepoint-event-8311.jpg"><img class="aligncenter size-full wp-image-1470" alt="sharepoint event 8311" src="http://www.lotp.fr/wp-content/uploads/2013/05/sharepoint-event-8311.jpg" width="632" height="440" /></a></p>
<p>Ce qui donne:</p>
<pre><strong>Log Name</strong>: Application
<strong>Source</strong>: Microsoft-SharePoint Products-SharePoint Foundation
<strong>Event ID</strong>: 8311
<strong>Task Category</strong>: Topology
<strong>Level</strong>: Error
<strong>Description</strong>:
An operation failed because the following certificate has validation errors:\n\nSubject Name: CN=Server.mydomain.net\nIssuer Name: CN=my-CA, DC=mydomain, DC=net

Errors:\n\n SSL policy errors have been encountered. Error code '0x2'..</pre>
<p><em id="__mceDel"> </em></p>
<h2>Cause</h2>
<p>Un certificat a été assigné dans IIS pour le site <strong>SharePoint Web Services</strong> (binding SSL port 32844).</p>
<p>&nbsp;</p>
<h2>Résolution</h2>
<p>Le problème ne vient pas de la confiance du certificat, mais du <strong>subject name</strong>. Il s&rsquo;avère que le serveur est enregistré avec le nom court dans la ferme, et que le certificat contient le FQDN.</p>
<p>2 solutions:</p>
<ul>
<li><span style="line-height: 12.796875px;">Générer un autre certificat avec un subject name qui correspond au serveur,</span></li>
<li>Renommer le serveur dans la ferme SharePoint.</li>
</ul>
<p>C&rsquo;est cette deuxième option qui a été renommé, à faire en PowerShell.</p>
<p>Lister les serveurs avec leur nom inscrit dans la ferme:</p>
<pre>get-spserver</pre>
<p>Renommer un serveur (à lancer localement sur le serveur):</p>
<pre>Rename-SPServer -Identity MyServer -Name MyServer.MyDomain.net</pre>
<p>Faire un iisreset ensuite, et patienter 10mn que la topology se mette à jour <img src='http://www.lotp.fr/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<img src="http://feeds.feedburner.com/~r/lotp/~4/KtgBHwDwjSY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/sharepoint-event-8311-ssl-policy-errors-encountered-error-code-0x2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/sharepoint-event-8311-ssl-policy-errors-encountered-error-code-0x2/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=sharepoint-event-8311-ssl-policy-errors-encountered-error-code-0x2</feedburner:origLink></item>
		<item>
		<title>Nagios: Superviser les certificats dans Windows</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/vScpGv7GZNk/</link>
		<comments>http://www.lotp.fr/2013/05/nagios-superviser-les-certificats-dans-windows/#comments</comments>
		<pubDate>Sun, 05 May 2013 19:12:52 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[nagios]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[outil]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1455</guid>
		<description><![CDATA[L’objectif de ce plugin pour Nagios est de superviser l’état des certificats, et leur date d&#8217;expiration en particulier (oui, je ne fais pas que du SCOM malgré un ouvrage ENI dessus!)
J’utilise l’agent nsclient++ sur les serveurs afin de pouvoir exécuter des scripts PowerShell entre autre. On a  [...]]]></description>
				<content:encoded><![CDATA[<p>L’objectif de ce plugin pour Nagios est de superviser l’état des certificats, et leur date d&rsquo;expiration en particulier (oui, je ne fais pas que du SCOM malgré un ouvrage ENI dessus!)</p>
<p>J’utilise l’agent <a title="site officiel nsclient++" href="http://www.nsclient.org/nscp/" target="_blank">nsclient++</a> sur les serveurs afin de pouvoir exécuter des scripts PowerShell entre autre. On a donc:</p>
<p>Nagios =&gt; check_nrpe =&gt; script powershell =&gt; retour nagios</p>
<p>Cela fonctionne également sur les serveurs Core.</p>
<p>Windows contient des certificats déjà expiré depuis longtemps. Le script contient une blacklist afin de les ignorer.</p>
<p><span style="font-size: 26px; letter-spacing: -0.03em; line-height: normal;">Configuration testée</span></p>
<p><strong>Linux:</strong></p>
<ul>
<li>Centos 6.4 x64</li>
<li>Nagios 3.4.4</li>
<li>check_nrpe 2.13</li>
<li>Centreon 2.4.2</li>
</ul>
<p><strong>Windows:</strong></p>
<ul>
<li>Windows Server 2003 / 2008 R2 / 2012</li>
<li>nsclient++ 0.4.1 x64 et x86</li>
<li>Serveurs Core et normaux</li>
</ul>
<h2>Arguments du script</h2>
<ul>
<li>checkMyStore (oui par défaut)</li>
<li>checkRootStore (oui par défaut)</li>
<li>checkCAStore (oui par défaut)</li>
<li>checkAuthRootStore (oui par défaut)</li>
<li>checkSharePointStore (oui par défaut)</li>
<li>expireInDays (60 jours par défaut)</li>
<li>maxWarn (avertissement si supérieur)</li>
<li>maxCrit (Critique si supérieur)</li>
</ul>
<p>Pour chaque store, la réponse doit être un booléen ($true /$false ou 1/0)</p>
<p>expireInDays,maxWarn et maxCrit doivent être des entiers</p>
<h2>Exemples d’utilisation</h2>
<p>Exemple en exécution directe PowerShell:</p>
<pre>PS C:\Program Files\NSClient++\scripts&gt; . .\lotp_check_certificates.ps1
CRITICAL: www.lotp.fr:2013/06/30
PS C:\Program Files\NSClient++\scripts&gt;</pre>
<p>Exécution NRPE:</p>
<pre>[root~]# /usr/lib64/nagios/plugins/check_nrpe -H myserver -n -c check_certificate -a \$true \$true \$true \$true \$true 60 0 0

CRITICAL: www.lotp.fr:2013/06/30

[root~]#</pre>
<h2>Installation:</h2>
<p>Sur les Windows:</p>
<ul>
<li>Activer l’exécution de scripts PowerShell non signés : Set-ExecutionPolicy RemoteSigned</li>
<li>copier le script dans C:\Program Files\NSClient++\scripts</li>
<li>Ajouter dans le fichier nsclient.ini:
<ul>
<li><em id="__mceDel">[/settings/external scripts/wrapped scripts]<br />
check_certificate=lotp_check_certificate.ps1 $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$<br />
</em></li>
</ul>
</li>
</ul>
<h2>Configuration:</h2>
<p>Par exemple, sur Centreon, en ajoutant la commande:</p>
<pre>$USER1$/check_nrpe -H $HOSTADDRESS$ -n -c check_certificate -a $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$</pre>
<h2>Téléchargement</h2>
<p>(enlever le .txt à la fin)</p>
<p><a href="http://www.lotp.fr/wp-content/uploads/2013/05/lotp_check_certificates.ps1_.txt">lotp_check_certificates.ps1</a></p>
<p>Code source en direct si le téléchargement ne passe pas:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><caption><a href="http://www.lotp.fr/?attachment_id=1456">/</a></caption><tr><td class="code"><pre class="powershell" style="font-family:monospace;"><span style="color: #008000;"># ====================================================================</span>
<span style="color: #008000;"># Check certificates health state</span>
<span style="color: #008000;"># Author: Mathieu Chateau - LOTP</span>
<span style="color: #008000;"># mail: mathieu.chateau@lotp.fr</span>
<span style="color: #008000;"># version 0.1</span>
<span style="color: #008000;"># ====================================================================</span>
&nbsp;
<span style="color: #008000;">#</span>
<span style="color: #008000;"># Require Set-ExecutionPolicy RemoteSigned.. or sign this script with your PKI </span>
<span style="color: #008000;">#</span>
&nbsp;
<span style="color: #008000;"># ============================================================</span>
<span style="color: #008000;">#</span>
<span style="color: #008000;">#  Do not change anything behind that line!</span>
<span style="color: #008000;">#</span>
<span style="color: #0000FF;">param</span> 
<span style="color: #000000;">&#40;</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">bool</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$checkMyStore</span><span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">bool</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$checkRootStore</span><span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">bool</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$checkCAStore</span><span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">bool</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$checkAuthRootStore</span><span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">bool</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$checkSharePointStore</span><span style="color: pink;">=</span><span style="color: #800080;">$true</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$expireInDays</span><span style="color: pink;">=</span><span style="color: #804000;">60</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxWarn</span> <span style="color: pink;">=</span> <span style="color: #804000;">1</span><span style="color: pink;">,</span>
	<span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #800080;">$maxError</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>
&nbsp;
<span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #008000;"># blacklist all third party known expired certificates in root &amp;amp; co, on Windows Server 2003, 2008 &amp;amp; 2012</span>
<span style="color: #800080;">$blacklist</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span>
<span style="color: #800000;">&quot;109F1CAED645BB78B3EA2B94C0697C740733031C&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;12519AE9CD777A560184F1FBD54215222E95E71F&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;127633A94F39CBF6EDF7C7BF64C4B535E9706E9A&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;18F7C1FCC3090203FD5BAA2F861A754976C8DD25&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;23EF3384E21F70F034C467D4CBA6EB61429F174E&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;245C97DF7514E7CF2DF8BE72AE957B9E04741E85&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;24A40A1F573643A67F0A4B0749F6A22BF28ABB6B&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;24BA6D6C8A5B5837A48DB5FAE919EA675C94D217&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;2B84BFBB34EE2EF949FE1CBE30AA026416EB2216&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;3A850044D8A195CD401A680C012CB0A3B5F8DC08&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4463C531D7CCC1006794612BB656D3BF8257846F&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;47AFB915CDA26D82467B97FA42914468726138DD&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4BA7B9DDD68788E12FF852E1A024204BF286A8F6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4D8547B7F864132A7F62D9B75B068521F10B68E3&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4DF13947493CFF69CDE554881C5F114E97C3D03B&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4EF2E6670AC9B5091FE06BE0E5483EAAD6BA32D9&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;4F65566336DB6598581D584A596C87934D5F2AB4&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;51C3247D60F356C7CA3BAF4C3F429DAC93EE7B74&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;53DECDF3BC1BDE7C9D1CEDAE718468CA20CC43E7&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;587B59FB52D8A683CBE1CA00E6393D7BB923BC92&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;5E997CA5945AAB75FFD14804A974BF2AE1DFE7E1&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;637162CC59A3A1E25956FA5FA8F60D2E1C52EAC6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;6690C02B922CBD3FF0D0A5994DBD336592887E3F&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;67EB337B684CEB0EC2B0760AB488278CDD9597DD&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;687EC17E0602E3CD3F7DFBD7E28D57A0199A3F44&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;688B6EB807E8EDA5C7B17C4393D0795F0FAE155F&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;68ED18B309CD5291C0D3357C1D1141BF883866B1&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;720FC15DDC27D456D098FABF3CDD78D31EF5A8DA&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7613BF0BA261006CAC3ED2DDBEF343425357F18B&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7A74410FB0CD5C972A364B71BF031D88A6510E9E&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7AC5FFF8DCBC5583176877073BF751735E9BD358&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7B02312BACC59EC388FEAE12FD277F6A9FB4FAC1&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7CA04FD8064C1CAA32A37AA94375038E8DF8DDC0&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7D7F4414CCEF168ADF6BF40753B5BECD78375931&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;7F88CD7223F3C813818C994614A89C99FA3B5247&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;838E30F77FDD14AA385ED145009C0E2236494FAA&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;8977E8569D2A633AF01D0394851681CE122683A6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;8B24CD8D8B58C6DA72ACE097C7B1E3CEA4DC3DC6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;9078C5A28F9A4325C2A7C73813CDFE13C20F934E&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;90DEDE9E4C4E9F6FD88617579DD391BC65A68964&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;96974CD6B663A7184526B1D648AD815CF51E801A&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;9845A431D51959CAF225322B4A4FE9F223CE6D15&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;9BACF3B664EAC5A17BED08437C72E4ACDA12F7E7&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;9FC796E8F8524F863AE1496D381242105F1B78F5&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;A1505D9843C826DD67ED4EA5209804BDBB0DF502&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;A399F76F0CBF4C9DA55E4AC24E8960984B2905B6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;A3E31E20B2E46A328520472D0CDE9523E7260C6D&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;A5EC73D48C34FCBEF1005AEB85843524BBFAB727&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;B19DD096DCD4E3E0FD676885505A672C438D4E9C&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;B533345D06F64516403C00DA03187D3BFEF59156&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;B6AF5BE5F878A00114C3D7FEF8C775C34CCD17B6&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;B72FFF92D2CE43DE0A8D4C548C503726A81E2B93&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;CFDEFE102FDA05BBE4C78D2E4423589005B2571D&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;D29F6C98BEFC6D986521543EE8BE56CEBC288CF3&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;DBAC3C7AA4254DA1AA5CAAD68468CB88EEDDEEA8&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;E38A2B7663B86796436D8DF5898D9FAA6835B238&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;EC0C3716EA9EDFADD35DFBD55608E60A05D3CBF3&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;EF2DACCBEABB682D32CE4ABD6CB90025236C07BC&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;F5A874F3987EB0A9961A564B669A9050F770308A&quot;</span><span style="color: pink;">,</span>
<span style="color: #800000;">&quot;F88015D3F98479E1DA553D24FD42BA3F43886AEF&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
<span style="color: #800080;">$outputNames</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
<span style="color: #800080;">$countMyStore</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countRootStore</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countCAStore</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countAuthRootStore</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countSharePointStore</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #800080;">$countTotal</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
&nbsp;
<span style="color: #800080;">$allCerts</span><span style="color: pink;">=</span><span style="color: #008080; font-weight: bold;">Get-ChildItem</span> <span style="color: #008080; font-style: italic;">-Path</span> cert: <span style="color: #008080; font-style: italic;">-Recurse</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span>
<span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.Notafter <span style="color: #FF0000;">-lt</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span><span style="color: #000000;">&#41;</span>.AddDays<span style="color: #000000;">&#40;</span><span style="color: #800080;">$expireInDays</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span> 
<span style="color: #000000;">&#40;</span><span style="color: #000080;">$_</span>.PSPParentPath <span style="color: #FF0000;">-notmatch</span> <span style="color: #800000;">&quot;Disallowed&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-and</span>
<span style="color: #000000;">&#40;</span><span style="color: #800080;">$blacklist</span> <span style="color: #FF0000;">-notcontains</span> <span style="color: #000080;">$_</span>.Thumbprint<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">select</span> NotAfter<span style="color: pink;">,</span>FriendlyName<span style="color: pink;">,</span>PSParentPath
&nbsp;
<span style="color: #0000FF;">function</span> outputCert <span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$outputTemp</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;&quot;</span>
	<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$t</span> <span style="color: #0000FF;">in</span> <span style="color: #800080;">$temp</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputTemp</span><span style="color: pink;">+=</span><span style="color: #800080;">$t</span>.FriendlyName<span style="color: pink;">+</span><span style="color: #800000;">&quot;:&quot;</span><span style="color: pink;">+</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">get-date</span> <span style="color: #008080; font-style: italic;">-Date</span> <span style="color: #800080;">$t</span>.NotAfter <span style="color: #008080; font-style: italic;">-format</span> <span style="color: #800000;">&quot;yyyy/MM/dd&quot;</span><span style="color: #000000;">&#41;</span><span style="color: pink;">+</span><span style="color: #800000;">&quot; &quot;</span>
	<span style="color: #000000;">&#125;</span>
	<span style="color: #0000FF;">return</span> <span style="color: #800080;">$outputTemp</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #008000;"># check params if provided</span>
&nbsp;
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$checkMyStore</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$allCerts</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PSParentPath <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;\\My$&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$countMyStore</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span>.Count
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputNames</span><span style="color: pink;">+=</span>outputCert <span style="color: #800080;">$temp</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$checkRootStore</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$allCerts</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PSParentPath <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;\\Root$&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$countRootStore</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span>.Count
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputNames</span><span style="color: pink;">+=</span>outputCert <span style="color: #800080;">$temp</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$checkCAStore</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$allCerts</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PSParentPath <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;\\CA$&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$countCAStore</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span>.Count
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputNames</span><span style="color: pink;">+=</span>outputCert <span style="color: #800080;">$temp</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$checkAuthRootStore</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$allCerts</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PSParentPath <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;\\AuthRoot$&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$countAuthRootStore</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span>.Count
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputNames</span><span style="color: pink;">+=</span>outputCert <span style="color: #800080;">$temp</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$checkSharePointStore</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$temp</span><span style="color: pink;">=@</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$allCerts</span> <span style="color: pink;">|</span> <span style="color: pink;">?</span> <span style="color: #000000;">&#123;</span><span style="color: #000080;">$_</span>.PSParentPath <span style="color: #FF0000;">-match</span> <span style="color: #800000;">&quot;\\SharePoint$&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #800080;">$countSharePointStore</span><span style="color: pink;">=</span><span style="color: #800080;">$temp</span>.Count
	<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$temp</span>.Count <span style="color: #FF0000;">-gt</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #800080;">$outputNames</span><span style="color: pink;">+=</span>outputCert <span style="color: #800080;">$temp</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">foreach</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$var</span> <span style="color: #0000FF;">in</span> <span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Variable</span> <span style="color: #008080; font-style: italic;">-Name</span> <span style="color: #800000;">&quot;count*Store&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$countTotal</span><span style="color: pink;">+=</span>$<span style="color: #000000;">&#40;</span><span style="color: #800080;">$var</span><span style="color: #000000;">&#41;</span>.Value
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$countTotal</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxError</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;CRITICAL&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">2</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">elseif</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$countTotal</span> <span style="color: #FF0000;">-gt</span> <span style="color: #800080;">$maxWarn</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;WARNING&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">1</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000FF;">else</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #800080;">$state</span><span style="color: pink;">=</span><span style="color: #800000;">&quot;OK&quot;</span>
	<span style="color: #800080;">$exitcode</span><span style="color: pink;">=</span><span style="color: #804000;">0</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #800080;">$output</span><span style="color: pink;">=</span><span style="color: #800080;">$state</span><span style="color: pink;">+</span><span style="color: #800000;">&quot;: &quot;</span><span style="color: pink;">+</span><span style="color: #800080;">$outputNames</span>
&nbsp;
<span style="color: #008080; font-weight: bold;">Write-Host</span> <span style="color: #800080;">$output</span>
exit $exitcode</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/lotp/~4/vScpGv7GZNk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/05/nagios-superviser-les-certificats-dans-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/05/nagios-superviser-les-certificats-dans-windows/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-superviser-les-certificats-dans-windows</feedburner:origLink></item>
		<item>
		<title>Nagios: Superviser les comptes Active Directory</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/t1XL70Hl0eM/</link>
		<comments>http://www.lotp.fr/2013/04/nagios-superviser-les-comptes-active-directory/#comments</comments>
		<pubDate>Sun, 28 Apr 2013 14:15:13 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[nagios]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[téléchargement]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[centreon]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1445</guid>
		<description><![CDATA[L'objectif de ce plugin pour Nagios est de superviser l'état des comptes AD (oui, je ne fais pas que du SCOM malgré un ouvrage ENI dessus!)

J'utilise l'agent nsclient++ sur les serveurs afin de pouvoir exécuter des scripts PowerShell entre autre. On a donc:

Nagios => check_nrpe => script powershell => retour nagios

Je m'appui sur le module PowerShell Standard ActiveDirectory. Cela fonctionne également sur les serveurs Core.

La supervision peut porter sur:

Account Disabled
Account Expired
Account Expiring
Account Inactive
Locked Out
Password Expired
Password Never Expires]]></description>
				<content:encoded><![CDATA[<p>L&rsquo;objectif de ce plugin pour Nagios est de superviser l&rsquo;état des comptes AD (oui, je ne fais pas que du SCOM malgré un ouvrage ENI dessus!)</p>
<p>J&rsquo;utilise l&rsquo;agent <a title="site officiel nsclient++" href="http://www.nsclient.org/nscp/" target="_blank">nsclient++</a> sur les serveurs afin de pouvoir exécuter des scripts PowerShell entre autre. On a donc:</p>
<p>Nagios =&gt; check_nrpe =&gt; script powershell =&gt; retour nagios</p>
<p>Je m&rsquo;appui sur le module PowerShell Standard ActiveDirectory. Cela fonctionne également sur les serveurs Core.</p>
<p>La supervision peut porter sur:</p>
<ul>
<li><span style="line-height: 18px; font-size: 0.8em;">Account Disabled</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Account Expired</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Account Expiring</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Account Inactive</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Locked Out</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Password Expired</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Password Never Expires</span></li>
</ul>
<p>La sortie fournie les données pour avoir un graphe (performance data)</p>
<h2>Configuration testée</h2>
<p><strong>Linux:</strong></p>
<ul>
<li><span style="line-height: 18px; font-size: 0.8em;">Centos 6.4 x64</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Nagios 3.4.4</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">check_nrpe 2.13</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">Centreon 2.4.2</span></li>
</ul>
<p><strong>Active Directory:</strong></p>
<ul>
<li><span style="line-height: 18px; font-size: 0.8em;">Windows Server 2008 R2 / Windows Server 2012</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">nsclient++ 0.4.1 x64</span></li>
<li><span style="font-size: 0.8em; line-height: 18px;">Serveurs Core et normaux</span></li>
</ul>
<h2>Arguments du script</h2>
<ul>
<li><span style="line-height: 18px; font-size: 0.8em;">action (LockedOut par défaut)</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">searchBase (tout le domaine par défaut)</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">seachScope (récursif par défaut)</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">maxWarn (avertissement si supérieur)</span></li>
<li><span style="line-height: 18px; font-size: 0.8em;">maxCrit (Critique si supérieur)</span></li>
</ul>
<p>action peut être:<br />
AccountDisabled,AccountExpired,AccountExpiring,AccountInactive,LockedOut,PasswordExpired,PasswordNeverExpires<br />
LockedOut par défaut</p>
<p>searchBase peut être:<br />
dc=mydomain,dc=com / ou=my users,dc=mydomain,dc=com<br />
tout le domaine par défaut</p>
<p>seachScope peut être:<br />
Base,OneLevel,Subtree<br />
Subtree par défaut</p>
<p>maxWarn and maxCrit doivent être des entiers</p>
<h2>Exemples d&rsquo;utilisation</h2>
<p>Exemple en exécution directe PowerShell:</p>
<pre>PS C:\Program Files\NSClient++\scripts&gt; . .\lotp_check_ad_accounts.ps1 AccountInactive "dc=mydomain,dc=com" subtree 5 10
CRITICAL: 216 AccountInactive|216;5;10
PS C:\Program Files\NSClient++\scripts&gt;</pre>
<p>Exécution NRPE:</p>
<pre>[root~]# /usr/lib64/nagios/plugins/check_nrpe -H prd-dom-dc01 -n -c check_ad_account -a AccountInactive \"dc=pmside,dc=net\" subtree 5 10

CRITICAL: 216 AccountInactive|'AccountInactive'=216;5;10

[root~]#</pre>
<h2>Installation:</h2>
<p>Sur les DC:</p>
<ul>
<li>Activer l&rsquo;exécution de scripts PowerShell non signés : Set-ExecutionPolicy RemoteSigned</li>
<li>copier le script dans C:\Program Files\NSClient++\scripts</li>
<li>Ajouter dans le fichier nsclient.ini:
<ul>
<li><em id="__mceDel">[/settings/external scripts/wrapped scripts]<br />
check_ad_account=lotp_check_ad_accounts.ps1 $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$</em></li>
</ul>
</li>
</ul>
<h2>Configuration:</h2>
<p>Par exemple, sur Centreon, en ajoutant la commande:</p>
<pre>$USER1$/check_nrpe -H $HOSTADDRESS$ -n -c check_ad_account -a $ARG1$ \"$ARG2$\" $ARG3$ $ARG4$ $ARG5$</pre>
<h2>Téléchargement</h2>
<p>(enlever le .txt à la fin)</p>
<p><a href="http://www.lotp.fr/wp-content/uploads/2013/04/lotp_check_ad_accounts.ps1_.txt">lotp_check_ad_accounts.ps1</a></p>
<p>Code source en direct si le téléchargement ne passe pas:</p>
<pre><span style="color: #008000;">#</span><span style="color: #008000;"> ====================================================================</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Search in AD for lockedout account. To be used through NRPE / nsclient++</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Author: Mathieu Chateau - LOTP</span><span style="color: #008000;">
#</span><span style="color: #008000;"> mail: mathieu.chateau@lotp.fr</span><span style="color: #008000;">
#</span><span style="color: #008000;"> version 0.1</span><span style="color: #008000;">
#</span><span style="color: #008000;"> ====================================================================</span><span style="color: #008000;">#
#</span><span style="color: #008000;"> Require Set-ExecutionPolicy RemoteSigned.. or sign this script with your PKI </span><span style="color: #008000;">
#
</span><span style="color: #008000;">#</span><span style="color: #008000;"> ============================================================</span><span style="color: #008000;">
#
#</span><span style="color: #008000;">  Do not change anything behind that line!</span><span style="color: #008000;">
#
</span><span style="color: #0000ff;">param</span><span style="color: #000000;"> 
(
    [</span><span style="color: #008080;">string</span><span style="color: #000000;">]</span><span style="color: #800080;">$action</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">LockedOut</span><span style="color: #800000;">"</span><span style="color: #000000;">,
    [</span><span style="color: #008080;">string</span><span style="color: #000000;">]</span><span style="color: #800080;">$searchBase</span><span style="color: #ff0000;">=</span><span style="color: #800000;">""</span><span style="color: #000000;">,
    [</span><span style="color: #008080;">string</span><span style="color: #000000;">]</span><span style="color: #800080;">$searchScope</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Subtree</span><span style="color: #800000;">"</span><span style="color: #000000;">,
    [</span><span style="color: #008080;">int</span><span style="color: #000000;">]</span><span style="color: #800080;">$maxWarn</span><span style="color: #ff0000;">=</span><span style="color: #000000;">5</span><span style="color: #000000;">,
    [</span><span style="color: #008080;">int</span><span style="color: #000000;">]</span><span style="color: #800080;">$maxCrit</span><span style="color: #ff0000;">=</span><span style="color: #000000;">10</span><span style="color: #000000;">
)

</span><span style="color: #008000;">#</span><span style="color: #008000;"> check that powershell ActiveDirectory module is present

</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #5f9ea0; font-weight: bold;">Get-Module</span><span style="color: #5f9ea0; font-style: italic;">-Name </span><span style="color: #800000;">"</span><span style="color: #800000;">ActiveDirectory</span><span style="color: #800000;">" </span><span style="color: #5f9ea0; font-style: italic;">-ListAvailable</span><span style="color: #000000;">)
{
    </span><span style="color: #0000ff;">try</span><span style="color: #000000;">
    {
        </span><span style="color: #5f9ea0; font-weight: bold;">Import-Module</span><span style="color: #5f9ea0; font-style: italic;">-Name </span><span style="color: #800000;">ActiveDirectory</span><span style="color: #000000;">
    }
    </span><span style="color: #0000ff;">catch</span><span style="color: #000000;">
    {
        </span><span style="color: #5f9ea0; font-weight: bold;">Write-Host </span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL: Missing PowerShell ActiveDirectory module</span><span style="color: #800000;">"</span><span style="color: #000000;">
        exit </span><span style="color: #000000;">2</span><span style="color: #000000;">
    }
}
</span><span style="color: #0000ff;">else</span><span style="color: #000000;">
{
    </span><span style="color: #5f9ea0; font-weight: bold;">Write-Host </span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL: Missing PowerShell ActiveDirectory module</span><span style="color: #800000;">"</span><span style="color: #000000;">
    exit </span><span style="color: #000000;">2</span><span style="color: #000000;">
}

</span><span style="color: #008000;">#</span><span style="color: #008000;"> check params if provided

</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$action </span><span style="color: #ff0000;">-notmatch </span><span style="color: #800000;">"</span><span style="color: #800000;">^(AccountDisabled|AccountExpired|AccountExpiring|AccountInactive|LockedOut|PasswordExpired|PasswordNeverExpires)$</span><span style="color: #800000;">"</span><span style="color: #000000;">)
{
    </span><span style="color: #5f9ea0; font-weight: bold;">Write-Hos t</span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL: action parameter can only be AccountDisabled,AccountExpired,AccountExpiring,AccountInactive,LockedOut,PasswordExpired,PasswordNeverExpires. Provided $action</span><span style="color: #800000;">"</span><span style="color: #000000;">
    exit </span><span style="color: #000000;">2</span><span style="color: #000000;">
}
</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$searchScope </span><span style="color: #ff0000;">-notmatch </span><span style="color: #800000;">"</span><span style="color: #800000;">^(Base|OneLevel|Subtree)$</span><span style="color: #800000;">"</span><span style="color: #000000;">)
{
    </span><span style="color: #5f9ea0; font-weight: bold;">Write-Host </span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL: searchScope parameter can only be Base,OneLevel,Subtree. Provided $searchScope</span><span style="color: #800000;">"</span><span style="color: #000000;">
    exit </span><span style="color: #000000;">2</span><span style="color: #000000;">
}
</span><span style="color: #0000ff;">if</span><span style="color: #000000;">((</span><span style="color: #800080;">$searchBase </span><span style="color: #ff0000;">-ne </span><span style="color: #800000;">""</span><span style="color: #000000;">) </span><span style="color: #ff0000;">-and </span><span style="color: #800080;">$searchBase </span><span style="color: #ff0000;">-ne</span><span style="color: #000000;"> ((Get-ADDomain).DistinguishedName))
{
    </span><span style="color: #800080;">$search</span><span style="color: #000000;">=Get-ADObject -Filter </span><span style="color: #800000;">'</span><span style="color: #800000;">ObjectClass -eq "OrganizationalUnit" -and DistinguishedName -eq $searchBase</span><span style="color: #800000;">'

</span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #800080;">$search</span><span style="color: #000000;">.Count </span><span style="color: #ff0000;">-ne </span><span style="color: #000000;">1</span><span style="color: #000000;">)
    {
        </span><span style="color: #5f9ea0; font-weight: bold;">Write-Host</span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL: SearchBase not found or duplicate. Provided $searchBase</span><span style="color: #800000;">"</span><span style="color: #000000;">
        exit </span><span style="color: #000000;">2</span><span style="color: #000000;">
    }
}
</span><span style="color: #0000ff;">else</span><span style="color: #000000;">
{
    </span><span style="color: #800080;">$searchBase</span><span style="color: #ff0000;">=</span><span style="color: #000000;">(Get-ADDomain).DistinguishedName
}

</span><span style="color: #800080;">$command</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Search-ADAccount -</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$action</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;"> -SearchBase '</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$searchBase</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">' -SearchScope </span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$searchScope

</span><span style="color: #800080;">$result</span><span style="color: #000000;">=</span><span style="color: #5f9ea0; font-weight: bold;">invoke-expression </span><span style="color: #800080;">$command

</span><span style="color: #0000ff;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$result</span><span style="color: #000000;">.Count </span><span style="color: #ff0000;">-gt </span><span style="color: #800080;">$maxCrit</span><span style="color: #000000;">)
{
    </span><span style="color: #800080;">$state</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">CRITICAL</span><span style="color: #800000;">"
    </span><span style="color: #800080;">$exitcode</span><span style="color: #ff0000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">
}
</span><span style="color: #0000ff;">elseif</span><span style="color: #000000;">(</span><span style="color: #800080;">$result</span><span style="color: #000000;">.Count </span><span style="color: #ff0000;">-gt </span><span style="color: #800080;">$maxWarn</span><span style="color: #000000;">)
{
    </span><span style="color: #800080;">$state</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">WARNING</span><span><span style="color: #800000;">"
</span><span style="color: #800080;">$exitcode</span><span style="color: #ff0000;">=</span><span style="color: #000000;">1</span><span style="color: #800000;">
</span></span><span style="color: #000000;">}
</span><span style="color: #0000ff;">else</span><span style="color: #000000;">
{
    </span><span style="color: #800080;">$state</span><span style="color: #ff0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">OK</span><span><span style="color: #800000;">"
</span><span style="color: #800080;">$exitcode</span><span style="color: #ff0000;">=</span><span style="color: #000000;">0</span><span style="color: #800000;">
</span></span><span style="color: #000000;">}

</span><span style="color: #800080;">$output</span><span style="color: #ff0000;">=</span><span style="color: #800080;">$state</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">: </span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$result</span><span style="color: #000000;">.Count</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$action</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">|</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$action</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">=</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$result</span><span style="color: #000000;">.Count</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">;</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$maxWarn</span><span style="color: #ff0000;">+</span><span style="color: #800000;">"</span><span style="color: #800000;">;</span><span style="color: #800000;">"</span><span style="color: #ff0000;">+</span><span style="color: #800080;">$maxCrit

</span><span style="color: #5f9ea0; font-weight: bold;">Write-Host </span><span style="color: #800080;">$output</span><span style="color: #000000;">
exit </span><span style="color: #800080;">$exitcode</span></pre>
<img src="http://feeds.feedburner.com/~r/lotp/~4/t1XL70Hl0eM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/04/nagios-superviser-les-comptes-active-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/04/nagios-superviser-les-comptes-active-directory/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=nagios-superviser-les-comptes-active-directory</feedburner:origLink></item>
		<item>
		<title>DSI++ : Mieux gérer l’existant ou acheter plus puissant ?</title>
		<link>http://feedproxy.google.com/~r/lotp/~3/5c0h7epCSo8/</link>
		<comments>http://www.lotp.fr/2013/04/dsi-mieux-gerer-lexistant-ou-acheter-plus-puissant/#comments</comments>
		<pubDate>Sat, 13 Apr 2013 21:43:59 +0000</pubDate>
		<dc:creator>Mathieu CHATEAU</dc:creator>
				<category><![CDATA[DSI++]]></category>

		<guid isPermaLink="false">http://www.lotp.fr/?p=1428</guid>
		<description><![CDATA[La demande en ressource informatique croit inexorablement dans les entreprises. Les projets les plus stratégiques font normalement l'objet d'un "capacity planning" permettant de s'assurer que la solution tiendra les fameux 3 ou 4 ans de son amortissement. Il y a cependant quelques parents pauvres qui bénéficient rarement de ce traitement:]]></description>
				<content:encoded><![CDATA[<p>En informatique, comme pour beaucoup de choses, on finit par être à l&rsquo;étroit dans l&rsquo;existant. Peut-être un peu plus vite en informatique que dans les autres domaines. Se pose alors toujours le choix entre mieux gérer l&rsquo;existant versus investir dans une nouvelle solution / faire une upgrade.</p>
<h3><strong>Mieux gérer l&rsquo;existant</strong></h3>
<p>Ce choix est plus courageux que le deuxième, mais aussi plus risqué. Il revient à dire que pensez pouvoir faire mieux que ce qui a été fait depuis le début. Cela se caractérise en général par du temps à passer, avec un gain difficile à estimer à l&rsquo;avance. Je pense qu&rsquo;il faut l&rsquo;essayer en premier car:</p>
<ul>
<li><span style="line-height: 12.796875px;">Il va potentiellement générer des économies, même s&rsquo;il est insuffisant et qu&rsquo;il faille quand même investir.</span></li>
<li>Il permettra de mieux comprendre le besoin en passant en revue les usages, et donc de justifier l&rsquo;investissement éventuel.</li>
<li>Il montre qu&rsquo;on ne se contente pas &laquo;&nbsp;d&rsquo;investir&nbsp;&raquo;.</li>
</ul>
<p>Le principal est de se fixer un objectif en termes de délai et de charge pour produire un résultat. Il ne devrait cependant jamais dépasser un certains % que coûterait la deuxième solution.</p>
<p>La demande en ressource informatique croit inexorablement dans les entreprises. Les projets les plus stratégiques font normalement l&rsquo;objet d&rsquo;un &laquo;&nbsp;capacity planning&nbsp;&raquo; permettant de s&rsquo;assurer que la solution tiendra les fameux 3 ou 4 ans de son amortissement. Il y a cependant quelques parents pauvres qui bénéficient rarement de ce traitement:</p>
<ul>
<li><span style="line-height: 12.796875px;">Le stockage de fichiers bureautiques,</span></li>
<li>Le stockage des mails,</li>
<li>La consommation réseau (inter sites, et Internet).<img class="aligncenter size-full wp-image-1429" alt="ramer-desert" src="http://www.lotp.fr/wp-content/uploads/2013/04/ramer-desert.jpg" width="679" height="309" /></li>
</ul>
<p style="text-align: center;"><a href="http://photo.net/photodb/photo?photo_id=6900152" target="_blank"><span style="line-height: 19px;">Crédit</span></a></p>
<p>Demander le ménage dans les fichiers bureautiques revient à ramer dans le désert. Tout le monde estime avoir mieux à faire, mais personne n&rsquo;a envie de payer le prix que cela coûte (stockage central €MC / N€tApp, sauvegarde&#8230;). Face à l&rsquo;hémorragie, des solutions soit disant &laquo;&nbsp;miracle&nbsp;&raquo; ont vu le jour (archivage 3 tiers, déduplication, SharePoint&#8230;). Ce dernier permet l&rsquo;indexation, ce qui est presque le pire. Où comment s&rsquo;y retrouver dans un capharnaüm sans ranger sa chambre. Non seulement les utilisateurs ne veulent plus supprimer les vieux fichiers, mais ils ne veulent plus classer non plus&#8230;</p>
<p>Heureusement, on peut transformer le virus en vaccin : chercher les mots salaires et primes. Résultats garantis!</p>
<p>Le réseau fait partie des investissements &laquo;&nbsp;lourds&nbsp;&raquo; qui fonctionnent par palier. Le stockage et la sauvegarde en font également partis. Des solutions existent depuis pas mal de temps, vu que c&rsquo;était le premier point de contention dans les entreprises en général:</p>
<ul>
<li><span style="line-height: 12.796875px;">QOS : permet de gérer l&rsquo;intérieur du tuyau : garantir des flux, en restreindre d&rsquo;autres,</span></li>
<li>Compression : Riverbed &amp; co. Espérer que les données sont redondantes et faire l&rsquo;équivalent d&rsquo;un &laquo;&nbsp;zip&nbsp;&raquo; des flux réseaux.</li>
</ul>
<p>En réponse à tout cela, je propose deux approches en parallèle:</p>
<ul>
<li><span style="line-height: 12.796875px;">Vérifier que les bonnes pratiques &laquo;&nbsp;minimum&nbsp;&raquo; sont appliquées</span></li>
<li>Outiller la DSI pour pouvoir faire de la refacturation interne.</li>
</ul>
<p>Quelques bonnes pratiques ayant fait leurs preuves:</p>
<ul>
<li><span style="line-height: 12.796875px;">Les flux http/https sont compressés par les serveurs Web et proxy,</span></li>
<li>Les réplications (DFS, SQL&#8230;) inter sites sont faites pendant les heures creuses ou avec la gestion de bande passante intégrée,</li>
<li>Privilégier l&rsquo;envoi de Delta plutôt que complète,</li>
<li>Chercher les fichiers les plus volumineux,</li>
<li>Bloquer dès le départ plutôt qu’a posteriori (fichiers multimédias&#8230;),</li>
<li>Mettre des quotas pour gérer des croissances non prévues. Même si le blocage ne sera pas maintenable.</li>
<li>Noter toute solution  &laquo;&nbsp;temporaire&nbsp;&raquo;, en identifiant le demandeur, la raison, et la date de suppression,</li>
<li>Mettre des sécurités (alerte/blocage) en dessous des valeurs réellement bloquantes.</li>
<li>Après une mise en production, revalider le capacity planning initial.</li>
</ul>
<p>Lors de besoins pour un projet spécifique, il est souvent facile d&rsquo;identifier le motif des coûts. Cela est plus difficile quand il s&rsquo;agit de la connexion Internet ou du stockage. Les outils de refacturation permettent d&rsquo;objectiver la consommation. Même si la refacturation interne ne sera pas faite, elle permet d&rsquo;identifier clairement les consommateurs, et de ventiler le coût de la prochaine upgrade.</p>
<h3><strong>Investir</strong></h3>
<p>Cette solution permet d&rsquo;avoir, de manière presque certaine, une réponse immédiate à un problème ou à un besoin. Sur certains sujets, comme les fichiers bureautiques, il permet de ne pas s&rsquo;attirer les foudres des utilisateurs, surtout quand ces derniers n&rsquo;hésitent pas à comparer avec le prix d&rsquo;un disque de 1To chez le marchand du coin. Cependant il y a des cas où ce choix n&rsquo;apporte pas les gains escomptés. C&rsquo;est notamment le cas avec les problèmes de performances, où acheter un deuxième serveur ne veut pas forcément dire deux fois plus vite.</p>
<p>L&rsquo;investissement est souvent favorisé car il permet également d&rsquo;avoir des ressources pour mener les actions. Si vous souhaitez optimiser votre infrastructure virtuelle, vous aurez peut-être du mal à obtenir un budget, tout au plus pour un audit. Alors que si vous faites un projet avec de nouveaux serveurs et une montée de version, on vous donnera le budget pour cela, avec les jours hommes qui vont avec. Cela est dû à la difficulté d&rsquo;afficher des gains avant de faire l&rsquo;optimisation.</p>
<h2>Conclusion</h2>
<p>Je recommande les actions suivantes pour le &laquo;&nbsp;label&nbsp;&raquo; DSI++:</p>
<ul>
<li><span style="line-height: 12.796875px;">Avoir les indicateurs clés de saturation. Ceux-ci doivent être suffisants pour avoir le temps de mener une phase d&rsquo;optimisation. Sinon on se retrouve dos au mur et l&rsquo;investissement sera systématiquement retenu.</span></li>
<li>Demander l&rsquo;exercice de chiffrer la consommation de ressources dans les projets. Profiter des montées de version pour inclure cet exercice sur l&rsquo;existant. Vérifier à posteriori la différence entre le prévu et le réel. Les chiffres sont tout aussi intéressants que la prise de conscience des personnes sur l&rsquo;impact de leur projet.</li>
<li>Quand une solution à un problème de consommation est identifiée dans un projet (activer la compression http), l&rsquo;inclure dans des normes et standard, afin qu&rsquo;elle soit généraliser &laquo;&nbsp;par défaut&nbsp;&raquo;.</li>
<li>Implémenter des outils de refacturation sur les éléments partagés et ceux où le consommateur n&rsquo;est pas clairement identifiable.</li>
<li>Vérifier que des graphiques de consommation sont bien disponibles sur les éléments clés de l&rsquo;architecture : stockage, réseau, processeur, mémoire. Ce n&rsquo;est pas quand il y aura une saturation que ces graphes doivent être mise en place.</li>
<li>Ramener le prix du stockage central au Go. Cela permet facilement une prise de conscience lors des demandes. Idem pour le réseau.</li>
<li>Remettre en cause les choix du passé lors des renouvellements d&rsquo;architecture. On fait certains choix en fonction:
<ul>
<li>D&rsquo;un contexte,</li>
<li>De l&rsquo;état des technologies (maturité, coût, connaissance),</li>
<li>De choix du groupe,</li>
<li>du budget.</li>
</ul>
</li>
</ul>
<p>Parfois c&rsquo;est même d&rsquo;autres personnes qui ont fait ces choix sur l&rsquo;architecture actuelle. Il moins engageant de &laquo;&nbsp;juste renouveler&nbsp;&raquo;, mais cela vous enferme indirectement dans des choix limités pour la suite.</p>
<img src="http://feeds.feedburner.com/~r/lotp/~4/5c0h7epCSo8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lotp.fr/2013/04/dsi-mieux-gerer-lexistant-ou-acheter-plus-puissant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lotp.fr/2013/04/dsi-mieux-gerer-lexistant-ou-acheter-plus-puissant/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dsi-mieux-gerer-lexistant-ou-acheter-plus-puissant</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: www.lotp.fr @ 2013-05-20 21:57:25 by W3 Total Cache -->
