shell通过钉钉输出简易的表格格式

function SendMessageToDingding(){

        url="https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        UA="Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"

        res=`curl -XPOST -s -L -H "Content-Type:application/json" -H "charset:utf-8" $url -d "

        {

        \"msgtype\": \"text\",

        \"text\": {

                \"content\": \"$1\n$2\n$3\n$4\n$5\n$6\n$7\"

                }

    }"`

        echo $res

}

subject="xxx.xxx.xxx.xxx"

by="Process    Memory_Used    Memory_Usage %"

PrimProc=`mcsadmin getSystemMemoryUsers | grep "PrimProc" | cut -f 5`

WriteEngineServ=`mcsadmin getSystemMemoryUsers | grep "WriteEngineServ" | cut -f 5`

mysqld=`mcsadmin getSystemMemoryUsers | grep "mysqld" | cut -f 5`

DMLProc=`mcsadmin getSystemMemoryUsers | grep "DMLProc" | cut -f 5`

ExeMgr=`mcsadmin getSystemMemoryUsers | grep "ExeMgr" | cut -f 5`

SendMessageToDingding "subject:"$subject "$by" "$PrimProc" "$WriteEngineServ"  "$mysqld" "$DMLProc" "$ExeMgr"


脚本运行结果:


你可能感兴趣的:(shell通过钉钉输出简易的表格格式)