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

<channel>
	<title>Blog Modulaweb &#187; awk</title>
	<atom:link href="http://www.modulaweb.fr/blog/tags/awk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.modulaweb.fr/blog</link>
	<description>Le blog des technologies modulables orientées web</description>
	<lastBuildDate>Thu, 16 Dec 2010 03:02:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Créer un fichier PID pour Funambol sous GNU/Linux</title>
		<link>http://www.modulaweb.fr/blog/2009/08/creer-un-fichier-pid-pour-funambol-sous-gnu-linux/</link>
		<comments>http://www.modulaweb.fr/blog/2009/08/creer-un-fichier-pid-pour-funambol-sous-gnu-linux/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 05:47:19 +0000</pubDate>
		<dc:creator>Jean-François VIAL</dc:creator>
				<category><![CDATA[Choses utiles]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[funambol]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[Monit]]></category>
		<category><![CDATA[PID]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://www.modulaweb.fr/blog/?p=397</guid>
		<description><![CDATA[Lorsqu'il est lancé, le serveur Funambol ne crée pas de fichier PID rendant difficile son monitoring à l'aide d'outils comme Monit qui, à l'aide d'un PID, monitorent les ressources consommées par un process donné. À l'aide d'un script bash, nous allons permettre cette création de fichier PID. Fonctionnement du script Rien de bien sorcier, juste [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-340" src="http://www.modulaweb.fr/blog/wp-content/uploads/2009/02/funambol1.png" alt="" width="128" height="128" />Lorsqu'il est lancé, le serveur Funambol ne crée pas de fichier PID rendant difficile son monitoring à l'aide d'outils comme <a href="http://fr.wikipedia.org/wiki/Monit">Monit</a> qui, à l'aide d'un PID, monitorent les ressources consommées par un process donné.</p>
<p>À l'aide d'un script bash, nous allons permettre cette création de fichier PID.<br />
<span id="more-397"></span></p>
<h2>Fonctionnement du script</h2>
<p>Rien de bien sorcier, juste une recherche des PID des différents composants du serveur Funambol à l'aide d'un bon vieux <a href="http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man1/ps.1.html">ps</a> couplé à une paire de <a href="http://www.linux-kheops.com/doc/man/manfr/man-html-0.9/man1/grep.1.html">grep</a> associés à un petit <a href="http://fr.wikipedia.org/wiki/Awk">awk</a> suivi d'un <a href="http://pwet.fr/man/linux/commandes/head">head</a>... autrement dit "on recherche les processus des composants de funambol dans la liste des processus, et on récupère leurs PID".</p>
<h2>Le script</h2>
<p>Il y a certainement plus élégant mais l'essentiel c'est qu'il fasse ce qu'on lui demande et qu'il remplisse sa fonction didactique.</p>
<pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Check the script is being run by root, or die.</span>
<span style="color: #007800;">ROOT_UID=</span><span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$UID&quot;</span> -ne <span style="color: #ff0000;">&quot;$ROOT_UID&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Run script as &quot;</span>root<span style="color: #ff0000;">&quot;.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">DS_SERVER=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> ds-server | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #007800;">HYPERSONIC=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> hypersonic | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #007800;">CTP_SERVER=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> com.funambol.ctp.server.CTPServer | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #007800;">INBOX_LISTENER=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> inbox-listener | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #007800;">PIM_LISTENER=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> pimlistener | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$DS_SERVER&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -e /opt/funambol/ds-server.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #c20cb9; font-weight: bold;">rm</span> /opt/Funambol/ds-server.pid
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> ds-server | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span> | <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> | <span style="color: #c20cb9; font-weight: bold;">head</span> -n <span style="color: #000000;">1</span> &gt; /opt/Funambol/ds-server.pid
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$HYPERSONIC&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -e /opt/funambol/hypersonic.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> /opt/Funambol/hypersonic.pid
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> hypersonic | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span> | <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> | <span style="color: #c20cb9; font-weight: bold;">head</span> -n <span style="color: #000000;">1</span> &gt; /opt/Funambol/hypersonic.pid
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$CTP_SERVER&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -e /opt/funambol/ctp-server.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> /opt/Funambol/ctp-server.pid
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> com.funambol.ctp.server.CTPServer | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span> | <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> | <span style="color: #c20cb9; font-weight: bold;">head</span> -n <span style="color: #000000;">1</span> &gt; /opt/Funambol/ctp-server.pid
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$INBOX_LISTENER&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -e /opt/funambol/inbox-listener.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> /opt/Funambol/inbox-listener.pid
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> inbox-listener | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span> | <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> | <span style="color: #c20cb9; font-weight: bold;">head</span> -n <span style="color: #000000;">1</span> &gt; /opt/Funambol/inbox-listener.pid
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$PIM_LISTENER&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -e /opt/funambol/pim-listener.pid <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> /opt/Funambol/pim-listener.pid
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> pimlistener | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span> | <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span> | <span style="color: #c20cb9; font-weight: bold;">head</span> -n <span style="color: #000000;">1</span> &gt; /opt/Funambol/pim-listener.pid
<span style="color: #000000; font-weight: bold;">fi</span></pre>
<h2>Utilisation</h2>
<p>En appelant ce script via une tache cron, par exemple, vous permettrez aux système de monitoring d'avoir un pid à jour en cas de redémarrage.</p>
<p>Il est aussi possible de créer un script de commande pour (re)lancer/arrêter Funambol afin de créer/détruire ces fichiers PID au démarrage/arrêt de Funambol. Voici un exemple d'un tel script, où le script précédent (celui qui crée les PID) est dans /opt/controls/mk-funambol-pid-file :</p>
<pre class="bash"><span style="color: #808080; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Check the script is being run by root, or die.</span>
<span style="color: #007800;">ROOT_UID=</span><span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$UID&quot;</span> -ne <span style="color: #ff0000;">&quot;$ROOT_UID&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Run script as &quot;</span>root<span style="color: #ff0000;">&quot;.&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">FUNAMBOL=</span>`<span style="color: #c20cb9; font-weight: bold;">ps</span> -ef | <span style="color: #c20cb9; font-weight: bold;">grep</span> /opt/Funambol | <span style="color: #c20cb9; font-weight: bold;">grep</span> -v <span style="color: #c20cb9; font-weight: bold;">grep</span>`
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> -z <span style="color: #ff0000;">&quot;$FUNAMBOL&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">FUNAMBOL_ON=</span><span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #007800;">FUNAMBOL_ON=</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FUNAMBOL_ON</span> -eq <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Funambol is already started : use $0 restart option to restart.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting Funambol...&quot;</span>
		/opt/Funambol/bin/funambol start
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating PID files...&quot;</span>
		/opt/controls/mk-funambol-pid-<span style="color: #c20cb9; font-weight: bold;">file</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
	;;
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FUNAMBOL_ON</span> -eq <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Funambol is already stopped.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping Funambol...&quot;</span>
                /opt/Funambol/bin/funambol stop
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Deleting PID files...&quot;</span>
                /opt/controls/mk-funambol-pid-<span style="color: #c20cb9; font-weight: bold;">file</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
	;;
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FUNAMBOL_ON</span> -eq <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Funambol was already stopped !&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting Funambol...&quot;</span>
                /opt/Funambol/bin/funambol start
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating PID files...&quot;</span>
                /opt/controls/mk-funambol-pid-<span style="color: #c20cb9; font-weight: bold;">file</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
	<span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stopping Funambol...&quot;</span>
                /opt/Funambol/bin/funambol stop
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Deleting PID files...&quot;</span>
                /opt/controls/mk-funambol-pid-<span style="color: #c20cb9; font-weight: bold;">file</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting Funambol...&quot;</span>
                /opt/Funambol/bin/funambol start
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Creating PID files...&quot;</span>
                /opt/controls/mk-funambol-pid-<span style="color: #c20cb9; font-weight: bold;">file</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
	;;
status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FUNAMBOL_ON</span> -eq <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Funambol is curently stopped.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Funambol is curently started.&quot;</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        ;;
*<span style="color: #7a0874; font-weight: bold;">&#41;</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage $0 [start|stop|restart|status]&quot;</span>
	;;
<span style="color: #000000; font-weight: bold;">esac</span></pre>
<p>Ce script permet, en outre, de permettre un redémarrage direct de Funambol.</p>
<h2>Exemple d'application : configuration de Monit pour Funambol</h2>
<p>Considérant que nous avons les 2 scripts précédent, l'un dans /opt/controls/mk-funambol-pid-file et l'autre dans /opt/controls/funambol, on pourra utiliser, par exemple, la configuration suivante pour Monit :</p>
<pre># Funambol
check process ds-server with pidfile /opt/Funambol/ds-server.pid
        group funambol
        start program "/opt/controls/funambol start"
        stop program "/opt/controls/funambol stop"
        if failed port 8443 for 3 times within 3 cycles then restart
        if 2 restart within 10 cycles then timeout
check process hypersonic with pidfile /opt/Funambol/hypersonic.pid
        group funambol
check process ctp-server with pidfile /opt/Funambol/ctp-server.pid
        group funambol
check process inbox-listener with pidfile /opt/Funambol/inbox-listener.pid
        group funambol
check process pim-listener with pidfile /opt/Funambol/pim-listener.pid
        group funambol</pre>
<p>Ici funambol utilise une connexion sécurisée sur le port 8443 comme indiqué dans le <a href="http://www.modulaweb.fr/blog/2009/02/installation-de-funambol-couple-a-zimbra-sur-un-serveur-gnu-linux/">tutoriel d'installation de Funambol</a>, nous monitorons donc ce port.</p>
<p>Grâce aux pid, nous pourrons voir sur l'interface web de Monit les ressources consommées par les composants de Funambol, et éventuellement créer des règles dans le cas où cette consommation deviendrait excessive.</p>
<h4 class='related-posts-header'>Articles apparentés</h4><ul class="related-posts-list"><li class="related-post"><a href="http://www.modulaweb.fr/blog/2009/05/quelques-scripts-pour-profiter-de-son-scanner-sous-gnulinux/">Quelques scripts pour profiter de son scanner sous GNU/Linux</a> </li><li class="related-post"><a href="http://www.modulaweb.fr/blog/2009/02/installation-de-funambol-couple-a-zimbra-sur-un-serveur-gnu-linux/">Installation de Funambol couplé à Zimbra sur un serveur GNU/Linux</a> </li><li class="related-post"><a href="http://www.modulaweb.fr/blog/2010/11/optimiser-apache/">Optimiser Apache – Partie 1</a> </li><li class="related-post"><a href="http://www.modulaweb.fr/blog/2009/05/configurer-vsftpd-pour-mettre-a-jour-automatiquement-wordpress/">Configurer vsftpd pour mettre à jour automatiquement Wordpress</a> </li><li class="related-post"><a href="http://www.modulaweb.fr/blog/2009/02/inclure-ses-machines-virtuelles-a-son-reseau-avec-virtualbox/">Inclure ses machines virtuelles à son réseau avec VirtualBox</a> </li><li class="related-post"><a href="http://www.modulaweb.fr/blog/2009/02/pour-des-sessions-ssh-qui-durent/">Pour des sessions SSH qui durent</a> </li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.modulaweb.fr/blog/2009/08/creer-un-fichier-pid-pour-funambol-sous-gnu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

