使用知行之桥EDI系统时,由于业务数据量的增多,难免会遇到一些系统异常情况,为了保证企业生产环境的稳定运行,EDI系统自带了错误邮件通知功能。此功能保证了在EDI系统自动处理数据的过程中可以将异常信息及时告知用户,使用户收到邮件及时处理,保证数据的正常传输。文章源自懂站帝-http://www.sfdkj.com/12316.html
那么除了一些常见的异常情况,随着企业业务数据量的增大,现有服务器环境可能无法提供足够的磁盘空间存放数据处理的日志和文件,特别是在使用跨平台版本(JAVA版本)的知行之桥EDI系统时,此情况比较常见。基于此背景,我们提供了堆内存占用超过80% 邮件预警以及磁盘空间使用率超过80%邮件预警功能。具体实现步骤如下:文章源自懂站帝-http://www.sfdkj.com/12316.html
一、堆内存占用超过 80% 邮件预警
Java堆内存管理是影响性能的主要因素之一,堆内存过高可能会造成内存溢出,导致进程无法无法访问,从而使EDI系统无法正常运行。为了避免这一问题的出现,提前预警,可以参考以下步骤进行配置:文章源自懂站帝-http://www.sfdkj.com/12316.html
1.新建监控脚本 java_heap_usage_monitor.sh文件,监控脚本的具体代码如下(注:其中_java=/home/java/jdk1.8.0_201/bin/java是当前环境中java执行路径,需要根据自身情况进行修改):文章源自懂站帝-http://www.sfdkj.com/12316.html
1文章源自懂站帝-http://www.sfdkj.com/12316.html 2文章源自懂站帝-http://www.sfdkj.com/12316.html 3文章源自懂站帝-http://www.sfdkj.com/12316.html 4文章源自懂站帝-http://www.sfdkj.com/12316.html 5文章源自懂站帝-http://www.sfdkj.com/12316.html 6文章源自懂站帝-http://www.sfdkj.com/12316.html 7文章源自懂站帝-http://www.sfdkj.com/12316.html 8文章源自懂站帝-http://www.sfdkj.com/12316.html 9文章源自懂站帝-http://www.sfdkj.com/12316.html 10文章源自懂站帝-http://www.sfdkj.com/12316.html 11文章源自懂站帝-http://www.sfdkj.com/12316.html 12文章源自懂站帝-http://www.sfdkj.com/12316.html 13文章源自懂站帝-http://www.sfdkj.com/12316.html 14文章源自懂站帝-http://www.sfdkj.com/12316.html 15文章源自懂站帝-http://www.sfdkj.com/12316.html 16文章源自懂站帝-http://www.sfdkj.com/12316.html 17文章源自懂站帝-http://www.sfdkj.com/12316.html 18文章源自懂站帝-http://www.sfdkj.com/12316.html 19文章源自懂站帝-http://www.sfdkj.com/12316.html 20文章源自懂站帝-http://www.sfdkj.com/12316.html 21文章源自懂站帝-http://www.sfdkj.com/12316.html 22文章源自懂站帝-http://www.sfdkj.com/12316.html 23文章源自懂站帝-http://www.sfdkj.com/12316.html 24文章源自懂站帝-http://www.sfdkj.com/12316.html 25文章源自懂站帝-http://www.sfdkj.com/12316.html 26文章源自懂站帝-http://www.sfdkj.com/12316.html 27文章源自懂站帝-http://www.sfdkj.com/12316.html 28文章源自懂站帝-http://www.sfdkj.com/12316.html 29文章源自懂站帝-http://www.sfdkj.com/12316.html 30文章源自懂站帝-http://www.sfdkj.com/12316.html 31文章源自懂站帝-http://www.sfdkj.com/12316.html 32文章源自懂站帝-http://www.sfdkj.com/12316.html 33文章源自懂站帝-http://www.sfdkj.com/12316.html 34文章源自懂站帝-http://www.sfdkj.com/12316.html 35文章源自懂站帝-http://www.sfdkj.com/12316.html 36文章源自懂站帝-http://www.sfdkj.com/12316.html 37文章源自懂站帝-http://www.sfdkj.com/12316.html 38文章源自懂站帝-http://www.sfdkj.com/12316.html 39文章源自懂站帝-http://www.sfdkj.com/12316.html 40文章源自懂站帝-http://www.sfdkj.com/12316.html 41文章源自懂站帝-http://www.sfdkj.com/12316.html 42文章源自懂站帝-http://www.sfdkj.com/12316.html 43文章源自懂站帝-http://www.sfdkj.com/12316.html 44文章源自懂站帝-http://www.sfdkj.com/12316.html 45文章源自懂站帝-http://www.sfdkj.com/12316.html 46文章源自懂站帝-http://www.sfdkj.com/12316.html 47文章源自懂站帝-http://www.sfdkj.com/12316.html 48文章源自懂站帝-http://www.sfdkj.com/12316.html 49文章源自懂站帝-http://www.sfdkj.com/12316.html 50文章源自懂站帝-http://www.sfdkj.com/12316.html 51文章源自懂站帝-http://www.sfdkj.com/12316.html 52文章源自懂站帝-http://www.sfdkj.com/12316.html 53文章源自懂站帝-http://www.sfdkj.com/12316.html 54文章源自懂站帝-http://www.sfdkj.com/12316.html 55文章源自懂站帝-http://www.sfdkj.com/12316.html 56文章源自懂站帝-http://www.sfdkj.com/12316.html 57文章源自懂站帝-http://www.sfdkj.com/12316.html 58文章源自懂站帝-http://www.sfdkj.com/12316.html 59文章源自懂站帝-http://www.sfdkj.com/12316.html 60文章源自懂站帝-http://www.sfdkj.com/12316.html 61文章源自懂站帝-http://www.sfdkj.com/12316.html 62文章源自懂站帝-http://www.sfdkj.com/12316.html 63文章源自懂站帝-http://www.sfdkj.com/12316.html 64文章源自懂站帝-http://www.sfdkj.com/12316.html 65文章源自懂站帝-http://www.sfdkj.com/12316.html 66文章源自懂站帝-http://www.sfdkj.com/12316.html 67文章源自懂站帝-http://www.sfdkj.com/12316.html 68文章源自懂站帝-http://www.sfdkj.com/12316.html 69文章源自懂站帝-http://www.sfdkj.com/12316.html 70文章源自懂站帝-http://www.sfdkj.com/12316.html 71文章源自懂站帝-http://www.sfdkj.com/12316.html 72文章源自懂站帝-http://www.sfdkj.com/12316.html 73文章源自懂站帝-http://www.sfdkj.com/12316.html 74文章源自懂站帝-http://www.sfdkj.com/12316.html 75文章源自懂站帝-http://www.sfdkj.com/12316.html 76文章源自懂站帝-http://www.sfdkj.com/12316.html 77文章源自懂站帝-http://www.sfdkj.com/12316.html 78文章源自懂站帝-http://www.sfdkj.com/12316.html 79文章源自懂站帝-http://www.sfdkj.com/12316.html 80文章源自懂站帝-http://www.sfdkj.com/12316.html 81文章源自懂站帝-http://www.sfdkj.com/12316.html 82文章源自懂站帝-http://www.sfdkj.com/12316.html 83文章源自懂站帝-http://www.sfdkj.com/12316.html |
#!/usr/bin/env bash文章源自懂站帝-http://www.sfdkj.com/12316.html set -e文章源自懂站帝-http://www.sfdkj.com/12316.html while getopts "v" opt; do文章源自懂站帝-http://www.sfdkj.com/12316.html case $opt in文章源自懂站帝-http://www.sfdkj.com/12316.html v) debug_mode=true;;文章源自懂站帝-http://www.sfdkj.com/12316.html esac文章源自懂站帝-http://www.sfdkj.com/12316.html done文章源自懂站帝-http://www.sfdkj.com/12316.html function _log_msg() {文章源自懂站帝-http://www.sfdkj.com/12316.html if [ $debug_mode ]; then文章源自懂站帝-http://www.sfdkj.com/12316.html echo $1文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html }文章源自懂站帝-http://www.sfdkj.com/12316.html function error() {文章源自懂站帝-http://www.sfdkj.com/12316.html echo $1 >&2文章源自懂站帝-http://www.sfdkj.com/12316.html }文章源自懂站帝-http://www.sfdkj.com/12316.html _java=/home/java/jdk1.8.0_201/bin/java文章源自懂站帝-http://www.sfdkj.com/12316.html # Check if arcesb service is live文章源自懂站帝-http://www.sfdkj.com/12316.html arcesb_pid=$(ps -aux | grep -e "java.*arcesb.jar" | grep -v grep | awk '{ print $2 }')文章源自懂站帝-http://www.sfdkj.com/12316.html if [ ! -n "$arcesb_pid" ]; then文章源自懂站帝-http://www.sfdkj.com/12316.html error "Failed to aceess arcesb process."文章源自懂站帝-http://www.sfdkj.com/12316.html exit 2文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "arcesb pid: $arcesb_pid"文章源自懂站帝-http://www.sfdkj.com/12316.html # Get java major version文章源自懂站帝-http://www.sfdkj.com/12316.html if [[ "$_java" ]]; then文章源自懂站帝-http://www.sfdkj.com/12316.html java_version=$("$_java" -version 2>&1 | awk -F '"' '/version/ {print $2}')文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "java version: $java_version"文章源自懂站帝-http://www.sfdkj.com/12316.html java_major_version=$(echo $java_version | awk -F '.' '{ print $1}')文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "java major version: $java_major_version"文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html if [ $(type -p jmap) ]; then文章源自懂站帝-http://www.sfdkj.com/12316.html _jmap=jmap文章源自懂站帝-http://www.sfdkj.com/12316.html else文章源自懂站帝-http://www.sfdkj.com/12316.html _jmap=/home/java/jdk1.8.0_201/bin/jmap文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "jmap not found, set default to $_jmap"文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html # Get arcesb service heap usage raw result文章源自懂站帝-http://www.sfdkj.com/12316.html if [ "$java_major_version" = "11" ]; then文章源自懂站帝-http://www.sfdkj.com/12316.html heap_res=$(sudo jhsdb jmap --heap --pid $arcesb_pid)文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "sudo jhsdb jmap --heap --pid $arcesb_pid:"文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "$heap_res"文章源自懂站帝-http://www.sfdkj.com/12316.html else文章源自懂站帝-http://www.sfdkj.com/12316.html heap_res=$("$_jmap" -heap $arcesb_pid)文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "sudo $_jmap -heap $arcesb_pid"文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "$heap_res"文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html # Get arcesb service heap usage percent文章源自懂站帝-http://www.sfdkj.com/12316.html if echo "$heap_res" | grep -q -i "garbage-first"; then文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "GC Algorithm: G1"文章源自懂站帝-http://www.sfdkj.com/12316.html key_word="g1 heap"文章源自懂站帝-http://www.sfdkj.com/12316.html elif echo "$heap_res" | grep -q -i "parallel gc"; then文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "GC Algorithm: Parallel GC"文章源自懂站帝-http://www.sfdkj.com/12316.html key_word="old gen"文章源自懂站帝-http://www.sfdkj.com/12316.html elif echo "$heap_res" | grep -q -i "mark sweep"; then文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "GC Algorithm: Mark Sweep"文章源自懂站帝-http://www.sfdkj.com/12316.html key_word="tenured"文章源自懂站帝-http://www.sfdkj.com/12316.html else文章源自懂站帝-http://www.sfdkj.com/12316.html error "Unknow GC Algorithm"文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html if type -p bc > /dev/null; then文章源自懂站帝-http://www.sfdkj.com/12316.html echo "$heap_res" | grep -i "$key_word" -A 10 | grep -e "used$" | head -1 | awk '{ print $1 }' | awk -F '%' '{ print "scale=0;" $1 " / 1" }' | bc -l文章源自懂站帝-http://www.sfdkj.com/12316.html else文章源自懂站帝-http://www.sfdkj.com/12316.html _log_msg "bc command not found"文章源自懂站帝-http://www.sfdkj.com/12316.html echo "$heap_res" | grep -i "$key_word" -A 10 | grep -e "used$" | head -1 | awk '{ print $1 }' | awk -F '%' '{ print $1 }' | awk -F '.' '{ print $1 }'文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html if [ "$?" != "0" ]; then文章源自懂站帝-http://www.sfdkj.com/12316.html error "Failed to parse the result of java heap usage."文章源自懂站帝-http://www.sfdkj.com/12316.html exit 3文章源自懂站帝-http://www.sfdkj.com/12316.html fi文章源自懂站帝-http://www.sfdkj.com/12316.html |
2.将监控脚本 java_heap_usage_monitor.sh文件拷贝至部署EDI的服务器。 3.给予java_heap_usage_monitor.sh文件执行权限,修改文件权限命令如下:文章源自懂站帝-http://www.sfdkj.com/12316.html
1文章源自懂站帝-http://www.sfdkj.com/12316.html |
sudo chmod a+x java_heap_usage_monitor.sh文章源自懂站帝-http://www.sfdkj.com/12316.html |
4.在服务器上测试监控脚本是否工作,执行以下命令,成功执行可以看到当前EDI系统占用堆内存的大小:文章源自懂站帝-http://www.sfdkj.com/12316.html
1文章源自懂站帝-http://www.sfdkj.com/12316.html |
./java_heap_usage_monitor.sh文章源自懂站帝-http://www.sfdkj.com/12316.html |
5.在EDI系统页面创建Script端口,修改监控脚本 java_heap_usage_monitor.sh文件的存放路径,以及邮件预警收件箱地址。文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html
Script端口具体代码如下:文章源自懂站帝-http://www.sfdkj.com/12316.html
1文章源自懂站帝-http://www.sfdkj.com/12316.html 2文章源自懂站帝-http://www.sfdkj.com/12316.html 3文章源自懂站帝-http://www.sfdkj.com/12316.html 4文章源自懂站帝-http://www.sfdkj.com/12316.html 5文章源自懂站帝-http://www.sfdkj.com/12316.html 6文章源自懂站帝-http://www.sfdkj.com/12316.html 7文章源自懂站帝-http://www.sfdkj.com/12316.html 8文章源自懂站帝-http://www.sfdkj.com/12316.html 9文章源自懂站帝-http://www.sfdkj.com/12316.html 10文章源自懂站帝-http://www.sfdkj.com/12316.html 11文章源自懂站帝-http://www.sfdkj.com/12316.html 12文章源自懂站帝-http://www.sfdkj.com/12316.html 13文章源自懂站帝-http://www.sfdkj.com/12316.html 14文章源自懂站帝-http://www.sfdkj.com/12316.html 15文章源自懂站帝-http://www.sfdkj.com/12316.html 16文章源自懂站帝-http://www.sfdkj.com/12316.html 17文章源自懂站帝-http://www.sfdkj.com/12316.html 18文章源自懂站帝-http://www.sfdkj.com/12316.html 19文章源自懂站帝-http://www.sfdkj.com/12316.html 20文章源自懂站帝-http://www.sfdkj.com/12316.html 21文章源自懂站帝-http://www.sfdkj.com/12316.html 22文章源自懂站帝-http://www.sfdkj.com/12316.html |
<!-- Execute Batch File -->文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="Directory" value="/home/arcesb_8056/data/" ></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="Name" value='/home/arcesb_8056/data/java_heap_usage_monitor.sh' ></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="Arguments" value='' ></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="o.Data"/>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:call op="sysExecute" out="out">文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:check value="[out.sys:error | def | trim]">文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:throw code="error" desc="Failed to execute [Name]: [out.sys:error]"/>文章源自懂站帝-http://www.sfdkj.com/12316.html </arc:check>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="heap.percentage" value="[out.sys:output | def | trim]"/>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:check value="[heap.percentage | isnumeric]">文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:if exp="[heap.percentage | greaterthan(80)]">文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="Subject" value="Low Java Heap"></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="Message" value="Java Heap used [heap.percentage]% of the space."></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:set attr="To" value="XXX@XXXXXX"></arc:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:call op="appSendEmail" ></arc:call>文章源自懂站帝-http://www.sfdkj.com/12316.html </arc:if>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:else>文章源自懂站帝-http://www.sfdkj.com/12316.html <arc:throw code="error" desc="Failed to parse the value [heap.percentage] as numeric!"/>文章源自懂站帝-http://www.sfdkj.com/12316.html </arc:else>文章源自懂站帝-http://www.sfdkj.com/12316.html </arc:check>文章源自懂站帝-http://www.sfdkj.com/12316.html </arc:call>文章源自懂站帝-http://www.sfdkj.com/12316.html |
6.设置Script端口自动化功能,设置定时接收,可以选择每天8点自动获取检测堆内存使用情况:文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html
7.配置完成后,知行之桥EDI系统每天8点检测堆内存使用情况,若是堆内存使用超过80%会收到如下主题提示的邮件,邮件正文包含当前进程堆内存使用率:文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html
二、磁盘空间使用率超过80%预警
磁盘空间不足也是影响EDI环境正常运行的一大原因,磁盘空间不足会导致数据无法正常处理,日志信息无法写入。同样为了避免这种情况出现,提前预警,可以参考以下方法进行配置:文章源自懂站帝-http://www.sfdkj.com/12316.html
1.在EDI系统页面新建Script端口,修改邮件预警收件箱地址信息。文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html
Script端口具体代码如下:文章源自懂站帝-http://www.sfdkj.com/12316.html
1文章源自懂站帝-http://www.sfdkj.com/12316.html 2文章源自懂站帝-http://www.sfdkj.com/12316.html 3文章源自懂站帝-http://www.sfdkj.com/12316.html 4文章源自懂站帝-http://www.sfdkj.com/12316.html 5文章源自懂站帝-http://www.sfdkj.com/12316.html 6文章源自懂站帝-http://www.sfdkj.com/12316.html 7文章源自懂站帝-http://www.sfdkj.com/12316.html 8文章源自懂站帝-http://www.sfdkj.com/12316.html 9文章源自懂站帝-http://www.sfdkj.com/12316.html 10文章源自懂站帝-http://www.sfdkj.com/12316.html 11文章源自懂站帝-http://www.sfdkj.com/12316.html 12文章源自懂站帝-http://www.sfdkj.com/12316.html 13文章源自懂站帝-http://www.sfdkj.com/12316.html 14文章源自懂站帝-http://www.sfdkj.com/12316.html 15文章源自懂站帝-http://www.sfdkj.com/12316.html 16文章源自懂站帝-http://www.sfdkj.com/12316.html |
<!-- Execute Batch File -->文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="Name" value="df" ></rsb:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="Arguments" value='"[_connector.sendfolder]"' ></rsb:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:call op="sysExecute" out="out">文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="disk.mount" value="[out.sys:output | split('\n', 2) | rsplit(' ', 1)]"/>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="disk.percentage" value="[out.sys:output | split('\n', 2) | rsplit(' ', 2) | replace('%', '')]"/>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:if exp="[disk.percentage | greaterthan(80)]">文章源自懂站帝-http://www.sfdkj.com/12316.html <!-- Send Email -->文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="Subject" value="Low Disk Space"></rsb:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="Message" value="Disk [disk.mount] used [disk.percentage]% of the space."></rsb:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:set attr="To" value="XXX@XXXXXX"></rsb:set>文章源自懂站帝-http://www.sfdkj.com/12316.html <rsb:call op="appSendEmail" ></rsb:call>文章源自懂站帝-http://www.sfdkj.com/12316.html </rsb:if>文章源自懂站帝-http://www.sfdkj.com/12316.html </rsb:call>文章源自懂站帝-http://www.sfdkj.com/12316.html |
2.设置Script端口自动化功能,设置定时接收,可以选择每天早上8点自动获取检测磁盘空间使用情况:文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html
3.配置完成后,EDI系统每天8点检测磁盘空间使用情况,若是磁盘空间使用率超过80%会收到如下主题提示的邮件,邮件正文包含当前磁盘空间使用率:文章源自懂站帝-http://www.sfdkj.com/12316.html

文章源自懂站帝-http://www.sfdkj.com/12316.html