Purpose: The purpose of the experiment was to zabbix server capable of real-time monitoring oracle instance on a server whether the normal connection
Environment: 1, zabbix_server 2, zabbix_agent (containing oracle)
Main points:
1, zabbix_get usage
2, python modules in cx_Oracle
------------------------------------------------------------------------------
1, zabbix_get usage
Common usage
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key
In the end we zabbix_server can test a zabbix_agent end of key
It will return a result under normal circumstances
Note: For zabbix client which key values, we can use zabbix_agentd -p command to view the client
as a key test of my own creation
2. Creating a Custom Key
Create custom key method is quite simple
Add a few parameters in our client's zabbix_agentd.conf configuration file on it
This is what I added two lines
1, UnsafeUserParameters parameter has two values 1 or 0
1 to 0 to disable open
2, UserParameter = key name, command or script (usage)
After completion of the configuration remember to restart the client process! !
3, custom scripts
This step is the most central of all you want to achieve monitoring can be planned at this stage
I tested the connection state oracle instance (or even can not connect)
code show as below
#-*- encoding: utf-8 -*- import cx_Oracle try: conn=cx_Oracle.connect('system/[email protected]:1521/orcl') c=conn.cursor() c.close() conn.close() print('1') except cx_Oracle.DatabaseError,error: print('2')
Which you need to use a third-party modules cx_Oracle
Installation can be seen
https://blog.csdn.net/qq_36743482/article/details/80884190
I mention it here:
Although when I run the script alone is no error, but when I tested with zabbix_get still have to import a module error
This is because the client shared library links do not do a good job
Add the path where libclntsh.so.11.1
In the run ldconfig take effect your configuration commands
Test again
This basically been completed
The rest is added at the end of the web to monitor this key is
4, web end add monitoring
Monitoring item is created, we create the trigger.
So far, the trigger has been created (when the return value 2, that is, even when the barrier will trigger an alarm)!
Then we can test yourself
When we turn off the monitor database
Obviously server receives the return value is 2
We take a look at the web end
See the web end has prompted alarm
Then we opened up listener
This time web end has been suggested that the problem has been resolved!
The experiments so far have all been completed.