| 8 | | <title>Monitoring</title> |
|---|
| 9 | | |
|---|
| 10 | | <indexterm><primary>monitoring &slony1;</primary></indexterm> |
|---|
| 11 | | |
|---|
| 12 | | <sect2> <title> &nagios; Replication Checks </title> |
|---|
| 13 | | |
|---|
| 14 | | <indexterm><primary>&nagios; for monitoring replication</primary></indexterm> |
|---|
| 15 | | |
|---|
| 16 | | <para> The script in the <filename>tools</filename> directory called |
|---|
| 17 | | <command> psql_replication_check.pl </command> represents some of the |
|---|
| 18 | | best answers arrived at in attempts to build replication tests to plug |
|---|
| 19 | | into the <ulink url="http://www.nagios.org/"> &nagios; </ulink> system |
|---|
| 20 | | monitoring tool.</para> |
|---|
| 21 | | |
|---|
| 22 | | <para> A former script, <filename> |
|---|
| 23 | | test_slony_replication.pl</filename>, took a <quote>clever</quote> |
|---|
| 24 | | approach where a <quote>test script</quote> is periodically run, which |
|---|
| 25 | | rummages through the &slony1; configuration to find origin and |
|---|
| 26 | | subscribers, injects a change, and watches for its propagation through |
|---|
| 27 | | the system. It had two problems:</para> |
|---|
| | 8 | <title>Surveillance</title> |
|---|
| | 9 | |
|---|
| | 10 | <indexterm><primary>Surveiller &slony1;</primary></indexterm> |
|---|
| | 11 | |
|---|
| | 12 | <sect2> <title> Tester la replication avec &nagios; </title> |
|---|
| | 13 | |
|---|
| | 14 | <indexterm><primary>&nagios; pour surveiller la réplication</primary></indexterm> |
|---|
| | 15 | |
|---|
| | 16 | <para> Le script <command> psql_replication_check.pl </command> qui se trouve |
|---|
| | 17 | dans le répertoire <filename>tools</filename> regroupe les meilleures |
|---|
| | 18 | tentatives de construire de création de tests utilisables par le systÚme |
|---|
| | 19 | de surveillance <ulink url="http://www.nagios.org/"> &nagios;</ulink>.</para> |
|---|
| | 20 | |
|---|
| | 21 | <para> Un script antérieur, nommé <filename> |
|---|
| | 22 | test_slony_replication.pl</filename>, utilisait une approche <quote>intelligente</quote> |
|---|
| | 23 | : un <quote>script de test</quote> est exécuté périodiquement et se déploie à travers les configurations |
|---|
| | 24 | &slony1; pour trouver l'origine et les abonnés, injecte un changement et observe sa propagation |
|---|
| | 25 | à travers le systÚme. Il présentait deux problÚmes :</para> |
|---|
| 42 | | <para> The new script, <command>psql_replication_check.pl</command>, |
|---|
| 43 | | takes the minimalist approach of assuming that the system is an online |
|---|
| 44 | | system that sees regular <quote>traffic,</quote> so that you can |
|---|
| 45 | | define a view specifically for the replication test called |
|---|
| 46 | | <envar>replication_status</envar> which is expected to see regular |
|---|
| 47 | | updates. The view simply looks for the youngest |
|---|
| 48 | | <quote>transaction</quote> on the node, and lists its timestamp, age, |
|---|
| 49 | | and some bit of application information that might seem useful to see. |
|---|
| | 39 | <para> Le nouveau script, <command>psql_replication_check.pl</command>, |
|---|
| | 40 | utilise une approche minimaliste qui suppose que le systÚme est une |
|---|
| | 41 | systÚme en ligne recevant un <quote>trafic</quote> régulier, et vous |
|---|
| | 42 | permet de définir une vue spécifique pour le test de replication appelée |
|---|
| | 43 | <envar>replication_status</envar> qui doit contenir des mises à jour |
|---|
| | 44 | réguliÚres. Cette vue regarde simplement la derniÚre |
|---|
| | 45 | <quote>transaction</quote> sur le noeud, et liste son timestamp, son âge, |
|---|
| | 46 | ainsi que quelques informations sur l'application qui peuvent être utiles. |
|---|
| 62 | | <para> An instance of the script will need to be run for each node |
|---|
| 63 | | that is to be monitored; that is the way &nagios; works. </para> |
|---|
| 64 | | |
|---|
| 65 | | </sect2> |
|---|
| 66 | | |
|---|
| 67 | | <sect2 id="slonymrtg"> <title> Monitoring &slony1; using MRTG </title> |
|---|
| 68 | | |
|---|
| 69 | | <indexterm><primary>MRTG for monitoring replication</primary></indexterm> |
|---|
| 70 | | |
|---|
| 71 | | <para> One user reported on the &slony1; mailing list how to configure |
|---|
| 72 | | <ulink url="http://people.ee.ethz.ch/~oetiker/webtools/mrtg/"> |
|---|
| 73 | | <application> mrtg - Multi Router Traffic Grapher </application> |
|---|
| 74 | | </ulink> to monitor &slony1; replication.</para> |
|---|
| 75 | | |
|---|
| 76 | | <para> ... Since I use <application>mrtg</application> to graph data |
|---|
| 77 | | from multiple servers I use snmp (<application>net-snmp</application> |
|---|
| 78 | | to be exact). On database server, I added the following line to |
|---|
| 79 | | <application>snmpd</application> configuration:</para> |
|---|
| | 59 | <para> Une instance du script doit être lancée sur chaque noeud surveillé; |
|---|
| | 60 | c'est ainsi que &nagios; fonctionne.</para> |
|---|
| | 61 | |
|---|
| | 62 | </sect2> |
|---|
| | 63 | |
|---|
| | 64 | <sect2 id="slonymrtg"> <title> Surveiller &slony1; avec MRTG </title> |
|---|
| | 65 | |
|---|
| | 66 | <indexterm><primary>Utiliser MRTG pour surveiller la réplication</primary></indexterm> |
|---|
| | 67 | |
|---|
| | 68 | <para> Un utilisateur a expliqué sur la liste de discussion de &slony1; comment |
|---|
| | 69 | configurer <ulink url="http://people.ee.ethz.ch/~oetiker/webtools/mrtg/"> |
|---|
| | 70 | <application> mrtg ( Multi Router Traffic Grapher )</application> |
|---|
| | 71 | </ulink> pour surveiller une réplication &slony1;.</para> |
|---|
| | 72 | |
|---|
| | 73 | <para> ... Puisque j'utilise <application>mrtg</application> pour visualiser |
|---|
| | 74 | les données depuis plusieurs serveurs, j'utilise SNMP |
|---|
| | 75 | (<application>net-snmp</application> pour être exact).* |
|---|
| | 76 | Pour un serveur de base de données, j'ai ajouté la ligne suivante à la configuration |
|---|
| | 77 | <application>snmpd</application> :</para> |
|---|
| 142 | | <indexterm><primary>script test_slony_state to test replication state</primary></indexterm> |
|---|
| 143 | | |
|---|
| 144 | | <para> This script does various sorts of analysis of the state of a |
|---|
| 145 | | &slony1; cluster.</para> |
|---|
| 146 | | |
|---|
| 147 | | <para> You specify arguments including <option>database</option>, |
|---|
| 148 | | <option>host</option>, <option>user</option>, |
|---|
| 149 | | <option>cluster</option>, <option>password</option>, and |
|---|
| 150 | | <option>port</option> to connect to any of the nodes on a cluster. |
|---|
| 151 | | You also specify a <option>mailprog</option> command (which should be |
|---|
| 152 | | a program equivalent to <productname>Unix</productname> |
|---|
| 153 | | <application>mailx</application>) and a recipient of email. </para> |
|---|
| 154 | | |
|---|
| 155 | | <para> You may alternatively specify database connection parameters |
|---|
| 156 | | via the environment variables used by |
|---|
| 157 | | <application>libpq</application>, <emphasis>e.g.</emphasis> - using |
|---|
| | 140 | <indexterm><primary>script test_slony_state pour tester l'état de la réplication</primary></indexterm> |
|---|
| | 141 | |
|---|
| | 142 | <para> Ce script effectue différents analyses sur l'état d'un cluster |
|---|
| | 143 | &slony1;.</para> |
|---|
| | 144 | |
|---|
| | 145 | <para>Vous devez spécifier les arguments tels que <option>la base de données</option>, |
|---|
| | 146 | <option>l'hÃŽte</option>, <option>l'utilisateur</option>, |
|---|
| | 147 | <option>le cluster</option>, <option>le mot de passe</option>, et |
|---|
| | 148 | <option>le port</option> afin de se connecter à n'importe quel |
|---|
| | 149 | noeud du cluster. Vous devez également préciser une commande |
|---|
| | 150 | <option>mailprog</option> ( qui doit être un commande équivalente |
|---|
| | 151 | Ã la commande <productname>Unix</productname> |
|---|
| | 152 | <application>mailx</application>) et une destination pour le courrier. </para> |
|---|
| | 153 | |
|---|
| | 154 | <para> Par ailleurs vous spécifier les paramÚtres de connexion aux bases de données |
|---|
| | 155 | via les variables d'environnement utilisées par |
|---|
| | 156 | <application>libpq</application>, <emphasis>par exemple :</emphasis> - utiliser |
|---|
| 159 | | <envar>PGUSER</envar>, <envar>PGSERVICE</envar>, and such.</para> |
|---|
| 160 | | |
|---|
| 161 | | <para> The script then rummages through <xref linkend="table.sl-path"/> |
|---|
| 162 | | to find all of the nodes in the cluster, and the DSNs to allow it to, |
|---|
| 163 | | in turn, connect to each of them.</para> |
|---|
| 164 | | |
|---|
| 165 | | <para> For each node, the script examines the state of things, |
|---|
| 166 | | including such things as: |
|---|
| | 158 | <envar>PGUSER</envar>, <envar>PGSERVICE</envar>, et ainsi de suite.</para> |
|---|
| | 159 | |
|---|
| | 160 | <para>Le script se promÚne à travers <xref linkend="table.sl-path"/> |
|---|
| | 161 | pour trouver tous les noeuds du cluster, et dans les DSNs qui lui |
|---|
| | 162 | permettront de se connecter à chaque noeud.</para> |
|---|
| | 163 | |
|---|
| | 164 | <para> Pour chaque noeud, le script examine l'état des données suivantes : |
|---|
| 169 | | <listitem><para> Checking <xref linkend="table.sl-listen"/> for some |
|---|
| 170 | | <quote>analytically determinable</quote> problems. It lists paths |
|---|
| 171 | | that are not covered.</para></listitem> |
|---|
| 172 | | |
|---|
| 173 | | <listitem><para> Providing a summary of events by origin node</para> |
|---|
| 174 | | |
|---|
| 175 | | <para> If a node hasn't submitted any events in a while, that likely |
|---|
| 176 | | suggests a problem.</para></listitem> |
|---|
| 177 | | |
|---|
| 178 | | <listitem><para> Summarizes the <quote>aging</quote> of table <xref |
|---|
| | 167 | <listitem><para> Vérification de <xref linkend="table.sl-listen"/> |
|---|
| | 168 | à la recherche de problÚmes |
|---|
| | 169 | <quote>déterminés analytiquement</quote>. Cela liste les voies de communication |
|---|
| | 170 | qui ne sont pas couvertes.</para></listitem> |
|---|
| | 171 | |
|---|
| | 172 | <listitem><para> Effectuer un résumé des événements sur le noeud d'origine</para> |
|---|
| | 173 | |
|---|
| | 174 | <para> Si un noeud n'a pas soumis un événement depuis longtemps, il y a certainement |
|---|
| | 175 | un problÚme.</para></listitem> |
|---|
| | 176 | |
|---|
| | 177 | <listitem><para> Vérification de <quote>l'âge</quote> de la table <xref |
|---|
| 181 | | <para> If one or another of the nodes in the cluster hasn't reported |
|---|
| 182 | | back recently, that tends to lead to cleanups of tables like <xref |
|---|
| 183 | | linkend="table.sl-log-1"/> and <xref linkend="table.sl-seqlog"/> not |
|---|
| 184 | | taking place.</para></listitem> |
|---|
| 185 | | |
|---|
| 186 | | <listitem><para> Summarizes what transactions have been running for a |
|---|
| 187 | | long time</para> |
|---|
| 188 | | |
|---|
| 189 | | <para> This only works properly if the statistics collector is |
|---|
| 190 | | configured to collect command strings, as controlled by the option |
|---|
| 191 | | <option> stats_command_string = true </option> in <filename> |
|---|
| | 180 | <para> Si un ou plusieurs noeuds du cluster n'ont pas envoyé de rapport récemment |
|---|
| | 181 | alors cela peut conduire à l'absence de nettoyage dans certaines tables comme |
|---|
| | 182 | <xref linkend="table.sl-log-1"/> et <xref linkend="table.sl-seqlog"/></para></listitem> |
|---|
| | 183 | |
|---|
| | 184 | <listitem><para> Vérifications des transactions longues</para> |
|---|
| | 185 | |
|---|
| | 186 | <para> Ceci ne fonctionne correctement que si le collecteur de statistique |
|---|
| | 187 | est configuré pour collecter les requêtes, c'est à dire l'option |
|---|
| | 188 | <option> stats_command_string = true</option> est présente dans <filename> |
|---|
| 194 | | <para> If you have broken applications that hold connections open, |
|---|
| 195 | | this will find them.</para> |
|---|
| 196 | | |
|---|
| 197 | | <para> If you have broken applications that hold connections open, |
|---|
| 198 | | that has several unsalutory effects as <link |
|---|
| 199 | | linkend="longtxnsareevil"> described in the |
|---|
| 200 | | FAQ</link>.</para></listitem> |
|---|
| | 191 | <para> Si des bugs applicatifs conservent des connexions ouvertes, ce script devrait les trouver |
|---|
| | 192 | .</para> |
|---|
| | 193 | |
|---|
| | 194 | <para> Si des bugs applicatifs conservent des connexions ouvertes, |
|---|
| | 195 | plusieurs effets négatifs sont à prévoir |
|---|
| | 196 | tels que <link |
|---|
| | 197 | linkend="longtxnsareevil">ceux décrits dans la FAQ |
|---|
| | 198 | </link>.</para></listitem> |
|---|
| 211 | | <indexterm><primary> search &slony1; logs using search-logs.sh </primary></indexterm> |
|---|
| 212 | | |
|---|
| 213 | | <para> This script is constructed to search for &slony1; log files at |
|---|
| 214 | | a given path (<envar>LOGHOME</envar>), based both on the naming |
|---|
| 215 | | conventions used by the <xref linkend="launchclusters"/> and <xref |
|---|
| 216 | | linkend="slonwatchdog"/> systems used for launching &lslon; |
|---|
| 217 | | processes.</para> |
|---|
| 218 | | |
|---|
| 219 | | <para> Errors, if found, are listed, by log file, and emailed to the |
|---|
| 220 | | specified user (<envar>LOGRECIPIENT</envar>); if no email address is |
|---|
| 221 | | specified, output goes to standard output. </para> |
|---|
| 222 | | |
|---|
| 223 | | <para> <envar>LOGTIMESTAMP</envar> allows overriding what hour to |
|---|
| 224 | | evaluate (rather than the last hour). </para> |
|---|
| 225 | | |
|---|
| 226 | | <para> An administrator might run this script once an hour to monitor |
|---|
| 227 | | for replication problems. </para> |
|---|
| 228 | | </sect2> |
|---|
| 229 | | |
|---|
| 230 | | <sect2 id="wikigen"> <title> Building MediaWiki Cluster Summary </title> |
|---|
| 231 | | |
|---|
| 232 | | <indexterm><primary> generating Wiki documentation of a cluster </primary></indexterm> |
|---|
| 233 | | |
|---|
| 234 | | <para> The script <filename>mkmediawiki.pl </filename>, in |
|---|
| 235 | | <filename>tools</filename>, may be used to generate a cluster summary |
|---|
| 236 | | compatible with the popular <ulink url="http://www.mediawiki.org/"> |
|---|
| 237 | | MediaWiki </ulink> software. Note that the |
|---|
| 238 | | <option>--categories</option> permits the user to specify a set of |
|---|
| 239 | | (comma-delimited) categories with which to associate the output. If |
|---|
| 240 | | you have a series of &slony1; clusters, passing in the option |
|---|
| 241 | | <option>--categories=slony1</option> leads to the MediaWiki instance |
|---|
| 242 | | generating a category page listing all &slony1; clusters so |
|---|
| 243 | | categorized on the wiki. </para> |
|---|
| 244 | | |
|---|
| 245 | | <para> The gentle user might use the script as follows: </para> |
|---|
| | 209 | <indexterm><primary> Chercher les logs &slony1; avec search-logs.sh </primary></indexterm> |
|---|
| | 210 | |
|---|
| | 211 | <para> Ce script est construit pour chercher les fichiers de trace &slony1; |
|---|
| | 212 | dans un emplacement donné (<envar>LOGHOME</envar>), en se basant à la fois |
|---|
| | 213 | sur les conventions de nommage utilisées par les systÚmes |
|---|
| | 214 | <xref linkend="launchclusters"/> et <xref linkend="slonwatchdog"/> lors du démarrage |
|---|
| | 215 | des processus &lslon;.</para> |
|---|
| | 216 | |
|---|
| | 217 | <para> Si des erreurs sont trouvées, elles sont listées pour chaque fichiers |
|---|
| | 218 | et transmises par courriel à un utilisateur spécifié (<envar>LOGRECIPIENT</envar>); |
|---|
| | 219 | si aucune adresse courriel n'est spécifiée, le résultat est affiché sur la sortie standard |
|---|
| | 220 | . </para> |
|---|
| | 221 | |
|---|
| | 222 | <para> <envar>LOGTIMESTAMP</envar> permet de surcharger quelle heure doit être évaluée |
|---|
| | 223 | (plutÎt que la derniÚre heure). </para> |
|---|
| | 224 | |
|---|
| | 225 | <para> Un administrateur peut exécuter ce script une fois par heure |
|---|
| | 226 | pour surveiller les problÚmes de réplication. |
|---|
| | 227 | </para> |
|---|
| | 228 | </sect2> |
|---|
| | 229 | |
|---|
| | 230 | <sect2 id="wikigen"> <title>Produire un rapport de surveillance au format MediaWiki</title> |
|---|
| | 231 | |
|---|
| | 232 | <indexterm><primary> générer la documentation Wiki d'un cluster </primary></indexterm> |
|---|
| | 233 | |
|---|
| | 234 | <para>Le script <filename>mkmediawiki.pl </filename>, situé dans |
|---|
| | 235 | <filename>tools</filename>, peut être utilisé pour générer un rapport de |
|---|
| | 236 | surveillance du cluster compatible avec le logiciel populaire |
|---|
| | 237 | <ulink url="http://www.mediawiki.org/">MediaWiki </ulink>. |
|---|
| | 238 | Notons que l'option <option>--categories</option> permet à l'utilisateur |
|---|
| | 239 | de préciser un ensemble de catégories (séparées par une virgule) qui seront |
|---|
| | 240 | associées aux résultats. Si vous avez une série de clusters &slony1; |
|---|
| | 241 | passer l'option <option>--categories=slony1</option> entraînera la création |
|---|
| | 242 | d'une page catégorie répertoriant l'ensemble des clusters &slony1;. </para> |
|---|
| | 243 | |
|---|
| | 244 | <para>On pourra utiliser le commande ainsi: </para> |
|---|