- zabbix#vi /opt/script/conf/config.sh
- NAME_PW=username/password
- export NAME_PW
- zabbix#vi /opt/script/logger.sh
- #!/bin/bash
- . /opt/script/conf/config.sh
- export ORACLE_SID=oracle1 #数据库实例名
- export ORACLE_HOME=/oracle/procduct/9.2
- su oracle -c "${ORACLE_HOME}/bin/sqlplus -S /nolog" <<EOF
- SET FEEDBACK OFF;
- SET ECHO OFF;
- CONN $NAME_PW
- insert into table_test(id,date.messages) values($!,sysdate,$2)# 向表 table_test 中插入数据
- commit;
- exit
- EOF
- zabbix#sh /opt/script/logger.sh 1,test# 向数据库中写入数据
来源: http://www.bubuko.com/infodetail-2504920.html