zoukankan      html  css  js  c++  java
  • 清除方式日志收集

    #! /bin/sh
    # The script is used for test log collection.
    
        
    function usage()
    {
      echo "
            Usage:
              $0 node_type start/stop  case_number
                    
            Example:
              $0 cp start
              $0 cp stop embms-9237
            
            Note: please configure DB's information inside the scripts so that can collect DB's log remotely.
    "
    
    }
    
    
    #used for copy db log to current server
    dbIP="192.168.107.35"
    dbNodeUser="admin"
    dbPassword="!QAZ2wsx3edc4rfv"
    dbLog="/var/postgres/log/postgresql*.csv"
    
    #cp application log
    cpAccessLog="/var/log/access.log"
    cpEventLog="/var/log/event.log"
    cpPerformanceLog="/var/log/performance.log"
    cpMonitorLog="/var/ericsson/log/event.log"
    
    #up application log
    upSessionLog="/var/log/session.log"
    upTrafficLog="/var/log/traffic.log"
    upMonitorLog="/var/log/event.log"
    
    #vcs log
    vcsLog="/var/VRTSvcs/log/engine_A.log"
    
    #system log
    messageLog="/var/log/messages"
    cronLog="/var/log/cron"
    secureLog="/var/log/secure"
    
    CPAppLog=($cpAccessLog $cpEventLog $cpPerformanceLog $vcsLog $messageLog $cronLog $secureLog)
    UPAppLog=($upSessionLog $upTrafficLog $messageLog $vcsLog $cronLog $secureLog)
    logList=
    logDirectory=
    
    [ $# -lt 2 ] && usage && exit 1;
    
    NODE_TYPE=$1
    COMMAND=$2
    CASE_NUMBER=
    
    case "$NODE_TYPE" in
        CP| cp| MDFCP| mdfcp) 
            logList=${CPAppLog[@]}
        ;;
        UP| up| MDFUP| mdfup)
            logList=${UPAppLog[@]}
        ;;
        *)
            usage
            exit 1
        ;;
    esac
        
        
    start_tc()
    {  
        for i in ${logList[@]}
        do
            cat $i >> $i".history."`date +%Y%m%d`
            > $i
        done 
    
      echo "TC started."
    }
    
    createDirectory()
    {
        logDirectory=$1"-"`date +%Y%m%d%H%M`
        [ -d $logDirectory ] && mv $logDirectory $logDirectory".history."`date +%Y%m%d%H%M%S`
        
        mkdir $logDirectory
        if [ $? -ne 0 ]; then
            echo "create log directory $logDirectory failed, exit!"
            exit
        else
            echo "the logs are stored in ./$logDirectory"
        fi
    }
    
    copyDBLog()
    {
    
        expect -c "
        spawn scp  -o StrictHostKeyChecking=no  $dbNodeUser@$dbIP:$dbLog $logDirectory
    
        expect "assword"
        send "$dbPassword
    "
        expect eof
        "
    }
    
    stop_tc()
    {
        createDirectory $CASE_NUMBER
        
        for i in ${logList[@]}
        do
            cp $i $logDirectory
        done 
        copyDBLog
    
      echo "TC ${CASE_NUMBER} stopped. Log dir: ${logDirectory}"
      
    }
    
    
    case "$COMMAND" in
        "start")
            start_tc
            ;;
        "stop")
        CASE_NUMBER=$3
            stop_tc
            ;;
        *)
            usage
            exit 2
            ;;
    esac
  • 相关阅读:
    .net core 3.0中可以使用gRPC了
    Java clone() 浅克隆与深度克隆(转)
    CENTOS下搭建SVN服务器(转)
    设置eclipse不同的workspace共享配置
    在Eclipse添加Android兼容包( v4、v7 appcompat )(转)
    【原创】Nginx+PHP-FPM优化技巧总结(转)
    【汇总】PHP-FPM 配置优化(转)
    nginx File not found 错误(转)
    nginx php-fpm安装配置(转)
    nginx优化(转)
  • 原文地址:https://www.cnblogs.com/tlmn2008/p/7761934.html
Copyright © 2011-2022 走看看