{"id":1495,"date":"2013-03-31T21:41:02","date_gmt":"2013-03-31T20:41:02","guid":{"rendered":"http:\/\/mikaeljensen.dk\/blog\/?p=1495"},"modified":"2013-03-31T21:41:02","modified_gmt":"2013-03-31T20:41:02","slug":"nagios-on-raspberry-pi","status":"publish","type":"post","link":"http:\/\/mikaeljensen.dk\/blog\/?p=1495","title":{"rendered":"Nagios on Raspberry Pi"},"content":{"rendered":"<p>A quick guide to install the normal Nagios via apt-get on an Raspberry PI using the standard Raspbian OS.<\/p>\n<p>&#8211; Preliminary; I have bought 2 Raspberry PI&#8217;s version B with 512MB RAM. The first is going to be used for Nagios monitoring of my home appliances which has grown to an incredible 45 devices. I&#8217;ve been reading through a lot of blogs describing how to compile the Nagios from bottom-up. The 1st RPI also servers as a portal server for my guest wifi, not that I have that many guests, but I wanted to make som fun to. The second RPI is going to be used as an Ubiquiti Unifi server compiled from scratch with the soft-floating Raspbian image and Mongodb, more on this in a later article.<\/p>\n<p>I took a different approach, as I wanted to make the install as simple as possible, so I&#8217;ve used the common software found through apt-get. And yes I do know Nagios is not the latest version, but I do not care about as it is running a decent version 3.4.1.<\/p>\n<p>Some things to consider before going down this path:<\/p>\n<ul>\n<li>Make an static IP, this makes it easier to reach.<\/li>\n<li>Enable SSH from the install screen<\/li>\n<\/ul>\n<p>Now let&#8217;s install (all this is done via SSH as my RP is headless), I do assume you have installed the Raspbian image on the SD-card, plugged in the network cable,SD-card and power)<\/p>\n<ol>\n<li>apt-get update<\/li>\n<li>apt-get upgrade (now the RPI is up to date but might take some time)<\/li>\n<li>apt-get install nagios<\/li>\n<li>It will ask you for an password for nagiosadmin.<\/li>\n<\/ol>\n<p>Now all done \ud83d\ude42 You can login to http:\/\/ip-of-your-server\/nagios3\u00a0 using nagiosadmin and the password you issued.<\/p>\n<p>If you have encountered some Nagios installations before, be aware the files you need to use are not in the usual spots as described on Nagios.org<\/p>\n<ul>\n<li>\/etc\/nagios3 &#8211; this is your primary folder\u00a0 where e.g. commands.cfg resides.<\/li>\n<li>\/etc\/nagios3\/conf.d\/ &#8211; this is the folder for all your config files. I used these for the basic monitoring tasks.<\/li>\n<li>\/etc\/nagios-plugins\u00a0 &#8211; home of all the native plugins like http_check<\/li>\n<\/ul>\n<p>I needed to check http status of some surveillance cams which I have choosen to monitor on other ports than the normal port 80 (web).<br \/>\nFor this to be succesfull you will have to edit \/etc\/nagios-plugins\/config\/http.cfg and insert following $ARG$ to the end of the line like this;<\/p>\n<p><strong># &#8216;check_http&#8217; command definition<\/strong><br \/>\n<strong>define command{<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 command_name\u00a0\u00a0\u00a0 check_http<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 command_line\u00a0\u00a0\u00a0 \/usr\/lib\/nagios\/plugins\/check_http -H &#8216;$HOSTADDRESS$&#8217; -I &#8216;$HOSTADDRESS$&#8217; &#8216;$ARG1$&#8217;<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/strong><\/p>\n<p>Then make another file for these devices, I&#8217;ve used <strong>services.cfg<\/strong><\/p>\n<p><strong>define service{<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 use\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 generic-service\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ; Inherit default values from a template<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 host_name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name-of-your-machine<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 service_description\u00a0\u00a0\u00a0\u00a0 HTTP:PORT<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 check_command\u00a0\u00a0 check_http!-p 10000 ;<\/strong>with 10000 as the port you want to monitor for http service<br \/>\n<strong>}<\/strong><\/p>\n<p>Presumably you have a host file named <strong>hostname.cfg<\/strong> with following basic input<\/p>\n<p>define host {<br \/>\nuse\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 generic-host<br \/>\nhost_name\u00a0\u00a0\u00a0\u00a0\u00a0 name-of-your-machine<br \/>\naddress\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 192.168.1.2<br \/>\n}<\/p>\n<p>Then save all your work and <strong>service nagios3 restart <\/strong>and refresh your browser.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A quick guide to install the normal Nagios via apt-get on an Raspberry PI using the standard Raspbian OS. &#8211; Preliminary; I have bought 2 Raspberry PI&#8217;s version B with 512MB RAM. The first is going to be used for Nagios monitoring of my home appliances which has grown to an incredible 45 devices. I&#8217;ve [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1498,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[454,5],"tags":[564,379,589,591,590,592],"class_list":["post-1495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-2","category-mikael","tag-564","tag-hvalso","tag-nagios","tag-pi","tag-raspberry","tag-raspbian"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/mikaeljensen.dk\/blog\/wp-content\/uploads\/pi1l.jpg","_links":{"self":[{"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1495"}],"version-history":[{"count":3,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1495\/revisions"}],"predecessor-version":[{"id":1499,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1495\/revisions\/1499"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=\/wp\/v2\/media\/1498"}],"wp:attachment":[{"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1495"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mikaeljensen.dk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}