add to crontab:
* * * * * /etc/zabbix/set_wait_classes.sh oracle_sid /oracle/app/base/db/12.1.0.2 /etc/zabbix/res_sqldb.ini WRITE_WAITS
script:
cat /etc/zabbix/set_wait_classes.sh #!/bin/bash ORACLE_SID="$1" ORACLE_HOME="$2" INI_FILE="$3" PARAM="$4" WAIT_CLASS="$5" export ORACLE_HOME PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch export PATH LD_LIBRARY_PATH_64=$ORACLE_HOME/lib64:/usr/local/lib64:/lib64:/usr/lib64 export LD_LIBRARY_PATH_64 LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/local/lib:/lib:/usr/lib export LD_LIBRARY_PATH NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS' NLS_LANG=AMERICAN_AMERICA.AL32UTF8 export ORACLE_SID USERNAME="zabbix" USERPASSWORD="herewasthepassword" #Проверка кода завершения function detect_error () { if [ $? -ne 0 ] then echo "ERROR for ${1}. " exit 1 fi } #Выполнить SQL function sqlexecute { result=`sqlplus -s ${USERNAME}/${USERPASSWORD} <<EOF set echo off serverout on HEADS off FEED off HEA off TRIM on TRIMS on ${SQL} ; exit EOF` detect_error "sqlplus ${SQL}" if echo "${result}" | egrep "^(SP-|ORA-|PLS-)" >/dev/null then echo "ERROR for SQL. ${SQL}" echo "${result}" exit 1 fi #Удалить пустые строки, пробелы и табуляции из результата echo "${result}" | grep -v ^Elapsed | grep -v ^$ | sed 's/ [\t]*//g' detect_error "sed 's/[ \t]*//g'" } #BEGIN SQL="" case $PARAM in "WRITE_WAITS") SQL="select count (*) || '~'|| nvl(wait_class,'CPU')|| '~'||to_char(sysdate,'yyyy-dd-mm-hh24:mi') from v\$active_session_history where SAMPLE_TIME > sysdate-1/1440 group by wait_class" sqlexecute > ${INI_FILE} ;; "SET_PARAM") if grep "${WAIT_CLASS}" ${INI_FILE} >/dev/null then grep "${WAIT_CLASS}" ${INI_FILE} | awk -F"~" '{print $1}' else echo "0" fi detect_error "Error print WAIT_CLASS" ;; *) help ;; esac
modify /etc/zabbix/zabbix_agentd.conf add
UserParameter=oracle.monitor.wait[*],/etc/zabbix/set_wait_classes.sh oracle_sid /oracle/app/base/db/12.1.0.2 /etc/zabbix/res_sqldb.ini SET_PARAM "$1"
and here is zabbix template with correct colors :
[code]
<zabbix_export>
<version>2.0</version>
<date>2016-11-23T14:00:15Z</date>
<groups>
<group>
<name>db_hosts_INC000002161969</name>
</group>
</groups>
<templates>
<template>
<template>db_wait_template</template>
<name>db_wait_template</name>
<groups>
<group>
<name>db_hosts_INC000002161969</name>
</group>
</groups>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<items>
<item>
<name>wait Administrative</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Administrative]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Application</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Application]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Cluster</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Cluster]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Commit</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Commit]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Concurrency</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Concurrency]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Configuration</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Configuration]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait CPU</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[CPU]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait IO</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[UserI/O]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Network</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Network]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Other</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Other]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Queueing</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Queueing]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait Scheduler</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[Scheduler]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
<item>
<name>wait SystemIO</name>
<type>0</type>
<snmp_community/>
<multiplier>0</multiplier>
<snmp_oid/>
<key>oracle.monitor.wait[SystemI/O]</key>
<delay>60</delay>
<history>7</history>
<trends>365</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units>ses</units>
<delta>0</delta>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<formula>1</formula>
<delay_flex/>
<params/>
<ipmi_sensor/>
<data_type>0</data_type>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>Oracle wait event</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
</item>
</items>
<discovery_rules/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
<graphs>
<graph>
<name>EM</name>
<width>900</width>
<height>200</height>
<yaxismin>0.0000</yaxismin>
<yaxismax>100.0000</yaxismax>
<show_work_period>1</show_work_period>
<show_triggers>1</show_triggers>
<type>1</type>
<show_legend>1</show_legend>
<show_3d>0</show_3d>
<percent_left>0.0000</percent_left>
<percent_right>0.0000</percent_right>
<ymin_type_1>0</ymin_type_1>
<ymax_type_1>0</ymax_type_1>
<ymin_item_1>0</ymin_item_1>
<ymax_item_1>0</ymax_item_1>
<graph_items>
<graph_item>
<sortorder>8</sortorder>
<drawtype>0</drawtype>
<color>444444</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Administrative]</key>
</item>
</graph_item>
<graph_item>
<sortorder>5</sortorder>
<drawtype>0</drawtype>
<color>FF3333</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Application]</key>
</item>
</graph_item>
<graph_item>
<sortorder>11</sortorder>
<drawtype>0</drawtype>
<color>CCCCCC</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Cluster]</key>
</item>
</graph_item>
<graph_item>
<sortorder>6</sortorder>
<drawtype>0</drawtype>
<color>EEEE00</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Commit]</key>
</item>
</graph_item>
<graph_item>
<sortorder>4</sortorder>
<drawtype>0</drawtype>
<color>AA0000</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Concurrency]</key>
</item>
</graph_item>
<graph_item>
<sortorder>7</sortorder>
<drawtype>0</drawtype>
<color>888800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Configuration]</key>
</item>
</graph_item>
<graph_item>
<sortorder>0</sortorder>
<drawtype>0</drawtype>
<color>00C800</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[CPU]</key>
</item>
</graph_item>
<graph_item>
<sortorder>2</sortorder>
<drawtype>0</drawtype>
<color>0000CC</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[UserI/O]</key>
</item>
</graph_item>
<graph_item>
<sortorder>9</sortorder>
<drawtype>0</drawtype>
<color>777777</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Network]</key>
</item>
</graph_item>
<graph_item>
<sortorder>12</sortorder>
<drawtype>0</drawtype>
<color>FF9999</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Other]</key>
</item>
</graph_item>
<graph_item>
<sortorder>10</sortorder>
<drawtype>0</drawtype>
<color>555555</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Queueing]</key>
</item>
</graph_item>
<graph_item>
<sortorder>1</sortorder>
<drawtype>0</drawtype>
<color>99FF99</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[Scheduler]</key>
</item>
</graph_item>
<graph_item>
<sortorder>3</sortorder>
<drawtype>0</drawtype>
<color>9999FF</color>
<yaxisside>0</yaxisside>
<calc_fnc>2</calc_fnc>
<type>0</type>
<item>
<host>db_wait_template</host>
<key>oracle.monitor.wait[SystemI/O]</key>
</item>
</graph_item>
</graph_items>
</graph>
</graphs>
</zabbix_export>
[/code]
The result is:
Short variant:
touch res_sqldb.ini touch set_wait_classes.sh chown oracle: res_sqldb.ini chown oracle: set_wait_classes.sh chmod 777 set_wait_classes.sh chmod 777 res_sqldb.ini * * * * * /etc/zabbix/set_wait_classes.sh u02pgu1 /oracle/app/base/db/11.2.0.4/ /etc/zabbix/res_sqldb.ini WRITE_WAITS * * * * * /etc/zabbix/set_wait_classes.sh u02pgu2 /oracle/app/base/db/11.2.0.4/ /etc/zabbix/res_sqldb.ini WRITE_WAITS add to /etc/zabbix/zabbix_agentd.conf UserParameter=oracle.monitor.wait[*],/etc/zabbix/set_wait_classes.sh u02pgu1 /oracle/app/base/db/11.2.0.4 /etc/zabbix/res_sqldb.ini SET_PARAM "$1"
Thx to Vladimir Mukin for material