{"id":409,"date":"2014-12-07T19:21:43","date_gmt":"2014-12-07T11:21:43","guid":{"rendered":"http:\/\/blog.yaojun.sg\/?p=409"},"modified":"2014-12-07T19:21:43","modified_gmt":"2014-12-07T11:21:43","slug":"nagios-part-1-installing-nagios-4-on-freebsd-10-1","status":"publish","type":"post","link":"https:\/\/blog.yaojun.sg\/?p=409","title":{"rendered":"Nagios (Part 1) &#8211; Installing Nagios 4 on FreeBSD 10.1"},"content":{"rendered":"<p>Nagios is one of the popular network and systems monitoring tool available. There are two main flavours of Nagios, Nagios XI the enterprise software and Nagios-Core the &#8220;Open-Source&#8221; version. This post\u00a0serves as a tutorial on setting it up on FreeBSD 10.1-Release that runs inside a vSphere environment.<\/p>\n<h2>Update FreeBSD base system<\/h2>\n<pre>freebsd-update fetch\r\nfreebsd-update install<\/pre>\n<h3>Get FreeBSD Ports Tree<\/h3>\n<pre>portsnap fetch extract update<\/pre>\n<p>One of the strength of FreeBSD is the FreeBSD ports tree which is a huge repository of make files for installation in FreeBSD. FreeBSD ports tree are maintained by the FreeBSD ports team and they are well maintained and very much up to date. Software can be compiled from source with the use of additional flags made possible by the make system in FreeBSD. If compiling is not your cup of tea, FreeBSD 10 also has the pkg system where binary packages are download from a repository tree much like yum in RHEL\/Centos and apt-get in Debian\/Ubuntu.<\/p>\n<h2>Setting Up OpenSSL<\/h2>\n<p>With a handful of SSL related vulnerabilities made public this year, it is advisable to use\u00a0the\u00a0Ports version of\u00a0OpenSSL as it is much more current as compared with the one that came with the base OS. Many applications have a dependency on OpenSSL for SSL connections, so it is advisable to install this first in a new system.<\/p>\n<pre>cd \/usr\/ports\/security\/openssl\r\nmake config-recursive\r\nmake install clean<\/pre>\n<p>In order to use the ports version of openssl we need to edit \/etc\/make.conf,<\/p>\n<pre>echo \"WITH_OPENSSL_PORT=YES\" &gt;&gt; \/etc\/make.conf<\/pre>\n<h3>Configuring OpenSSL<\/h3>\n<pre>mv \/usr\/bin\/openssl \/usr\/bin\/openssl.default\r\nln -s \/usr\/local\/bin\/openssl \/usr\/bin\/\r\ncp \/usr\/local\/openssl\/openssl.cnf.example \/usr\/local\/openssl\/openssl.cnf<\/pre>\n<h2>Setting Up PortMaster<\/h2>\n<p>PortMaster is a tool to manage the ports that are installed on the FreeBSD system which includes\u00a0easy upgrading of ports.<\/p>\n<pre>cd \/usr\/ports\/ports-mgmt\/portmaster\r\nmake config-recursive\r\nmake install clean<\/pre>\n<h2>Open-VM-Tools<\/h2>\n<p>Although VMware freebsd tools works, VMware is always slow in the release of the tools for FreeBSD.<\/p>\n<pre>cd \/usr\/ports\/emulators\/open-vm-tools-nox11\/\r\nmake config-recursive\r\nmake install clean<\/pre>\n<p>Make sure that the Open-VM-Tools works on reboot by editing the \/etc\/rc.conf<\/p>\n<pre>vmware_guest_vmblock_enable=\"YES\"\r\nvmware_guest_vmhgfs_enable=\"YES\"\r\nvmware_guest_vmmemctl_enable=\"YES\"\r\nvmware_guest_vmxnet_enable=\"YES\"\r\nvmware_guestd_enable=\"YES\"<\/pre>\n<h2>Vim-Lite<\/h2>\n<p>We all need our favourite text editor to configure Nagios and other configuration files.<\/p>\n<pre>cd \/usr\/ports\/editors\/vim-lite\r\nmake config-recursive\r\nmake install clean<\/pre>\n<p>edit ~\/.vimrc<\/p>\n<pre>syntax on\r\nset background=dark\r\nset shiftwidth=2\r\nset tabstop=2\r\nset nocompatible\r\nset expandtab\r\nset autoindent\r\nset ruler\r\nif has(\"autocmd\")\r\n filetype plugin indent on\r\nendif\r\nset showcmd \" Show (partial) command in status line.\r\nset showmatch \" Show matching brackets.\r\nset ignorecase \" Do case insensitive matching\r\nset smartcase \" Do smart case matching\r\nset incsearch \" Incremental search\r\nset hidden \" Hide buffers when they are abandoned\r\nset backspace=indent,eol,start\r\nset mouse=<\/pre>\n<h2>SSMTP<\/h2>\n<p>Refer to this <a href=\"http:\/\/easyos.net\/articles\/bsd\/freebsd\/using_gmail_smtp_to_send_email_in_freebsd\" target=\"_blank\">article to setup an authenticated system email with Gmail<\/a>.<\/p>\n<h2>Web Server<\/h2>\n<p>Nagios has a web based dashboard to provide an overview of the state of the monitored machines.<\/p>\n<pre>Install Apache24\r\ncd \/usr\/ports\/www\/apache24\r\nmake config-recursive\r\nmake install clean\r\nvim \/etc\/rc.conf\r\napache24_enable=yes<\/pre>\n<h3>Install PHP 5.6<\/h3>\n<pre>cd \/usr\/ports\/lang\/php56\r\nmake config-recursive\r\nmake install clean<\/pre>\n<h3>Install PHP56-extensions<\/h3>\n<pre>cd \/usr\/ports\/lang\/php56-extensions\r\nmake config-recursive\r\nmake install clean<\/pre>\n<h3>Install PHP56 Apache module<\/h3>\n<pre>cd \/usr\/ports\/www\/mod_php56\r\nmake config-recursive\r\nmake install clean<\/pre>\n<p>Edit httpd.conf to insert the following to the configuration file<\/p>\n<pre>&lt;FilesMatch \".php$\"&gt;\r\n    SetHandler application\/x-httpd-php\r\n&lt;\/FilesMatch&gt;\r\n&lt;FilesMatch \".phps$\"&gt;\r\n    SetHandler application\/x-httpd-php-source\r\n&lt;\/FilesMatch&gt;\r\n<\/pre>\n<pre>cp \/usr\/local\/etc\/php.ini-production \/usr\/local\/etc\/php.ini<\/pre>\n<pre>cd \/usr\/ports\/net-mgmt\/nagios4\r\nmake config-recursive\r\nmake install clean<\/pre>\n<p>Ensure that mod_cgi is enabled in \/usr\/local\/etc\/apache24\/httpd.conf by uncommenting the following line<\/p>\n<pre class=\"p1\"><span class=\"s1\">LoadModule<\/span> <span class=\"s2\">cgi<\/span>_module libexec\/apache24\/mod_<span class=\"s2\">cgi<\/span>.so<\/pre>\n<p>Restart the apache service to check if nagios is accessible.<\/p>\n<p>More about the installation and configuration of Nagios to follow. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nagios is one of the popular network and systems monitoring tool available. There are two main flavours of Nagios, Nagios XI the enterprise software and Nagios-Core the &#8220;Open-Source&#8221; version. This post\u00a0serves as a tutorial on setting it up on FreeBSD 10.1-Release that runs inside a vSphere environment. Update FreeBSD base system freebsd-update fetch freebsd-update install [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,10,13,15],"class_list":["post-409","post","type-post","status-publish","format-standard","hentry","category-tech","tag-bsd","tag-freebsd","tag-monitoring","tag-nagios"],"_links":{"self":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts\/409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=409"}],"version-history":[{"count":0,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=\/wp\/v2\/posts\/409\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.yaojun.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}