安裝zabbix agent
方法1
rpm包安裝
redhat6
wget https://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-agent-3.4.9-1.el6.x86_64.rpm
rpm -ivhzabbix-agent-3.4.9-1.el6.x86_64.rpm
/etc/init.d/zabbix_agentd start
chkconfig --add zabbix_agentd
chkconfig --level 12345 zabbix_agentd on
redhat7
rpm -ihttps://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
rpm -ivhzabbix-release-3.4-2.el7.noarch.rpm
systemctl start zabbix_agentd
systemctl enable zabbix_agentd
yum方法網絡安裝
CentOS6
/etc/init.d/zabbix_agentd start
chkconfig --level 12345 zabbix_agentd on
CentOS7
yum -y install zabbix-agentd
systemctl start zabbix_agentd
systemctl enable zabbix_agentd
方法2
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
tar zxvf zabbix-3.4.12.tar.gz
ll
cd zabbix-3.4.12
ll
groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
./configure --prefix=/usr/local/zabbix-3.4.12--with-net-snmp --enable-agent
make
make install
cp misc/init.d/tru64/zabbix_agentd/etc/init.d/
chmod +x /etc/init.d/zabbix_agentd
vi /etc/init.d/zabbix_agentd
# chkconfig: 2345 10 90
# description: myservice ....
DAEMON=/usr/local/zabbix-3.4.12/sbin/zabbix_agentd
vim?/usr/local/zabbix-3.4.12/etc/zabbix_agentd.conf
Server=172.16.80.222
ListenPort=10050
ServerActive=172.16.80.222
Hostname=Oracle1
/etc/init.d/zabbix_agentd start
chkconfig --add zabbix_agentd
注:libpcre是pcre-devel.x86_64的包含的文件。
安裝配置orabbix
Oracle中創建監控用戶并賦予權限
grant alter session to zabbix;
grantcreate session to zabbix;
grant connect to zabbix;
alter user zabbix default role all;
grant select on v_$instance to zabbix;
grant select on dba_users to zabbix;
grant select on v_$log_historyto zabbix;
grant select on v_$parameterto zabbix;
grant select on sys.dba_audit_sessionto zabbix;
grant select on v_$lock tozabbix;
grant select on dba_registryto zabbix;
grant select onv_$librarycache to zabbix;
grant select on v_$sysstat tozabbix;
grant select on v_$parameterto zabbix;
grant select on v_$latch to zabbix;
grant select on v_$pgastat tozabbix;
grant select on v_$sgastat tozabbix;
grant select onv_$librarycache to zabbix;
grant select on v_$process tozabbix;
grant select on dba_data_filesto zabbix;
grant select on dba_temp_filesto zabbix;
grant select on dba_free_spaceto zabbix;
grant select onv_$system_event to zabbix;
grant select ondba_tablespaces to zabbix;
grant select on v_$session to zabbix;
grant select on dba_objects tozabbix;
grant select onv_$locked_object to zabbix;
grant select on v_$log tozabbix;
ACL:
??? dbms_network_acl_admin.create_acl(
??? acl =>'UTL_INADDR.xml',
??? description =>'utl_inaddr',
??? principal => 'ZABBIX',
??? is_grant => TRUE,
??? privilege => 'resolve'
??? );
??? commit;
end;
/
??? dbms_network_acl_admin.add_privilege (
??? acl => 'UTL_INADDR.xml',
??? principal => 'ZABBIX',
??? is_grant => TRUE,
??? privilege => 'connect'
??? );
??? commit;
end;
/
??? dbms_network_acl_admin.assign_acl(
??? acl => 'UTL_INADDR.xml',
??? host => '*'
??? );
??? commit;
end;
/
Zabbix端需要做的配置
安裝orabbix?
下載地址:http://www.smartmarmot.com/product/orabbix/download/
? ?? ? 1
)在/opt創建目錄創建orabbix文件。(原因:orabbix啟動文件默認寫在/opt/orabbix目錄下,也可以修改一下orabbix啟動腳本的路徑)? ?? ?? ??
#mkdir /opt/orabbix
#mv orabbix-1.2.3.zip /opt/orabbix
#cd /opt/orabbit
#unzip orabbix-1.2.3.zip
授予文件可執行的權限
#chmod a+x /opt/orabbix -R
創建一個名為config.props文件,有模板可以參考。
#cp /opt/orabbix/conf/config.props.sample config.props
修改confi.props配置文件,僅需修改如下內容即可。
# cat /opt/orabbix/conf/config.props |grep-v "#"?? 這里僅取沒有注釋的。
ZabbixServerList=ZabbixServer????????? #zabbix名稱
ZabbixServer.Address=192.168.0.119???? #zabbix服務端的IP地址
ZabbixServer.Port=10051??????????????? #zabbix服務端的端口
OrabbixDaemon.PidFile=./logs/orabbix.pid
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100
DatabaseList=twstcptest.com??? #這個名稱可以隨便起,但是必須跟監控的主機名保持一致。
DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1
twstcptest.com.Url=jdbc:oracle:thin:@192.168.0.110:1521:rdcms? #這里主要是通過JDBC來連接客戶端的。rdcms主要是數據庫的實例名稱。在客戶端可以通過select instance_name from v$instance來得到實例的名稱。
twstcptest.com.User=zabbix????? #數據庫用戶
twstcptest.com.Password=zabbix? #數據庫用戶密碼
twstcptest.com.MaxActive=10
twstcptest.com.MaxWait=100
twstcptest.com.MaxIdle=1
twstcptest.com.QueryListFile=./conf/query.props
vi /opt/orabbix/conf/query.props
tbl_space.Query=SELECT * FROM ( \
select '- Tablespace ->',t.tablespace_namektablespace, \
??????'- Type->',substr(t.contents, 1, 1) tipo, \
??????'- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024)ktbs_em_uso, \
??????'- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
??????'- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
??????'- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024)kfree_space, \
??????'- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space,0))/1024/1024) kspace, \
??????'- Perc->',decode(d.tbs_maxsize, 0, 0,trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
from \
? (select SUM(bytes) tbs_size, \
??????????SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize,tablespace_name tablespace \
???from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes,tablespace_name \
???from dba_data_files \
???union all \
???select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
???from dba_temp_files \
??? )\
???group by tablespace_name \
??? )d, \
??? (select SUM(bytes) free_space, \
???tablespace_name tablespace \
???from dba_free_space \
???group by tablespace_name \
??? )s, \
???dba_tablespaces t \
???where t.tablespace_name = d.tablespace(+) and \
???t.tablespace_name = s.tablespace(+) \
???order by 8) \
???where kperc >60 \
???and tipo <>'T' \
???and tipo <>'U'
如上修改kperc > 60,也就是使用率達到60%以上
參考:
https://www.cnblogs.com/zoulongbin/p/6395047.html
https://blog.csdn.net/ttt111zzz/article/details/79000411
https://blog.csdn.net/mchdba/article/details/51366790
http://www.cnblogs.com/leipei2352/archive/2011/06/14/2080575.html