fluentdã¨fluent-plugin-pghstoreã¨pandorafmsã§ãã°åéãå¯è¦åãç£è¦ãè¡ã
前回の記事ã§å ±åããããã«ãfluent-plugin-pghstoreã§ãã°ãPostgreSQLã«è²¯ãããã¨ãã§ãã¾ããã
次ã¯å¯è¦åã¨ç£è¦ãè¡ãã¾ããããã§ãæè¿ä½¿ã£ã¦ã¿ã¦ããPandora FMSã使ãã¾ãã
pluginãæºå
ã¾ãã¯ä»¥ä¸ã®ã¹ã¯ãªãããä¿åããpandora/etc/pandora/plugins以ä¸ã«ç½®ãã¾ããDBãTABLEã¯é©å®æ¸ãæãã¦ãã ãããã¾ããhostnameãportãé©å®å¤æ´ã§ãé¡ããã¾ãã
ä¸ã®æ¹ã«ããSQLã¯éå»5åéã®codeã2XXã3XXãªã©ã®å²åãåºãã¦ããã¾ãããã®å¾ãPandraFMSã§ã®pluginå½¢å¼ã®XMLã«ããããã«æ´å½¢ãã¾ãã
ã¡ãªã¿ã«ãä¸ã¤ã®SQLã§è¤æ°ãåæã«count()ããæ¹æ³ã«ã¤ãã¦ã¯ 複数同時にcount() ãã©ããã
#!/usr/bin/env sh DB=logdb TABLE=apache_log SQL=`cat <<EOT SELECT \ ROUND(100 * (s.C_2XX::numeric / s.all::numeric), 1) AS C_2, \ ROUND(100 * (s.C_3XX::numeric / s.all::numeric), 1) AS C_3, \ ROUND(100 * (s.C_4XX::numeric / s.all::numeric), 1) AS C_4, \ ROUND(100 * (s.C_5XX::numeric / s.all::numeric), 1) AS C_5, \ s.all AS count \ FROM( \ SELECT \ count(*) AS all, \ count(CASE WHEN record->'code' LIKE '2__' THEN 1 END) AS C_2XX, \ count(CASE WHEN record->'code' LIKE '3__' THEN 1 END) AS C_3XX, \ count(CASE WHEN record->'code' LIKE '4__' THEN 1 END) AS C_4XX, \ count(CASE WHEN record->'code' LIKE '5__' THEN 1 END) AS C_5XX \ FROM $TABLE WHERE time > (CURRENT_TIMESTAMP - interval '5 min') \ )s EOT` RESULT=`psql -At -F " " $DB -c "$SQL"` count=0 for p in $RESULT do case $count in 0) name="http_status_2XX" desc="HTTP Status Code percentage" ;; 1) name="http_status_3XX" desc="HTTP Status Code percentage" ;; 2) name="http_status_4XX" desc="HTTP Status Code percentage" ;; 3) name="http_status_5XX" desc="HTTP Status Code percentage" ;; 4) name="http_access_count" desc="access count" ;; esac echo "<module>" echo " <name><![CDATA[${name}]]></name>" echo " <type><![CDATA[generic_data]]></type>" echo " <data><![CDATA[${p}]]></data>" echo " <description><![CDATA[$desc]]></description>" echo "</module>" count=`expr $count + 1` done
ãã¨ã¯ãpandora_agent.conf ã«ä»¥ä¸ã®ä¸è¡ã足ãã¦ãã ããã
module_plugin http_access_status.sh
ã¯ããçµããã§ããmoduleä½æã¯ç°¡åã§ããã
ã°ã©ãå
ããã¾ã§åºæ¥ãã°ãã¨ã¯PandoraFMSå´ã§ã§ãã¾ãã
ã¬ãã¼ã管ç -> ã°ã©ããã«ãã¼ ã§åã¹ãã¼ã¿ã¹ã³ã¼ãã®å¡ãæ½°ãã®ç©ã¿ä¸ãã°ã©ããä½æãã¾ãã
ããããã¨ããããªæãã®ã°ã©ãããªã¢ã«ã¿ã¤ã ã§åºã¦ãã¾ãã
éä¸ç´«è²ãå¢ãã¦ããã®ã¯ã¢ã©ã¼ãã®ãã¹ããå ¼ãã¦è©¦ãã«å ¥ãã¦ã¿ããã®ã§ãã
ç£è¦
PandoraFMSã¯ç£è¦ã·ã¹ãã ã§ããã§ãã®ã§ã 4XXã5XXã25%ãè¶ãããéç¥ãåºãããªãã¦ãã¨ãç°¡åã«åºæ¥ã¾ãã
ããã§ã¯è©³ããè¿°ã¹ã¾ããã®ã§ã http://www.openideas.info/wiki/index.php?title=Pandora_3.0:Documentation_ja:Alerts ãã¡ããã覧ãã ããã
ã¾ã¨ã
fluentd + fluent-plugin-pghstore + PostgreSQL + Pandora FMSã§
- ãã°åé
- å¯è¦å
- ç£è¦ + ã¢ã©ã¼ã
ãä¸æ°é貫ã§è¡ããããã«ãªãã¾ããã
ä»å試ãããã®ã¯ãfluent-plugin-datacounter + out_growthforecast + growthforecast + nagiosã§å¯è½ã§ããããããfluent-plugin-pghstoreã使ã£ãå ´åãSQLã§ãããããªå¦çãã§ãã¾ãã®ã§ãã¢ã¤ãã¢æ¬¡ç¬¬ã§ä»åã®Status Code以å¤ã«ã使ããã¨æãã¾ãã