{"id":935,"date":"2010-12-02T18:34:12","date_gmt":"2010-12-02T18:34:12","guid":{"rendered":"https:\/\/supportex.net\/?p=935"},"modified":"2019-05-11T05:41:22","modified_gmt":"2019-05-11T03:41:22","slug":"snmp-extend-feature-nagios","status":"publish","type":"post","link":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/","title":{"rendered":"Using SNMP extend feature in Nagios"},"content":{"rendered":"<p>In <a href=\"http:\/\/supportex.net\/\">Supportex<\/a> we monitor a lot of web services and devices. One of the most convenient ways to monitor various parameters is SNMP <strong>extend<\/strong> feature.<\/p>\n<p>Let&#8217;s consider how it works. Assume you already have SNMP daemon installed.<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Firstly you need to add configuration line in you SNMP daemon config and restart daemon:<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<blockquote><p>extend raid-md0 \/usr\/local\/bin\/check_md_raid.pl<\/p><\/blockquote>\n<p>To use Nagios with <strong>extend<\/strong> feature you can use Michal Ludvig&#8217;s plugin, which could be found on his <a href=\"http:\/\/www.logix.cz\/michal\/devel\/nagios\/\">page<\/a>.<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Next you need to create Nagios command:<br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">check_snmp_extend:USER1$\/check_snmp_extend_em.pl -H $HOSTADDRESS$ -c $ARG1$<\/code><\/li>\n<li>And finally create Nagios service:<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">define service {\nuse check_snmp_extend_service\nservice_description RAID md0 \tstatus\ncheck_command \tcheck_snmp_extend!raid-md0\nhost_name server41\ncontact_groups \tSupportex\n}<\/pre>\n<p>To meet our requirements we wrote our own script for Nagios with pure Perl, so it doesn&#8217;t fork external command \u00a0<strong>snmpget<\/strong> now and should work faster. Besides it could be used with \u00a0<a href=\"http:\/\/nagios.sourceforge.net\/docs\/3_0\/embeddedperl.html\">embedded Nagios Perl<\/a>.<br \/>\nTo use it you should install Net::SNMP library for Perl. So use<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">[root@playground ~]#yum install perl-Net-SNMP<\/code><\/p>\n<p>for Centos or Fedora and<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">[root@playground ~]#aptitude install libsnmp-perl<\/code><\/p>\n<p>for Ubuntu or Debian.<\/p>\n<p><a href=\"http:\/\/supportex.net\/files\/check_snmp_extend_em.pl\">Download<\/a> script for getting SNMP extend output.<\/p>\n<p>Here it is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/perl\n# nagios: +epn\n#\n# Pure Perl script for getting SNMP extend output.\n# Alex Tykhonov, Supportex.net, 2010.\n# http:\/\/supportex.net\/\n# mail:\nuse POSIX;\nuse strict;\nuse Getopt::Long;\nuse lib &amp;amp;amp;quot;\/usr\/lib64\/nagios\/plugins&amp;amp;amp;quot; ;\nuse utils qw(%ERRORS &amp;amp;amp;amp;print_revision &amp;amp;amp;amp;support &amp;amp;amp;amp;usage );\nuse Net::SNMP v5.1.0 qw(snmp_type_ntop DEBUG_ALL);\nsub print_usage {print '';};\n\n# SNMP stuff:\nmy $USER = &amp;amp;amp;quot;yoursnmpuser&amp;amp;amp;quot;;\nmy $PASS = &amp;amp;amp;quot;strongspassword&amp;amp;amp;quot;;\nmy $AUTHPROT = &amp;amp;amp;quot;yourAuthProt&amp;amp;amp;quot;;\nmy $PRIVPROT = &amp;amp;amp;quot;yourProvProt&amp;amp;amp;quot;;\n\n# Host related\nmy $host_address;\nmy $snmp_port;\nmy $command;\n\nGetOptions(&amp;amp;amp;quot;port=s&amp;amp;amp;quot;, $snmp_port, &amp;amp;amp;quot;c=s&amp;amp;amp;quot;, $command, &amp;amp;amp;quot;H=s&amp;amp;amp;quot;, $host_address);\nunless ( defined($host_address) &amp;amp;amp;amp;&amp;amp;amp;amp; defined($command) )\n{\nprint_usage();\n}\n\nif ( !defined($snmp_port) ) {$snmp_port = &amp;amp;amp;quot;161&amp;amp;amp;quot;; }\n\n$ENV{'PATH'}='';\n$ENV{'BASH_ENV'}='';\n$ENV{'ENV'}='';\n\nmy ($s, $error) = Net::SNMP-&amp;amp;amp;gt;session(\n-hostname =&amp;amp;amp;gt; $host_address,\n-version =&amp;amp;amp;gt; &amp;amp;amp;quot;3&amp;amp;amp;quot;,\n-username =&amp;amp;amp;gt; $USER,\n-authprotocol =&amp;amp;amp;gt; $AUTHPROT,\n-authpassword =&amp;amp;amp;gt; $PASS,\n-privpassword =&amp;amp;amp;gt; $PASS,\n-privprotocol =&amp;amp;amp;gt; $PRIVPROT,\n-port =&amp;amp;amp;gt; $snmp_port );\nif (!defined($s)) {\nprintf(&amp;amp;amp;quot;ERROR: %s.n&amp;amp;amp;quot;, $error);\nexit 1;\n}\n\nmy $oid = &amp;amp;amp;quot;.1.3.6.1.4.1.8072.1.3.2.3.1.2.&amp;amp;amp;quot;;\n$oid = $oid . length($command);\n\nmy @array = split(\/\/, $command);\nmy $item;\nmy $ret = 3;\nforeach $item (@array) { $oid = $oid . &amp;amp;amp;quot;.&amp;amp;amp;quot; . ord($item); }\n\nmy $response = $s-&amp;amp;amp;gt;get_request(\n-varbindlist =&amp;amp;amp;gt; [$oid]\n);\n$s-&amp;amp;amp;gt;close;\n\nmy $output = $response-&amp;amp;amp;gt;{$oid};\nif ( $output =~ \/OK\/ ) { $ret = 0; }\nif ( $output =~ \/WARNING\/ ) { $ret = 1; }\nif ( $output =~ \/CRITICAL\/ ) { $ret = 2; }\n\nprint $output, &amp;amp;amp;quot;n&amp;amp;amp;quot;;\n\nexit($ret);\n<\/pre>\n<p><strong>Didn&#8217;t find the answer to your question? <a href=\"\/contacts\/\">Ask it<\/a> our administrators to reply we will publish on website.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Supportex we monitor a lot of web services and devices. One of the most convenient ways to monitor various parameters is SNMP extend feature. Let&#8217;s consider how it works. Assume you already have SNMP daemon installed. Firstly you need to add configuration line in you SNMP daemon config and restart daemon: extend raid-md0 \/usr\/local\/bin\/check_md_raid.pl&hellip; <\/p>\n<div class=\"readmore-wrapper\"><a href=\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\" class=\"more-link\">Read <\/a><\/div>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[152],"tags":[275,161,201,202],"class_list":["post-935","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-monitoring","tag-nagios-en","tag-snmp-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using SNMP extend feature in Nagios &#8211; Supportex.NET blog<\/title>\n<meta name=\"description\" content=\"How to use SNMP extend feature in Nagios\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using SNMP extend feature in Nagios &#8211; Supportex.NET blog\" \/>\n<meta property=\"og:description\" content=\"How to use SNMP extend feature in Nagios\" \/>\n<meta property=\"og:url\" content=\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\" \/>\n<meta property=\"og:site_name\" content=\"Supportex.NET blog\" \/>\n<meta property=\"article:published_time\" content=\"2010-12-02T18:34:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-11T03:41:22+00:00\" \/>\n<meta name=\"author\" content=\"Oleksii Tykhonov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oleksii Tykhonov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\"},\"author\":{\"name\":\"Oleksii Tykhonov\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"headline\":\"Using SNMP extend feature in Nagios\",\"datePublished\":\"2010-12-02T18:34:12+00:00\",\"dateModified\":\"2019-05-11T03:41:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\"},\"wordCount\":187,\"commentCount\":0,\"keywords\":[\"linux\",\"monitoring\",\"nagios\",\"snmp\"],\"articleSection\":[\"linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\",\"url\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\",\"name\":\"Using SNMP extend feature in Nagios &#8211; Supportex.NET blog\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\"},\"datePublished\":\"2010-12-02T18:34:12+00:00\",\"dateModified\":\"2019-05-11T03:41:22+00:00\",\"author\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"description\":\"How to use SNMP extend feature in Nagios\",\"breadcrumb\":{\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/supportex.net\/blog\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using SNMP extend feature in Nagios\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\",\"url\":\"https:\/\/supportex.net\/blog\/en\/\",\"name\":\"Supportex.NET blog\",\"description\":\"Server and network management company\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\",\"name\":\"Oleksii Tykhonov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"caption\":\"Oleksii Tykhonov\"},\"url\":\"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using SNMP extend feature in Nagios &#8211; Supportex.NET blog","description":"How to use SNMP extend feature in Nagios","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/","og_locale":"en_US","og_type":"article","og_title":"Using SNMP extend feature in Nagios &#8211; Supportex.NET blog","og_description":"How to use SNMP extend feature in Nagios","og_url":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/","og_site_name":"Supportex.NET blog","article_published_time":"2010-12-02T18:34:12+00:00","article_modified_time":"2019-05-11T03:41:22+00:00","author":"Oleksii Tykhonov","twitter_misc":{"Written by":"Oleksii Tykhonov","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#article","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/"},"author":{"name":"Oleksii Tykhonov","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"headline":"Using SNMP extend feature in Nagios","datePublished":"2010-12-02T18:34:12+00:00","dateModified":"2019-05-11T03:41:22+00:00","mainEntityOfPage":{"@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/"},"wordCount":187,"commentCount":0,"keywords":["linux","monitoring","nagios","snmp"],"articleSection":["linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/","url":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/","name":"Using SNMP extend feature in Nagios &#8211; Supportex.NET blog","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/en\/#website"},"datePublished":"2010-12-02T18:34:12+00:00","dateModified":"2019-05-11T03:41:22+00:00","author":{"@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"description":"How to use SNMP extend feature in Nagios","breadcrumb":{"@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/supportex.net\/blog\/2010\/12\/snmp-extend-feature-nagios\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/supportex.net\/blog\/en\/"},{"@type":"ListItem","position":2,"name":"Using SNMP extend feature in Nagios"}]},{"@type":"WebSite","@id":"https:\/\/supportex.net\/blog\/en\/#website","url":"https:\/\/supportex.net\/blog\/en\/","name":"Supportex.NET blog","description":"Server and network management company","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251","name":"Oleksii Tykhonov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","caption":"Oleksii Tykhonov"},"url":"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/"}]}},"_links":{"self":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/comments?post=935"}],"version-history":[{"count":2,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions"}],"predecessor-version":[{"id":3248,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/935\/revisions\/3248"}],"wp:attachment":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/media?parent=935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/categories?post=935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/tags?post=935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}