#!/bin/bash
operLogDir="/usr/local/apache/htdocs/db_backup/operLog"
alarmLogDir="/usr/local/apache/htdocs/db_backup/alarmLog"

operLogFile=$operLogDir/"operationLog"`date +%Y%m%d`".csv"
alarmLogFile=$alarmLogDir/"alarmLog"`date +%Y%m%d`".csv"

/usr/bin/mysql  -prootaa <<_EOF_
use OMC_PUB;
SELECT sysConf.sysTypeName,sysAlarmLog.sysNo,sysAlarmLog.subSysNo,sysAlarmLevelDesc.desc_2,sysAlarmConf.alarmDesc_2,sysAlarmLog.alarmTime,sysAlarmLog.clearTime,sysAlarmLog.clearBy INTO OUTFILE "$alarmLogFile" FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM (((sysAlarmLog INNER JOIN sysConf ON sysConf.sysTypeNo=sysAlarmLog.sysTypeNo) INNER JOIN sysAlarmConf ON sysAlarmLog.compCode=sysAlarmConf.compCode AND sysAlarmLog.alarmCode=sysAlarmConf.alarmCode AND sysAlarmLog.sysTypeNo=sysAlarmConf.sysTypeNo) INNER JOIN sysAlarmLevelDesc ON sysAlarmConf.alarmLevel=sysAlarmLevelDesc.level);

SELECT * INTO OUTFILE "$operLogFile" FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM sysOperLog;
_EOF_

