{"id":83,"date":"2011-09-20T15:39:52","date_gmt":"2011-09-20T13:39:52","guid":{"rendered":"http:\/\/blog.lokizone.net\/?p=83"},"modified":"2011-09-20T15:47:36","modified_gmt":"2011-09-20T13:47:36","slug":"check-audio-stream-dans-nagios","status":"publish","type":"post","link":"https:\/\/blog.lokizone.net\/?p=83","title":{"rendered":"Check audio stream dans Nagios"},"content":{"rendered":"<p>J&rsquo;ai fait un petit script en bash pour faire un service <a href=\"http:\/\/www.nagios.org\/\" target=\"_blank\">Nagios<\/a>. Le voici \u00e0 disposition.<\/p>\n<p><!--more--><\/p>\n<p>Celui-ci utilise <a href=\"http:\/\/streamripper.sourceforge.net\/\" target=\"_blank\">streamripper<\/a> pour dumper le flux audio pendant $DURATION secondes et v\u00e9rifier que le fichier cr\u00e9e fait au moins $DUMP_LIMIT ko.<br \/>\nIl suffit de lui passer l&rsquo;url du flux en param\u00e8tre.<\/p>\n<p><code><br \/>\n#! \/bin\/bash<\/p>\n<p># This check uses streamripper to dump a continuous audio stream, check if file exists and<br \/>\n# determine if the streaming service is working or not.<br \/>\n#<br \/>\n# \u00a9 Nicolas Perrin 2011<\/p>\n<p>PATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin<\/p>\n<p>PROGNAME=`basename $0`<br \/>\nPROGPATH=`echo $0 | sed -e 's,[\\\\\/][^\\\\\/][^\\\\\/]*$,,'`<br \/>\nREVISION=\"1.0\"<br \/>\n# stream dump duration (in seconds)<br \/>\nDURATION=\"5\"<br \/>\n# attended dump size<br \/>\nDUMP_LIMIT=\"10\"<\/p>\n<p>. $PROGPATH\/utils.sh<\/p>\n<p>case \"$1\" in<br \/>\n\t--help | -h )<br \/>\n\t\techo \"This plugin checks audio stream using the streamripper package.\"<br \/>\n\t\techo \"usage: $PROGNAME URL\"<br \/>\n\t\texit 0<br \/>\n\t\t;;<br \/>\n\t--version | -V )<br \/>\n\t   \techo $PROGNAME $REVISION<br \/>\n\t\texit 0<br \/>\n\t\t;;<br \/>\n\t*)<br \/>\n\t\t# previous dump files cleaning<br \/>\n\t\trm \/tmp\/stream_dump* > \/dev\/null 2>&1<br \/>\n\t\trm -rf \/tmp\/incomplete > \/dev\/null 2>&1<br \/>\n\t\t#stream dump<br \/>\n\t\tSTATUS=`\/usr\/bin\/streamripper \u201c$1\u201d -d \/tmp\/ -a stream_dump -sA -l $DURATION 2>&1 | grep \"^error\"`<br \/>\n\t\tif [ -z \"$STATUS\" ]; then<br \/>\n\t\t\tSTREAM_SIZE=`stat --printf=\"%s\" \/tmp\/stream_dump.mp3`<br \/>\n\t               if [ ${STREAM_SIZE} -gt $DUMP_LIMIT ]; then<br \/>\n\t                       echo \"Stream OK - $1\"<br \/>\n\t\t\t\texit $STATE_OK<br \/>\n\t               else<br \/>\n\t                       echo \"STREAM WARNING - Stream too small ! - $1\"<br \/>\n\t                       exit $STATE_WARNING<br \/>\n\t               fi<br \/>\n\t\telse<br \/>\n\t\t\techo \"STREAM CRITICAL - streamripper returned state: $STATUS\"<br \/>\n\t\t\texit $STATE_CRITICAL<br \/>\n\t\tfi<br \/>\n\t\t;;<br \/>\nesac<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>J&rsquo;ai fait un petit script en bash pour faire un service Nagios. Le voici \u00e0 disposition.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[25,24],"class_list":["post-83","post","type-post","status-publish","format-standard","hentry","category-non-classe","tag-bash","tag-supervision"],"_links":{"self":[{"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=83"}],"version-history":[{"count":8,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions"}],"predecessor-version":[{"id":91,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=\/wp\/v2\/posts\/83\/revisions\/91"}],"wp:attachment":[{"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lokizone.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}