{"id":255,"date":"2018-07-05T21:24:38","date_gmt":"2018-07-05T21:24:38","guid":{"rendered":"https:\/\/projects-42.nl\/?p=255"},"modified":"2018-07-19T19:29:10","modified_gmt":"2018-07-19T19:29:10","slug":"deploy-a-zabbix-server-to-monitor-your-infrastructure","status":"publish","type":"post","link":"https:\/\/projects-42.nl\/index.php\/2018\/deploy-a-zabbix-server-to-monitor-your-infrastructure\/","title":{"rendered":"Deploy a Zabbix server to monitor your infrastructure"},"content":{"rendered":"<p>If you maintain a ICT infrastructure you probably use (or your looking to use) a monitoring solution to monitor your ICT infrastructure. Detecting, and fixing, problems before end users start experiencing them is something most ICT professionals love to <span class=\"gt-baf-word-clickable\">accomplish, <span id=\"result_box\" class=\"\" lang=\"en\"><span class=\"\">preferably every time a problem occurs<\/span><\/span><\/span>.<\/p>\n<p>Zabbix is an open-source monitoring solution for servers, network devices and (web) applications. In this article we will setup a Zabbix server and install the Zabbix client on a Linux and a Windows server.<\/p>\n<p><strong>Setting up the Zabbix Server<\/strong><\/p>\n<p>We will be using a Ubuntu 16.04 server for the Zabbix server (i know 18.04 is already out there but because of some hypervisor related problems i am not yet able to install 18.04).<\/p>\n<p>Before we start installing Zabbix, we need to install a number of prerequisites. to installe these type in (or copy) the following commands:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo apt-get update\r\nsudo apt-get install apache2 libapache2-mod-php7.0 php7.0 php7.0-xml php7.0-bcmath php7.0-mbstring mysql-server -y<\/pre>\n<p>Now we need to add the Zabbix repository. This will ensure we will receive updates for Zabbix when the are released.<\/p>\n<p>Zabbix uses an installer packet to add the repository to the system. Use the following commands to download and install the Zabbix repository:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">wget\u00a0http:\/\/repo.zabbix.com\/zabbix\/3.2\/ubuntu\/pool\/main\/z\/zabbix-release\/zabbix-release_3.2-1+xenial_all.deb\r\nsudo dpkg\u00a0-i\u00a0zabbix-release_3.2-1+xenial_all.deb<\/pre>\n<p>With that out of the way we can install Zabbix server and agent.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo apt-get update\r\nsudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent -y<\/pre>\n<p>Because Zabbix wont create its own database we will need to take care of it, use the following commands to log in to the mysql server and create the database (change &lt;zabbix_user&gt; and &lt;zabbix_password&gt; to a username and password):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">mysql -u root -p\r\nCREATE DATABASE zabbix_db character set utf8 collate utf8_bin;\r\nGRANT ALL PRIVILEGES on zabbix_db.* to &lt;zabbix_user&gt;@localhost identified by '&lt;zabbix_password&gt;';\r\nFLUSH PRIVILEGES;\r\nexit;\r\n\r\ncd \/usr\/share\/doc\/zabbix-server-mysql\/\r\nsudo zcat create.sql.gz | mysql -u &lt;zabbix_user&gt; -p zabbix_db<\/pre>\n<p>Now we have to point the Zabbix server to the newly created database. First we need to open the configuration file:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo nano \/etc\/zabbix\/zabbix_server.conf\r\n<\/pre>\n<p>Now we have to find the DB configuration and configure it as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DBName=zabbix_db\r\nDBUser=<span class=\"\">&lt;zabbix_user&gt;<\/span>\r\nDBPassword=<span class=\"st0\">&lt;zabbix_password&gt;<\/span><\/pre>\n<p>Next up is the timezone. we have to change this in two files, the Zabbix config and the php config. you can find your timezone in this list: <a href=\"http:\/\/php.net\/manual\/en\/timezones.php\">http:\/\/php.net\/manual\/en\/timezones.php<\/a><\/p>\n<p>Use the following commands to edit the Zabbix config:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo nano \/etc\/zabbix\/apache.conf\r\n\r\n# fint the line:\r\n# php_value date.timezone Europe\/Riga\r\n\r\n# Replace it with \r\nphp_value date.timezone &lt;your_timezone&gt;<\/pre>\n<p>Now for the php config:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo nano \/etc\/php\/7.0\/apache2\/php.ini\r\n\r\n# fint the line:\r\n;date.timezone =\r\n\r\n# replace it with\r\ndate.timezone = &lt;your_timezone&gt;\r\n<\/pre>\n<p>Now we can start Zabbix and make the service for the server and client start at boot (we also need to restart apache2):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo systemctl restart zabbix-agent\r\nsudo systemctl restart apache2\r\nsudo systemctl restart zabbix-server\r\n\r\nsudo systemctl enable zabbix-server\r\nsudo systemctl enable zabbix-agent<\/pre>\n<p>The zabbix server is now operational, so is the Zabbix agent. Now we have to configure the Zabbix web interface to be able to use the Server (and agent).<\/p>\n<p>Navigate your browser to http:\/\/&lt;the_ip_of_your_zabbix_server&gt;\/zabbix<\/p>\n<p>You page should look like the following image:<\/p>\n<figure id=\"attachment_258\" aria-describedby=\"caption-attachment-258\" style=\"width: 846px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-258 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix01.png\" alt=\"\" width=\"846\" height=\"498\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix01.png 846w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix01-300x177.png 300w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix01-768x452.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\" \/><figcaption id=\"caption-attachment-258\" class=\"wp-caption-text\">Click &#8220;Next Step&#8221; to continue.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_266\" aria-describedby=\"caption-attachment-266\" style=\"width: 700px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-266 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/0-36qWtUKA1YWV_0HE.png\" alt=\"\" width=\"700\" height=\"304\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/0-36qWtUKA1YWV_0HE.png 700w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/0-36qWtUKA1YWV_0HE-300x130.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><figcaption id=\"caption-attachment-266\" class=\"wp-caption-text\">If you followed all staps above, the next page should be looking like this. All prerequisites should be met. Click &#8220;Next step&#8221; to continue. (I forgot to capture this page, so its looking a little different.\u00a0 luckily Google has the solution to (almost) every problem).<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_259\" aria-describedby=\"caption-attachment-259\" style=\"width: 844px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-259 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix02.png\" alt=\"\" width=\"844\" height=\"496\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix02.png 844w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix02-300x176.png 300w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix02-768x451.png 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><figcaption id=\"caption-attachment-259\" class=\"wp-caption-text\">Enter the database information you used while configuring the database and click &#8220;Next Step&#8221; to continue.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_260\" aria-describedby=\"caption-attachment-260\" style=\"width: 842px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-260 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix03.png\" alt=\"\" width=\"842\" height=\"497\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix03.png 842w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix03-300x177.png 300w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix03-768x453.png 768w\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" \/><figcaption id=\"caption-attachment-260\" class=\"wp-caption-text\">Now we can give a name to our Zabbix instance the hostname and port configuration can be left at the default stetting (unless you are already using this port for something else or you run the Zabbix server component from a different machine). Click &#8220;Next step&#8221; to continue.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_262\" aria-describedby=\"caption-attachment-262\" style=\"width: 836px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-262 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix05.png\" alt=\"\" width=\"836\" height=\"490\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix05.png 836w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix05-300x176.png 300w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/06\/Zabbix05-768x450.png 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><figcaption id=\"caption-attachment-262\" class=\"wp-caption-text\">The zabbix installation is now complete. Click &#8220;Finish&#8221; to navigate to the Zabbix login page.<\/figcaption><\/figure>\n<p>The default login credentials are username: &#8220;Admin&#8221; and password: &#8220;zabbix&#8221;. Both username and password are case sensitive.<\/p>\n<p><strong>Installing the agent on a Linux host<\/strong><\/p>\n<p>Although we already installed the agent on the zabbix server during the setup process, the process of installing the agent\u00a0 is explained here so it can be easily installed on other on Debian based Linux hosts.<\/p>\n<p>First we need to add the repository (in my case I&#8217;m using xenial, if you are using another distro check <a href=\"http:\/\/repo.zabbix.com\/zabbix\/\">this link<\/a> for the available distro&#8217;s) :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">wget http:\/\/repo.zabbix.com\/zabbix\/3.2\/ubuntu\/pool\/main\/z\/zabbix-release\/zabbix-release_3.2-1+xenial_all.deb\r\nsudo dpkg -i zabbix-release_3.2-1+xenial_all.deb<\/pre>\n<p>Next up, install the agent:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo apt-get update\r\nsudo apt-get install zabbix-agent -y<\/pre>\n<p>Now we need to tell the Zabbix agent where the server is located. To do this open the Zabbix agent configuration:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo nano \/etc\/zabbix\/zabbix_agentd.conf\r\n\r\n# find the line \r\nServer=\r\n\r\n#change it to\r\nServer=&lt;the_ip_of_your_zabbix_server&gt;\r\n\r\n\r\n# find the line \r\nServerActive=\r\n\r\n#change it to\r\nServerActive=&lt;the_ip_of_your_zabbix_server&gt;\r\n\r\n\r\n# find the line \r\nHostname=\r\n\r\n#change it to\r\nHostname=&lt;the_hostname&gt;\r\n\r\n<\/pre>\n<p>Make sure the service is started (with the new configuration) and it will start automatically after the next reboot:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sudo systemctl restart zabbix-agent\r\nsudo systemctl enable zabbix-agent<\/pre>\n<p>Were all done here.<\/p>\n<p><strong>Installing the agent on a Windows host<\/strong><\/p>\n<p>Before we can install the agent, we first need to download it. The agent can be found at the following page &#8220;<a href=\"https:\/\/www.zabbix.com\/download_agents\">https:\/\/www.zabbix.com\/download_agents<\/a>&#8220;. Unlike the Linux agent, the Windows agent is not packaged into a handy installer. Luckily the Zabbix team made it easy to install the Agent service.<\/p>\n<p>After downloading the Zip file from the above link, we have to extract the agent and place it somewhere convenient. I placed my agent files in &#8220;<em>C:\\ProgramData\\zabbix_agent\\<\/em>&#8221; but any directory will do.<\/p>\n<p>Next we have to edit the &#8220;<em>zabbix_agentd.win.conf<\/em>&#8221; file which is located in the &#8220;<em>conf<\/em>&#8221; directory:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># find the line\r\nServer=\r\n\r\n#change it to\r\nServer=&lt;the_ip_of_your_zabbix_server&gt;\r\n\r\n\r\n# find the line\r\nServerActive=\r\n\r\n#change it to\r\nServerActive=&lt;the_ip_of_your_zabbix_server&gt;\r\n\r\n\r\n# find the line\r\nHostname=\r\n\r\n#change it to\r\nHostname=&lt;the_hostname&gt;<\/pre>\n<p>We are now ready to install the agent service. We can do this by calling the &#8220;<em>zabbix_agentd.exe<\/em>&#8221; with the &#8220;<em>&#8211;install<\/em>&#8221; and &#8220;<em>&#8212; config<\/em>&#8221; parameters.<\/p>\n<p>The command to install the agent service is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;location_of_your_zabbix_agent_C:\\_path&gt;\\bin\\&lt;win64_or_win32&gt;\\zabbix_agentd.exe --config &lt;location_of_your_zabbix_agent_C:\\_path&gt;\\conf\\zabbix_agentd.win.conf --install<\/pre>\n<p>To remove the agent use the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;location_of_your_zabbix_agent_C:\\_path&gt;\\bin\\&lt;win64_or_win32&gt;\\zabbix_agentd.exe --config &lt;location_of_your_zabbix_agent_C:\\_path&gt;\\conf\\zabbix_agentd.win.conf --uninstall<\/pre>\n<p>If you open the &#8220;services&#8221; mmc snap-in you will see the &#8220;Zabbix Agent&#8221; service installed and ready to go.<\/p>\n<p><strong>Add a host to Zabbix<\/strong><\/p>\n<p>After installing the server and agent components we can finally start adding hosts to Zabbix.<\/p>\n<p>To add a host, log in to the Zabbix webinterface, navigate to &#8220;Configuration&#8221;-&gt;&#8221;Hosts&#8221; and click the &#8220;Create host&#8221; button at the top right side of the screen.<\/p>\n<figure id=\"attachment_273\" aria-describedby=\"caption-attachment-273\" style=\"width: 871px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-273 size-full\" src=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/07\/Zabbix06.png\" alt=\"\" width=\"871\" height=\"892\" srcset=\"https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/07\/Zabbix06.png 871w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/07\/Zabbix06-293x300.png 293w, https:\/\/projects-42.nl\/wp-content\/uploads\/2018\/07\/Zabbix06-768x787.png 768w\" sizes=\"auto, (max-width: 871px) 100vw, 871px\" \/><figcaption id=\"caption-attachment-273\" class=\"wp-caption-text\">Fill out the &#8220;Add host form&#8221; and put it in the desired group (select Windows servers if you are adding a Windows server, etc.). Click &#8220;add&#8221; to add the host to Zabbix.<\/figcaption><\/figure>\n<p>Optionally you can add templates to the host (the default groups alredy have templates linked to them).<\/p>\n<p>It can take some time (up to 50 min) to get the first redings in the Zabbix web-interface.<\/p>\n<p>&nbsp;<\/p>\n<p>Congratulations, you now have a working Zabbix server with at least one host. Happy monitoring \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you maintain a ICT infrastructure you probably use (or your looking to use) a monitoring solution to monitor your ICT infrastructure. Detecting, and fixing, problems before end users start experiencing them is something most ICT professionals love to accomplish, preferably every time a problem occurs. Zabbix is an open-source monitoring solution for servers, network [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":257,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[21,55],"class_list":["post-255","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general-ict","tag-ubuntu","tag-zabbix"],"_links":{"self":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/comments?post=255"}],"version-history":[{"count":10,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/255\/revisions\/274"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media\/257"}],"wp:attachment":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media?parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/categories?post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/tags?post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}