{"id":898,"date":"2024-06-04T16:13:29","date_gmt":"2024-06-04T14:13:29","guid":{"rendered":"https:\/\/anjo.pt\/keyword-oracle\/?p=898"},"modified":"2024-06-10T09:52:13","modified_gmt":"2024-06-10T07:52:13","slug":"how-to-use-zabbix-to-monitor-oracle-db-a-quick-test-run","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2024\/06\/04\/how-to-use-zabbix-to-monitor-oracle-db-a-quick-test-run\/","title":{"rendered":"How to use Zabbix to monitor Oracle DB &#8211; a quick test run"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Currently I&#8217;m testing different solutions for monitoring (mostly) Oracle databases. One solution in the shortlist is Zabbix.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Zabbix is open-source and currently has a quite active community helping out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On Zabbix website there is a nice quick <a href=\"https:\/\/www.zabbix.com\/download\">download and setup instructions<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"758\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1024x758.png\" alt=\"\" class=\"wp-image-899\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1024x758.png 1024w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-300x222.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-768x569.png 768w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image.png 1207w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ll use a <a href=\"https:\/\/anjo.pt\/keyword-oracle\/2024\/03\/10\/install-oracle-linux-9-and-oracle-database-19c-on-windows-wsl\/\" data-type=\"post\" data-id=\"880\">Oracle Linux 9 VM under Windows WSL2<\/a> for installing Zabbix. For the exercise, I&#8217;ll configure it with PostgreSQL. The database installation step is missing. So, here are all the steps I&#8217;ve done.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">1. Install Zabbix<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Disable using Zabbix packages provided by Oracle-epel, by adding &#8220;excludepkgs=zabbix*&#8221; to \/etc\/yum.repos.d\/oracle-epel-ol9.repo :<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# cat \/etc\/yum.repos.d\/oracle-epel-ol9.repo\n\n&#x5B;ol9_developer_EPEL]\nname=Oracle Linux $releasever EPEL Packages for Development ($basearch)\nbaseurl=https:\/\/yum$ociregion.$ocidomain\/repo\/OracleLinux\/OL9\/developer\/EPEL\/$basearch\/\ngpgkey=file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-oracle\ngpgcheck=1\nenabled=1\nexcludepkgs=zabbix*\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Add Zabbix repository<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# rpm -Uvh https:\/\/repo.zabbix.com\/zabbix\/6.4\/rhel\/9\/x86_64\/zabbix-release-6.4-1.el9.noarch.rpm\n\n# dnf clean all\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Install Zabbix server, frontend and agent<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">2. Install PostgreSQL<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">At the time of writing, the latest version was PostgreSQL 16. Again, to make sure I get the packages from the best source, I install posture repo<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# dnf install https:\/\/download.postgresql.org\/pub\/repos\/yum\/reporpms\/EL-9-x86_64\/pgdg-redhat-repo-latest.noarch.rpm\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">And install the latest version<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# dnf install postgresql16 postgresql16-server\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Then we initialize and start the postgreSQL server (I do not enable the service, as this is only a test)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# \/usr\/pgsql-16\/bin\/postgresql-16-setup initdb\nInitializing database ... OK\n\n# systemctl start postgresql-16\n\n# ss -antpl | grep 5432\nLISTEN 0      200        127.0.0.1:5432       0.0.0.0:*    users:((&quot;postgres&quot;,pid=23637,fd=7))\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">3. Create and configure Zabbix repository DB<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a user called zabbix and then a database also called zabbix, having the created user as owner<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# sudo -u postgres createuser --pwprompt zabbix\n# sudo -u postgres createdb -O zabbix zabbix\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Fill up the repository DB with the initial schema and data. It will make a long output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# zcat \/usr\/share\/zabbix-sql-scripts\/postgresql\/server.sql.gz | sudo -u zabbix psql zabbix\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Put the Password you setup for zabbix user above in the configuration file<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# read -s -p &quot;Zabbix password:&quot; DBPWD\n# sed -i -E &quot;s\/^# DBPassword=\/DBPassword=$DBPWD\/&quot; \/etc\/zabbix\/zabbix_server.conf \n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">4. Configure the nix webserver <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Set the port and hostname in configuration file<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# sed -i -E &#039;s\/^#.*listen\/listen\/&#039; \/etc\/nginx\/conf.d\/zabbix.conf\n# sed -i -E &quot;s\/^#server_name.*\/server_name $(hostname -f);\/&quot; \/etc\/nginx\/conf.d\/zabbix.conf\n# grep -E &#039;listen|server_name&#039; \/etc\/nginx\/conf.d\/zabbix.conf\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">On WSL2 you need to find your computer IP address and then you can access the Zabbix:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# hostname -I\n172.31.152.146\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">5. Finish configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Then you can continue with Zabbix configuration on the web browser<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"590\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1-1024x590.png\" alt=\"\" class=\"wp-image-900\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1-1024x590.png 1024w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1-300x173.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1-768x443.png 768w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-1.png 1143w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As Zabbix per default uses the Public schema from PostgreSQL, on the screen below, leave the field &#8220;Database Schema&#8221; empty. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"504\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-2.png\" alt=\"\" class=\"wp-image-902\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-2.png 851w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-2-300x178.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-2-768x455.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On the next screen it asks for the Server name, and you can give the result of $(hostname) command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And you can login to Zabbix. The default user is Admin, and password zabbix:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"368\" height=\"379\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-3.png\" alt=\"\" class=\"wp-image-903\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-3.png 368w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-3-291x300.png 291w\" sizes=\"auto, (max-width: 368px) 100vw, 368px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">6. Install Zabbix Agent2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On the server with Oracle database, download and install Zabbix Agent2<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# rpm -Uvh https:\/\/repo.zabbix.com\/zabbix\/6.4\/rhel\/9\/x86_64\/zabbix-release-6.4-1.el9.noarch.rpm\n\n# dnf clean all\n\n# dnf install zabbix-agent2\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Update the Agent configuration file. After some fight, these were the sittings I changed in the monitored server \/etc\/zabbix\/zabbix_agent2.conf file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nServer=0.0.0.0\/0           # Accept connections from any Zabbix Server\nListenPort=12051            # Port where Agent listen for Server requests - default Port did not work\nServerActive=127.0.1.2  # IP Address of the Zabbix Server\nHostname=Anjo-X13      # Hostname of the monitored server\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">And restart the Agent<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n# systemctl restart zabbix-agent2\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Create Oracle user<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On the database to be monitored, create a database user:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nexport z_crd=&quot;zabbix_pwd&quot;\n\n$   sqlplus -S -L \/ as sysdba &lt;&lt;EOF\nSET PAGES 0 HEAD OFF ECHO OFF FEED OFF\nWHENEVER SQLERROR EXIT SQL.SQLCODE\nCREATE USER c##zabbix_mon IDENTIFIED BY &quot;${z_crd}&quot;;\nALTER USER c##zabbix_mon SET CONTAINER_DATA=ALL CONTAINER=CURRENT;\nGRANT CONNECT, CREATE SESSION TO c##zabbix_mon;\nGRANT SELECT_CATALOG_ROLE to c##zabbix_mon;\nGRANT SELECT ON v_\\$instance TO c##zabbix_mon;\nGRANT SELECT ON v_\\$database TO c##zabbix_mon;\nGRANT SELECT ON v_\\$sysmetric TO c##zabbix_mon;\nGRANT SELECT ON v_\\$system_parameter TO c##zabbix_mon;\nGRANT SELECT ON v_\\$session TO c##zabbix_mon;\nGRANT SELECT ON v_\\$recovery_file_dest TO c##zabbix_mon;\nGRANT SELECT ON v_\\$active_session_history TO c##zabbix_mon;\nGRANT SELECT ON v_\\$osstat TO c##zabbix_mon;\nGRANT SELECT ON v_\\$restore_point TO c##zabbix_mon;\nGRANT SELECT ON v_\\$process TO c##zabbix_mon;\nGRANT SELECT ON v_\\$datafile TO c##zabbix_mon;\nGRANT SELECT ON v_\\$pgastat TO c##zabbix_mon;\nGRANT SELECT ON v_\\$sgastat TO c##zabbix_mon;\nGRANT SELECT ON v_\\$log TO c##zabbix_mon;\nGRANT SELECT ON v_\\$archive_dest TO c##zabbix_mon;\nGRANT SELECT ON v_\\$asm_diskgroup TO c##zabbix_mon;\nGRANT SELECT ON sys.dba_data_files TO c##zabbix_mon;\nGRANT SELECT ON DBA_TABLESPACES TO c##zabbix_mon;\nGRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO c##zabbix_mon;\nGRANT SELECT ON DBA_USERS TO c##zabbix_mon;\nEOF\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">7. Add host to Zabbix server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On Zabbix web interface go to &#8220;Monitoring&#8221; &#8211; &#8220;Hosts&#8221; and click &#8220;Create Host&#8221; on the top right.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is the configuration that worked with me. The IP address is the one from Anjo-X13, the monitored server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"637\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6-1024x637.png\" alt=\"\" class=\"wp-image-907\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6-1024x637.png 1024w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6-300x186.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6-768x477.png 768w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-6.png 1044w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">On the &#8220;Macros&#8221; tab I had to add the following three parameters and respective values<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"278\" height=\"199\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-7.png\" alt=\"\" class=\"wp-image-908\"\/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After this, I restarted the agent and started to get information.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"834\" height=\"132\" src=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-8.png\" alt=\"\" class=\"wp-image-909\" srcset=\"https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-8.png 834w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-8-300x47.png 300w, https:\/\/anjo.pt\/keyword-oracle\/wp-content\/uploads\/sites\/3\/2024\/05\/image-8-768x122.png 768w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Zabbix seems quite complete solution, even if the wording used is not very clear. I did not manage to make the &#8220;Named Sessions&#8221; to work, which would allow to configure the database credentials directly on the Agent configuration file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Two monitoring &#8220;Items&#8221; I disabled:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>oracle.redolog.info &#8211; it expects minimum 5 redolog groups, which I do not have on my test DBs<\/li>\n\n\n\n<li>oracle.tbs_used_pct &#8211; which checks the percentage of allocated space used for each tablespace, not looking at the autoextend (there is oracle.tbs_used_from_max_pct for that).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">When looking for a lighter alternative to Enterprise Manager, which also monitors other RDBMS, Zabbix is something to consider. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Currently I&#8217;m testing different solutions for monitoring (mostly) Oracle databases. One solution in the shortlist is Zabbix. Zabbix is open-source and currently has a quite active community helping out. On Zabbix website there is a nice quick download and setup instructions: I&#8217;ll use a Oracle Linux 9 VM under Windows WSL2 for installing Zabbix. For [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-898","post","type-post","status-publish","format-standard","category-oracle","czr-hentry"],"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=898"}],"version-history":[{"count":4,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/898\/revisions"}],"predecessor-version":[{"id":920,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/898\/revisions\/920"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}