summaryrefslogtreecommitdiff
path: root/linuxinstall
diff options
context:
space:
mode:
authorchenjinsong <[email protected]>2018-09-27 16:11:54 +0800
committerchenjinsong <[email protected]>2018-09-27 16:11:54 +0800
commit56d71f261a8bd6031e47e2bf80867049a2aa13da (patch)
treef09257b2143782a333a9eda3395137837d9bdad1 /linuxinstall
initial commit
Diffstat (limited to 'linuxinstall')
-rw-r--r--linuxinstall/autoinstall.sh170
-rw-r--r--linuxinstall/conf/jvm.conf2
-rw-r--r--linuxinstall/detectShell/config5
-rw-r--r--linuxinstall/detectShell/getMacInfo.v2.sh590
-rw-r--r--linuxinstall/detectShell/monitor_net.py362
-rw-r--r--linuxinstall/detectShell/remote_net.sh5
-rw-r--r--linuxinstall/detectShell/sysinfo29
-rw-r--r--linuxinstall/install.sh215
-rw-r--r--linuxinstall/readme.txt59
-rw-r--r--linuxinstall/shell/check_userpass.sh47
-rw-r--r--linuxinstall/shell/execCmdBySu.sh78
-rw-r--r--linuxinstall/shell/nmsagent.sh260
-rw-r--r--linuxinstall/shell/nmsclient_shouhu.sh55
-rw-r--r--linuxinstall/shell/restart.sh30
-rw-r--r--linuxinstall/shell/shutdown.sh30
-rw-r--r--linuxinstall/shell/startup.sh30
16 files changed, 1967 insertions, 0 deletions
diff --git a/linuxinstall/autoinstall.sh b/linuxinstall/autoinstall.sh
new file mode 100644
index 0000000..ce83980
--- /dev/null
+++ b/linuxinstall/autoinstall.sh
@@ -0,0 +1,170 @@
+#!/bin/bash
+
+# --- set default value
+DEFAULT_DATA_DIR="/home/nms/nmsdata"
+DEFAULT_INSTALL_DIR="/home/nms/nmsclient"
+
+# --- set install dir
+PRG="$0"
+PRGDIR=`dirname "$PRG"`
+CUR_PRGDIR=`cd "$PRGDIR"; pwd`
+
+INSTALL_DIR="$DEFAULT_INSTALL_DIR"
+
+if [ ! -d $INSTALL_DIR ]
+ then
+ mkdir -p $INSTALL_DIR
+fi
+
+INSTALL_DIR=`cd "$INSTALL_DIR"; pwd`
+
+# --- check jdk and jdk-version
+install_jdk=0
+javaversion=`java -version 2>&1|grep "java version"`
+if [ -n "$javaversion" ]
+ then
+ # javaversion=${javaversion:14:3}
+ javavmajor=`echo $javaversion | cut -c15`
+ javavminor=`echo $javaversion | cut -c17`
+# OS_TYPE=$( lsb_release -d| cut -d: -f2| cut -f2 )
+# if [ "`echo $OS_TYPE | cut -c1-6`" = "Ubuntu" ]
+# then
+# if [ 2 -gt $javavmajor ]; then
+# if [ 6 -gt $javavminor ]; then
+# install_jdk=1
+# fi
+# fi
+# else
+ if [[ 2 -gt $javavmajor && 6 -gt $javavminor ]]; then
+ install_jdk=1
+ fi
+# fi
+ else
+ install_jdk=1
+fi
+
+# --- install jdk
+cd "$INSTALL_DIR"/..
+NMS_JDK="$(pwd)/nmsjdk"
+JDK_DIR="$(pwd)/jdk1.7.0_80"
+JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-i586.tar.gz"
+if [ "`uname -i`" = "x86_64" ];then
+ JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-x64.tar.gz"
+fi
+if [ $install_jdk = 1 ]
+ then
+ if [ ! -e "$NMS_JDK" ]
+ then
+ echo "JDK bin file: $JDK_BIN_FILE"
+ echo "now, install jdk: $NMS_JDK"
+ sleep 3
+
+ if [ ! -e "$JDK_DIR" ];then
+ mkdir -p $JDK_DIR
+ fi
+ tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
+ if [ -n "$installJdk" ];then
+ echo "install jdk failure, exit program"
+ exit 1
+ fi
+ ln -s $JDK_DIR $NMS_JDK
+ echo "install jdk done"
+ fi
+elif [ -n "$JAVA_HOME" ];then
+ ln -s $JAVA_HOME $NMS_JDK
+else
+ echo "JDK bin file: $JDK_BIN_FILE"
+ echo "now, install jdk: $NMS_JDK"
+ sleep 3
+ if [ ! -e "$JDK_DIR" ];then
+ mkdir -p $JDK_DIR
+ fi
+ tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
+ if [ -n "$installJdk" ];then
+ echo "install jdk failure, exit program"
+ exit 1
+ fi
+ ln -s $JDK_DIR $NMS_JDK
+ echo "install jdk done"
+fi
+cd "$CUR_PRGDIR"
+
+echo "==========================================="
+echo "NMS_JDK: $NMS_JDK"
+echo "INSTALL_DIR: $INSTALL_DIR"
+echo "==========================================="
+
+# --- copy file to install_dir
+if [ "$INSTALL_DIR" != "$CUR_PRGDIR" ];then
+ CP_DIR=(
+ bin
+ lib
+ conf
+ shell
+ )
+ #cp
+ for CP_NAME in ${CP_DIR[@]}
+ do
+ cp -a $CUR_PRGDIR"/$CP_NAME" $INSTALL_DIR
+ done
+fi
+
+
+function modify_file(){
+ if [ $# != 2 ]
+ then
+ echo "usage: modify_file [prop_name] [prop_value]"
+ exit 0
+ fi
+ prop_name="$1"
+ prop_value="$2"
+ #echo "modify_file $prop_name $prop_value"
+ if [ -z "$(cat $PROP_FILE |grep $prop_name)" ]
+ then
+ echo "" >> $PROP_FILE
+ echo "$prop_name=$prop_value" >> $PROP_FILE
+ else
+ sed -i "s@^$prop_name.*@$prop_name=$prop_value@" $PROP_FILE
+ fi
+}
+
+# --- modify property
+#-------------file path
+path="$DEFAULT_DATA_DIR"
+#-------------include path
+include_path="$INSTALL_DIR,$path"
+#-------------exclude path
+exclude_path="$INSTALL_DIR/bin,$INSTALL_DIR/lib,$INSTALL_DIR/shell,$INSTALL_DIR/conf"
+#-------------log4j dir
+logs_path="$path/nc_logs"
+
+PROP_FILE=$INSTALL_DIR"/conf/myconfig.properties"
+#echo "PROP_FILE: $PROP_FILE"
+modify_file "local.data.path" $path
+modify_file "common.del.path.include" $include_path
+modify_file "common.del.path.exclude" $exclude_path
+
+# modify log4j
+PROP_FILE=$INSTALL_DIR"/conf/log4j.properties"
+encoding=${LANG#*.}
+modify_file "log4j.appender.stdout.encoding" $encoding
+modify_file "log4j.appender.debugAppender.encoding" $encoding
+modify_file "log4j.appender.infoAppender.encoding" $encoding
+modify_file "log4j.appender.debugAppender.File" "$logs_path/nmsclient_debug.log"
+modify_file "log4j.appender.infoAppender.File" "$logs_path/nmsclient_info.log"
+
+#permit
+cd $INSTALL_DIR"/shell"
+chmod 755 *.sh
+cd $CUR_PRGDIR
+
+if [ -z "$(cat /etc/rc.local|grep $INSTALL_DIR"/shell/startup.sh")" ]
+then
+ echo $INSTALL_DIR"/shell/startup.sh" >> /etc/rc.local
+fi
+
+echo ""
+echo "install successed..."
+echo "please use [$INSTALL_DIR/shell/startup.sh] to run the program..."
+
+$INSTALL_DIR/shell/startup.sh
diff --git a/linuxinstall/conf/jvm.conf b/linuxinstall/conf/jvm.conf
new file mode 100644
index 0000000..f4edf37
--- /dev/null
+++ b/linuxinstall/conf/jvm.conf
@@ -0,0 +1,2 @@
+-Xms64m
+-Xmx128m \ No newline at end of file
diff --git a/linuxinstall/detectShell/config b/linuxinstall/detectShell/config
new file mode 100644
index 0000000..5b2757e
--- /dev/null
+++ b/linuxinstall/detectShell/config
@@ -0,0 +1,5 @@
+configPath=/home/nms/nmsdata/nc_config
+sysinfoPath=/root/zhong/sysinfo
+ip1=192.168.11.211
+ip2=192.168.11.211
+ip3=192.168.11.211
diff --git a/linuxinstall/detectShell/getMacInfo.v2.sh b/linuxinstall/detectShell/getMacInfo.v2.sh
new file mode 100644
index 0000000..6b32b8e
--- /dev/null
+++ b/linuxinstall/detectShell/getMacInfo.v2.sh
@@ -0,0 +1,590 @@
+#!/bin/bash
+
+basePath=$(cd `dirname $0`; pwd)
+date=`date +%Y%m%d%H%M%S`
+d=`date "+%Y-%m-%d %H:%M:%S"` #temp column
+t=`date -d "$d" +%s` #temp column
+t2=`date "+%N" | awk '{print int($0)}'`
+dateStamp=$((t*1000+t2/1000000)) #current time stamp
+sep=\$@\$
+
+cd ${basePath}
+while read line;do # 读取config
+ eval "$line"
+done < config
+
+if [ ! -d macInfo ]
+ then
+ mkdir macInfo
+fi
+
+if [ ! -d result ]
+ then
+ mkdir result
+fi
+
+if [ ! -f firstTimeDate ]
+ then
+ touch firstTimeDate
+ echo ${dateStamp} > firstTimeDate
+ firstTimeDate=${dateStamp}
+ else
+ firstTimeDate=`cat firstTimeDate`
+fi
+
+# 读取任务配置文件
+OLD_IFS="$IFS"
+IFS=","
+
+cpu_pubInfo=`cat ${configPath}/cpu_cpu.cfg | grep pubInfo | awk -F'=' '{print $2}'`
+cpu_checkState=`cat ${configPath}/cpu_cpu.cfg | grep checkState | awk -F'=' '{print $2}'`
+cpu_checkGap=`cat ${configPath}/cpu_cpu.cfg | grep checkGap | awk -F'=' '{print $2}'`
+cpu_checkOutTime=`cat ${configPath}/cpu_cpu.cfg | grep checkOutTime | awk -F'=' '{print $2}'`
+cpu_checkMaxTimes=`cat ${configPath}/cpu_cpu.cfg | grep checkMaxTimes | awk -F'=' '{print $2}'`
+cpu_planCheckTime=`cat ${configPath}/cpu_cpu.cfg | grep planCheckTime | awk -F'=' '{print $2}'`
+cpu_uploadGap=`cat ${configPath}/cpu_cpu.cfg | grep uploadGap | awk -F'=' '{print $2}'`
+cpu_dataFileDir=`cat ${configPath}/cpu_cpu.cfg | grep dataFileDir | awk -F'=' '{print $2}'`
+cpu_polices=`cat ${configPath}/cpu_cpu.cfg | grep police | awk -F'=' '{print $2}'`
+cpu_polices_arr=($cpu_polices)
+cpu_police_flag=0
+cpu_nextDateStamp=$((cpu_checkGap*60*1000+dateStamp))
+mem_pubInfo=`cat ${configPath}/memory_memory.cfg | grep pubInfo | awk -F'=' '{print $2}'`
+mem_checkState=`cat ${configPath}/memory_memory.cfg | grep checkState | awk -F'=' '{print $2}'`
+mem_checkGap=`cat ${configPath}/memory_memory.cfg | grep checkGap | awk -F'=' '{print $2}'`
+mem_checkOutTime=`cat ${configPath}/memory_memory.cfg | grep checkOutTime | awk -F'=' '{print $2}'`
+mem_checkMaxTimes=`cat ${configPath}/memory_memory.cfg | grep checkMaxTimes | awk -F'=' '{print $2}'`
+mem_planCheckTime=`cat ${configPath}/memory_memory.cfg | grep planCheckTime | awk -F'=' '{print $2}'`
+mem_uploadGap=`cat ${configPath}/memory_memory.cfg | grep uploadGap | awk -F'=' '{print $2}'`
+mem_dataFileDir=`cat ${configPath}/memory_memory.cfg | grep dataFileDir | awk -F'=' '{print $2}'`
+mem_polices=`cat ${configPath}/memory_memory.cfg | grep police | awk -F'=' '{print $2}'`
+mem_polices_arr=($mem_polices)
+mem_police_flag=0
+mem_nextDateStamp=$((mem_checkGap*60*1000+dateStamp))
+disk_pubInfo=`cat ${configPath}/disk_disk.cfg | grep pubInfo | awk -F'=' '{print $2}'`
+disk_checkState=`cat ${configPath}/disk_disk.cfg | grep checkState | awk -F'=' '{print $2}'`
+disk_checkGap=`cat ${configPath}/disk_disk.cfg | grep checkGap | awk -F'=' '{print $2}'`
+disk_checkOutTime=`cat ${configPath}/disk_disk.cfg | grep checkOutTime | awk -F'=' '{print $2}'`
+disk_checkMaxTimes=`cat ${configPath}/disk_disk.cfg | grep checkMaxTimes | awk -F'=' '{print $2}'`
+disk_planCheckTime=`cat ${configPath}/disk_disk.cfg | grep planCheckTime | awk -F'=' '{print $2}'`
+disk_uploadGap=`cat ${configPath}/disk_disk.cfg | grep uploadGap | awk -F'=' '{print $2}'`
+disk_dataFileDir=`cat ${configPath}/disk_disk.cfg | grep dataFileDir | awk -F'=' '{print $2}'`
+disk_polices=`cat ${configPath}/disk_disk.cfg | grep police | awk -F'=' '{print $2}'`
+disk_polices_arr=($disk_polices)
+disk_police_flag=0
+disk_nextDateStamp=$((disk_checkGap*60*1000+dateStamp))
+net_pubInfo=`cat ${configPath}/net_net.cfg | grep pubInfo | awk -F'=' '{print $2}'`
+net_checkState=`cat ${configPath}/net_net.cfg | grep checkState | awk -F'=' '{print $2}'`
+net_checkGap=`cat ${configPath}/net_net.cfg | grep checkGap | awk -F'=' '{print $2}'`
+net_checkOutTime=`cat ${configPath}/net_net.cfg | grep checkOutTime | awk -F'=' '{print $2}'`
+net_checkMaxTimes=`cat ${configPath}/net_net.cfg | grep checkMaxTimes | awk -F'=' '{print $2}'`
+net_planCheckTime=`cat ${configPath}/net_net.cfg | grep planCheckTime | awk -F'=' '{print $2}'`
+net_uploadGap=`cat ${configPath}/net_net.cfg | grep uploadGap | awk -F'=' '{print $2}'`
+net_dataFileDir=`cat ${configPath}/net_net.cfg | grep dataFileDir | awk -F'=' '{print $2}'`
+net_polices=`cat ${configPath}/net_net.cfg | grep police | awk -F'=' '{print $2}'`
+net_polices_arr=($net_polices)
+net_police_flag=0
+net_nextDateStamp=$((net_checkGap*60*1000+dateStamp))
+sys_pubInfo=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep pubInfo | awk -F'=' '{print $2}'`
+sys_checkState=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep checkState | awk -F'=' '{print $2}'`
+sys_checkGap=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep checkGap | awk -F'=' '{print $2}'`
+sys_checkOutTime=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep checkOutTime | awk -F'=' '{print $2}'`
+sys_checkMaxTimes=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep checkMaxTimes | awk -F'=' '{print $2}'`
+sys_planCheckTime=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep planCheckTime | awk -F'=' '{print $2}'`
+sys_uploadGap=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep uploadGap | awk -F'=' '{print $2}'`
+sys_dataFileDir=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep dataFileDir | awk -F'=' '{print $2}'`
+sys_polices=`cat ${configPath}/systeminfo_servicessysinfo.cfg | grep police | awk -F'=' '{print $2}'`
+sys_polices_arr=($sys_polices)
+sys_police_flag=0
+sys_nextDateStamp=$((sys_checkGap*60*1000+dateStamp))
+
+IFS="$OLD_IFS"
+
+sysinfoSrc=`cat ${sysinfoPath}`
+
+## begin content weaving ##
+# task info
+cpuResult_taskInfo=${cpu_pubInfo}","${firstTimeDate}","${cpu_checkOutTime}","${dateStamp}",1,"${cpu_nextDateStamp}","
+memResult_taskInfo=${mem_pubInfo}","${firstTimeDate}","${mem_checkOutTime}","${dateStamp}",1,"${mem_nextDateStamp}","
+diskResult_taskInfo=${disk_pubInfo}","${firstTimeDate}","${disk_checkOutTime}","${dateStamp}",1,"${disk_nextDateStamp}","
+netResult_taskInfo=${net_pubInfo}","${firstTimeDate}","${net_checkOutTime}","${dateStamp}",1,"${net_nextDateStamp}","
+sysResult_taskInfo=${sys_pubInfo}","${firstTimeDate}","${sys_checkOutTime}","${dateStamp}",1,"${sys_nextDateStamp}",1,"
+
+cpuResult_coreNum=0
+disk_total_num=0
+net_total_num=0
+sys_net_total_num=0
+diskResult_baseInfo="\""
+memResult_baseInfo="\""
+netResult_baseInfo="\""
+sysResult_baseInfo="\""
+# result file
+
+cpuResult=result/cpuResult_${date}
+memResult=result/memResult_${date}
+diskResult=result/diskResult_${date}
+netResult=result/netResult_${date}
+sysResult=result/sysResult_${date}
+
+function getDetail {
+ cpuInfo=macInfo/$1_cpuInfo_${date}
+ memInfo=macInfo/$1_memInfo_${date}
+ diskInfo=macInfo/$1_diskInfo_${date}
+ netInfo=macInfo/$1_netInfo_${date}
+ sysInfo=macInfo/$1_sysInfo_${date}
+
+ ssh -tt $2 "sar -P ALL 1 1" > ${cpuInfo}
+ ssh -tt $2 "cat /proc/cpuinfo | grep MHz" > ${cpuInfo}2
+ ssh -tt $2 "free|awk 'NR>1{print}'" > ${memInfo}
+ ssh -tt $2 "df -l|grep -v tmpfs|awk 'NR>1{print}'" > ${diskInfo}
+
+ # 网卡信息
+ special_net_result_t=`ssh -C $2 "/bin/bash" < remote_net.sh` # 获取特殊网卡信息
+ special_net_result_base=${special_net_result_t%details,*}
+ special_net_result_details_t=${special_net_result_t#*details,}
+ special_net_result_details="\""${special_net_result_details_t#*\"}
+ special_net_result_details_t_arr=($special_net_result_details_t)
+ special_net_result_detailsNum=${special_net_result_details_t_arr[0]}
+ special_net_result=${special_net_result_base}"details,"${special_net_result_detailsNum}$'\n'
+ for((i=1;i<${#special_net_result_details_t_arr[@]};i++));do
+ special_net_result=${special_net_result}${special_net_result_details_t_arr[$i]}$'\n'
+ done
+ echo "$special_net_result" > ${netInfo}3
+ getNetInfo
+
+ dos2unix ${cpuInfo} > /dev/null 2>&1
+ dos2unix ${cpuInfo}2 > /dev/null 2>&1
+ dos2unix ${memInfo} > /dev/null 2>&1
+ dos2unix ${diskInfo} > /dev/null 2>&1
+ #dos2unix ${diskInfo} > /dev/null 2>&1
+
+ # cpu info
+ cpu_t=`awk -F "(" '{print $3}' ${cpuInfo}` # temp column
+
+ cpu_coreNum=`echo $cpu_t|awk -F " " '{print $1}'`
+ cpuResult_coreNum=$((cpuResult_coreNum+cpu_coreNum))
+ cpu_totalMHz=`awk '{total+=$4}END{print total}' ${cpuInfo}2`
+ cpu_averMHz=`echo "scale=2;$cpu_totalMHz/$cpu_coreNum"|bc|awk '{printf "%.2f",$0}'`
+ cpu_idle_total=`awk 'NR==4{print $9}' ${cpuInfo}`
+ cpu_shiyonglv=`bc <<<100-$cpu_idle_total|awk '{printf "%.2f",$0}'`
+
+ cpuResult_baseInfo=${cpuResult_baseInfo}${sep}"cpu${index} i18n_client.SystemInfo.mhz_n81i"${cpu_averMHz}"MHz,i18n_client.SystemInfo.shiyonglv_n81i "${cpu_shiyonglv}"%; "
+ getCpuBase2 ${cpuInfo} ${cpuInfo}2
+ getCpuDetail ${cpuInfo} ${cpuInfo}2
+
+ # mem info
+ swap_total_t=`cat ${memInfo}|grep '^S'|awk '{print $2}'`
+ swap_total=`echo "scale=2;${swap_total_t}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ swap_free_t=`cat ${memInfo}|grep '^S'|awk '{print $4}'`
+ swap_free=`echo "scale=2;${swap_free_t}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ mem_total_t=`awk 'NR==1{print $2}' ${memInfo}`
+ mem_total=`echo "scale=2;${mem_total_t}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ mem_used_t=`awk 'NR==1{print $3}' ${memInfo}`
+ mem_used=`echo "scale=2;${mem_used_t}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ mem_free=`echo "${mem_total}-${mem_used}"|bc|awk '{printf "%.2f",$0}'`
+ mem_shiyonglv=`echo "scale=2;${mem_used}/${mem_total}*100.00"|bc|awk '{printf "%.2f",$0}'`
+ memResult_baseInfo="${memResult_baseInfo}"${sep}"i18n_client.SystemInfo.memerySize_n81i: "${mem_total}"G, i18n_client.SystemInfo.currentUsed_n81i:"${mem_used}"G, i18n_client.SystemInfo.spaceRemain_n81i:"${mem_free}"G, i18n_client.SystemInfo.shiyonglv_n81i:"${mem_shiyonglv}"% "
+ mem_detail_nopolice=${swap_total}","${swap_free}","${mem_total}","${mem_used}","${mem_free}","${mem_shiyonglv}","$'\n'
+ OLD_IFS="$IFS"
+ IFS=","
+ mem_detail_nopolice_arr=(${mem_detail_nopolice})
+ IFS=$OLD_IFS
+ # police
+ if [ ! -z $mem_polices ]
+ then
+ mem_police_most_level=0
+ mem_police_flag_t=0 #临时变量
+ mem_baseInfo_police=""
+ for((j=0;j<${#mem_polices_arr[@]};j++));do
+ mem_detail_police_t=""
+ OLD_IFS="$IFS"
+ IFS="|"
+ mem_police_arr=(${mem_polices_arr[$j]})
+ IFS=$OLD_IFS
+
+ if (($(echo "${mem_detail_nopolice_arr[((${mem_police_arr[0]}-1))]} ${mem_police_arr[1]} ${mem_police_arr[2]}"|bc) == 1))
+ then #触发告警
+ mem_detail_police_t=${mem_police_arr[0]}","${mem_police_arr[3]}","${mem_police_arr[2]}","
+ mem_police_flag=1
+ mem_police_flag_t=1
+ if ((${mem_police_arr[3]} > ${mem_police_most_level}))
+ then
+ mem_police_most_level=${mem_police_arr[3]}
+ mem_detail_police=$mem_detail_police_t
+ mem_baseInfo_police="【${mem_detail_nopolice_arr[0]}】"${mem_police_arr[4]}${mem_detail_nopolice_arr[((${mem_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.abnormal_n81i</br>"
+ fi
+ elif [ $mem_police_flag_t -eq 0 ]&&[ -z "${mem_baseInfo_police}" ];then
+ mem_detail_police="\"\",,,"
+ mem_baseInfo_police="【${mem_detail_nopolice_arr[0]}】"${mem_police_arr[4]}${mem_detail_nopolice_arr[((${mem_police_arr[0]}-1))]}" i18n_client.GetInfoRun.normal_n81i</br>"
+ fi
+ done
+ memResult_baseInfo_police=${memResult_baseInfo_police}${mem_baseInfo_police}
+ else
+ mem_detail_police="\"\",,,"
+ fi
+ memResult_detail=${memResult_detail}${mem_detail_police}${mem_detail_nopolice}
+
+
+ #memResult_detail="${memResult_detail}""\"\",,,"${swap_total}","${swap_free}","${mem_total}","${mem_used}","${mem_free}","${mem_shiyonglv}","$'\n'
+
+ # disk info
+ disk_total_size=`awk '{total+=$2}END{print total}' ${diskInfo}` # Kb
+ disk_total_used_size=`awk '{total+=$3}END{print total}' ${diskInfo}`
+ disk_total_shiyonglv=`echo "scale=2;(${disk_total_used_size}*100)/${disk_total_size}"|bc|awk '{printf "%.2f",$0}'`
+ diskResult_baseInfo=${diskResult_baseInfo}${sep}"disk-"${index}"i18n_client.SystemInfo.diskSize_n81i:"`echo "scale=2;${disk_total_size}/1024/1024"|bc|awk '{printf "%.2f",$0}'`"G,i18n_client.SystemInfo.used2_n81i "${disk_total_shiyonglv}"% ;"
+ getDiskBase ${diskInfo}
+ getDiskDetail
+
+ # net info
+ #net_avai_if_arr=($(awk 'NR==1{print $0}' ${netInfo}))
+ #net_all_if_arr=($(awk 'NR>1{print}' ${netInfo} | awk -F ':' '{print $1 NR}'))
+ #getNetInfo
+}
+
+function getCpuBase2 {
+ arr1=($(awk '/^[0-2]/{print $9}' $1|awk 'NR>2{print $0}'))
+ arr2=($(awk '{print $4}' $2))
+
+ for((i=0;i<${#arr1[@]};i++));do
+ cpu_t2=`bc <<<100-${arr1[$i]} |awk '{printf "%.2f",$0}'`
+ cpuResult_baseInfo=${cpuResult_baseInfo}${sep}"cpu"${index}"-$i i18n_client.SystemInfo.mhz_n81i"${arr2[$i]}"MHz,i18n_client.SystemInfo.shiyonglv_n81i "${cpu_t2}"%; "
+ done
+}
+
+function getCpuDetail {
+ cpu_t3=`awk '/^[0-2]/{print $0}' $1|awk 'NR>1{print $0}'`
+
+ for((i=2;i<=`echo "${cpu_t3}"|awk 'END{print NR}'`;i++));do
+ cpu_row=`echo "${cpu_t3}"|awk 'NR=="'$i'"{print $0}'`
+ cpu_idle=`echo "${cpu_row}"|awk '{print $9}'`
+ cpu_shiyonglv_t=`bc <<<100-${cpu_idle} |awk '{printf "%.2f",$0}'`
+
+ cpu_detail_nopolice="cpu${index}-$((i-2)),"`echo "${cpu_row}"|awk '{print $4}'`","`echo "${cpu_row}"|awk '{print $6}'`","`echo "${cpu_row}"|awk '{print $7}'`","`echo "${cpu_row}"|awk '{print $5}'`","`echo "${cpu_row}"|awk '{print $9}'`","${cpu_shiyonglv_t}","`awk 'NR=="'$((i-1))'"{print $4}' $2`$'\n'
+
+ # police
+ if [ ! -z $cpu_polices ]
+ then
+ OLD_IFS="$IFS"
+ IFS=","
+ cpu_detail_nopolice_arr=(${cpu_detail_nopolice})
+ IFS=$OLD_IFS
+ cpu_police_most_level=0
+ cpu_police_flag_t=0 #临时变量
+ cpu_baseInfo_police=""
+ for((j=0;j<${#cpu_polices_arr[@]};j++));do
+ cpu_detail_police_t=""
+ OLD_IFS="$IFS"
+ IFS="|"
+ cpu_police_arr=(${cpu_polices_arr[$j]})
+ IFS=$OLD_IFS
+
+ if (($(echo "${cpu_detail_nopolice_arr[((${cpu_police_arr[0]}-1))]} ${cpu_police_arr[1]} ${cpu_police_arr[2]}"|bc) == 1))
+ then #触发告警
+ cpu_detail_police_t=${cpu_police_arr[0]}","${cpu_police_arr[3]}","${cpu_police_arr[2]}","
+ cpu_police_flag=1
+ cpu_police_flag_t=1
+ if ((${cpu_police_arr[3]} > ${cpu_police_most_level}))
+ then
+ cpu_police_most_level=${cpu_police_arr[3]}
+ cpu_detail_police=$cpu_detail_police_t
+ cpu_baseInfo_police="【cpu${index}-$((i-2))】"${cpu_police_arr[4]}${cpu_detail_nopolice_arr[((${cpu_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.abnormal_n81i</br>"
+ fi
+ elif [ $cpu_police_flag_t -eq 0 ]&&[ -z "${cpu_baseInfo_police}" ];then
+ cpu_detail_police="\"\",,,"
+ cpu_baseInfo_police="【cpu${index}-$((i-2))】"${cpu_police_arr[4]}${cpu_detail_nopolice_arr[((${cpu_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.normal_n81i</br>"
+ fi
+ done
+ cpuResult_baseInfo_police=${cpuResult_baseInfo_police}${cpu_baseInfo_police}
+ else
+ cpu_detail_police="\"\",,,"
+ fi
+ cpuResult_detail=${cpuResult_detail}${cpu_detail_police}${cpu_detail_nopolice}
+ done
+ cpuResult_detail=${cpuResult_detail}"\"\",,,cpu${index},"`awk 'NR==4{print $4}' $1`","`awk 'NR==4{print $6}' $1`","`awk 'NR==4{print $7}' $1`","`awk 'NR==4{print $5}' $1`","`awk 'NR==4{print $9}' $1`","${cpu_shiyonglv}","${cpu_averMHz}$'\n'
+}
+
+function getDiskBase {
+ disk_size_arr=($(awk '{print $2}' $1))
+ disk_used_arr=($(awk '{print $3}' $1))
+ disk_avai_arr=($(awk '{print $4}' $1)) # available
+ disk_usep_arr=($(awk '{print $5}' $1))
+ disk_moun_arr=($(awk '{print $6}' $1)) # mount on
+
+ for((i=0;i<${#disk_size_arr[@]};i++));do
+ disk_size=`echo "scale=2;${disk_size_arr[$i]}/1024/1024"|bc|awk '{printf "%.2f",$0}'` # Gb
+ disk_used=`echo "scale=2;${disk_used_arr[$i]}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ disk_avai=`echo "scale=2;${disk_avai_arr[$i]}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ disk_usep=${disk_usep_arr[$i]}
+ disk_moun=${disk_moun_arr[$i]}
+
+ diskResult_baseInfo=${diskResult_baseInfo}${sep}"【disk-$index:"${disk_moun}"】i18n_client.SystemInfo.size_n81i "${disk_size}"G, i18n_client.SystemInfo.used1_n81i "${disk_used}"G, i18n_client.SystemInfo.spaceRemain_n81i "${disk_avai}"G, i18n_client.SystemInfo.shiyonglv_n81i "${disk_usep}" ; "
+ done
+}
+
+function getDiskDetail {
+ disk_total_num=`echo "${disk_total_num}+${#disk_size_arr[@]}"|bc`
+ for((i=0;i<${#disk_size_arr[@]};i++));do
+ disk_size=`echo "scale=2;${disk_size_arr[$i]}/1024/1024"|bc|awk '{printf "%.2f",$0}'` # Gb
+ disk_avai=`echo "scale=2;${disk_avai_arr[$i]}/1024/1024"|bc|awk '{printf "%.2f",$0}'`
+ disk_detail_nopolice="disk-$index:"${disk_moun_arr[$i]}","${disk_size}","${disk_avai}","${disk_usep_arr[$i]%\%*}",0,"$'\n'
+ OLD_IFS=$IFS
+ IFS=","
+ disk_detail_nopolice_arr=(${disk_detail_nopolice})
+ IFS=$OLD_IFS
+
+ # police
+ if [ ! -z $disk_polices ]
+ then
+ disk_police_most_level=0
+ disk_police_flag_t=0 #临时变量
+ disk_baseInfo_police=""
+ for((j=0;j<${#disk_polices_arr[@]};j++));do
+ disk_detail_police_t=""
+ OLD_IFS="$IFS"
+ IFS="|"
+ disk_police_arr=(${disk_polices_arr[$j]})
+ IFS=$OLD_IFS
+
+ if (($(echo "${disk_detail_nopolice_arr[((${disk_police_arr[0]}-1))]} ${disk_police_arr[1]} ${disk_police_arr[2]}"|bc) == 1))
+ then #触发告警
+ disk_detail_police_t=${disk_police_arr[0]}","${disk_police_arr[3]}","${disk_police_arr[2]}","
+ disk_police_flag=1
+ disk_police_flag_t=1
+ if ((${disk_police_arr[3]} > ${disk_police_most_level}))
+ then
+ disk_police_most_level=${disk_police_arr[3]}
+ disk_detail_police=$disk_detail_police_t
+ disk_baseInfo_police="【${disk_detail_nopolice_arr[0]}】"${disk_police_arr[4]}${disk_detail_nopolice_arr[((${disk_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.abnormal_n81i</br>"
+ fi
+ elif [ $disk_police_flag_t -eq 0 ]&&[ -z "${disk_baseInfo_police}" ];then
+ disk_detail_police="\"\",,,"
+ disk_baseInfo_police="【${disk_detail_nopolice_arr[0]}】"${disk_police_arr[4]}${disk_detail_nopolice_arr[((${disk_police_arr[0]}-1))]}" i18n_client.GetInfoRun.normal_n81i</br>"
+ fi
+ done
+ diskResult_baseInfo_police=${diskResult_baseInfo_police}${disk_baseInfo_police}
+ else
+ disk_detail_police="\"\",,,"
+ fi
+ diskResult_detail=${diskResult_detail}${disk_detail_police}${disk_detail_nopolice}
+ done
+}
+
+function getNetInfo {
+ # 处理特殊网卡信息的内容
+ special_base_row=`awk 'NR==1{print $0}' ${netInfo}3` # 第一行
+ special_base_11=`echo ${special_base_row} | awk -F '"' '{print $2}'` # 11列
+ special_base_11=${sep}${special_base_11#*$sep}
+ special_base_12=`echo $special_base_row | awk -F '"' '{print $4}'` # 12列
+ special_base_12=${sep}${special_base_12#*$sep}
+ special_base_t=${special_base_11}${special_base_12}
+ special_base_t=${special_base_t//$sep/\!}
+ OLDIFS=$IFS
+ IFS="\!"
+ special_base_t_arr=(${special_base_t})
+ IFS=$OLD_IFS
+
+ special_base=""
+ for((i=1;i<${#special_base_t_arr[@]};i++));do
+ special_base=${special_base}"${sep}if${index}-"${special_base_t_arr[$i]}
+ done
+ special_detail_rows=`awk 'NR>2{print}' ${netInfo}3` # details行下方所有行
+ special_detail_rows_arr=($special_detail_rows) # details下方所有行的数组,每个元素为一行内容
+
+ #special_if_t=`echo ${special_detail_rows}|awk -F ',' '{print $4}'` # 取每行第三、四个逗号之间的网卡名
+ special_if_arr=() # 网卡名称数组
+
+ special_if_baseInfo="" # 初始化特殊网卡基础信息
+ for ((i=0;i<${#special_detail_rows_arr[@]};i++));do
+ special_detail_row=`echo ${special_detail_rows_arr[$i]} | awk -F ',' '{print gensub($4,"if"'$index'"-"$4,1)}'` # detail行网卡名替换为ifx-开头的名字
+ netResult_detail=${netResult_detail}${special_detail_row}$'\n'
+
+ special_if_baseInfo=${special_if_baseInfo}${special_base_12}${special_base_11}
+ special_if_arr[$i]=`echo ${special_detail_rows_arr[$i]}| awk -F ',' '{print $4}'`
+ done
+ sys_net_total_num=`echo "${sys_net_total_num}+${#net_all_if_arr[@]}"|bc`
+ net_total_num=`echo "${net_total_num}+${#net_avai_if_arr[@]}"|bc`
+ net_avai_baseInfo=""
+ net_disa_baseInfo=""
+
+ for((i=0;i<${#net_all_if_arr[@]};i++));do
+ ifName_t=${net_all_if_arr[$i]}
+ ifName=${ifName_t%?}
+ echo ${special_if_arr[0]}"--"${special_if_arr[1]}"--"${special_if_arr[2]}"--"${ifName}
+ if echo "${special_if_arr[@]}"|grep -w "${ifName}" &>/dev/null;then
+ let "net_total_num--"
+ let "sys_net_total_num--"
+ continue
+ fi
+
+ net_rowNum=$((${net_all_if_arr[$i]: -1}+1))
+ net_if_name_t=`awk 'NR=="'${net_rowNum}'"{print $1}' ${netInfo}`
+ net_if_name=${net_if_name_t%?}
+ is_avai=`echo "${net_avai_if_arr[@]}" | grep -wq "${net_all_if_arr[$i]%?}" && echo "1" || echo "0"`
+ if [ "1" -eq "$is_avai" ]
+ then
+ echo "#!/bin/bash"$'\n'"ethtool ${net_if_name}" > ethtool.sh
+ net_if_ethtoolResult=`ssh -C $value "/bin/bash" < ethtool.sh`
+ net_if_speed_t=`echo "${net_if_ethtoolResult}"|grep "Speed:"|awk '{print $2}'`
+ if [ ${#net_if_speed_t} -lt 1 ]
+ then
+ net_if_speed=0
+ else
+ net_if_speed=${net_if_speed_t:0:${#net_if_speed_t}-4}
+ fi
+ net_if_rxByte1=`awk 'NR=="'${net_rowNum}'"{print $2}' ${netInfo}`
+ net_if_rxByte2=`awk 'NR=="'${net_rowNum}'"{print $2}' ${netInfo}2`
+ net_if_rxBps=`echo "scale=2;($net_if_rxByte2-$net_if_rxByte1)*8/5"|bc|awk '{printf "%.2f",$0}'`
+ net_if_rxPackets1=`awk 'NR=="'${net_rowNum}'"{print $3}' ${netInfo}`
+ net_if_rxPackets2=`awk 'NR=="'${net_rowNum}'"{print $3}' ${netInfo}2`
+ net_if_rxPps_t=`echo "($net_if_rxPackets2-$net_if_rxPackets1)"|bc`
+ net_if_rxPps=`echo "scale=2;($net_if_rxPackets2-$net_if_rxPackets1)*8/5"|bc|awk '{printf "%.2f",$0}'`
+ net_if_txByte1=`awk 'NR=="'${net_rowNum}'"{print $10}' ${netInfo}`
+ net_if_txByte2=`awk 'NR=="'${net_rowNum}'"{print $10}' ${netInfo}`
+ net_if_txBps=`echo "scale=2;($net_if_txByte2-$net_if_txByte1)*8/5"|bc|awk '{printf "%.2f",$0}'`
+ net_if_txPackets1=`awk 'NR=="'${net_rowNum}'"{print $11}' ${netInfo}`
+ net_if_txPackets2=`awk 'NR=="'${net_rowNum}'"{print $11}' ${netInfo}2`
+ net_if_txPps_t=`echo "($net_if_rxPackets2-$net_if_rxPackets1)"|bc`
+ net_if_txPps=`echo "scale=2;($net_if_rxPackets2-$net_if_rxPackets1)*8/5"|bc|awk '{printf "%.2f",$0}'`
+ net_if_rxError1=`awk 'NR=="'${net_rowNum}'"{print $4}' ${netInfo}`
+ net_if_rxError2=`awk 'NR=="'${net_rowNum}'"{print $4}' ${netInfo}2`
+ net_if_txError1=`awk 'NR=="'${net_rowNum}'"{print $12}' ${netInfo}`
+ net_if_txError2=`awk 'NR=="'${net_rowNum}'"{print $12}' ${netInfo}2`
+ net_if_rxDrop1=`awk 'NR=="'${net_rowNum}'"{print $5}' ${netInfo}`
+ net_if_rxDrop2=`awk 'NR=="'${net_rowNum}'"{print $5}' ${netInfo}2`
+ net_if_txDrop1=`awk 'NR=="'${net_rowNum}'"{print $13}' ${netInfo}`
+ net_if_txDrop2=`awk 'NR=="'${net_rowNum}'"{print $13}' ${netInfo}2`
+
+ if [ $net_if_rxPps_t -gt 0 ]
+ then
+ net_if_rxErrorPerc=`echo "scale=2;($net_if_rxError2-$net_if_rxError1)*100/($net_if_rxPackets2-$net_if_rxPackets1)"|bc|awk '{printf "%.2f",$0}'`
+ net_if_rxDropPerc=`echo "scale=2;($net_if_rxDrop2-$net_if_rxDrop1)*100/($net_if_rxPackets2-$net_if_rxPackets1)"|bc|awk '{printf "%.2f",$0}'`
+ else
+ net_if_rxErrorPerc=0.00
+ net_if_rxDropPerc=0.00
+ fi
+ if [ $net_if_txPps_t -gt 0 ]
+ then
+ net_if_txErrorPerc=`echo "scale=2;($net_if_txError2-$net_if_txError1)*100/($net_if_txPackets2-$net_if_txPackets1)"|bc|awk '{printf "%.2f",$0}'`
+ net_if_txDropPerc=`echo "scale=2;($net_if_txDrop2-$net_if_txDrop1)*100/($net_if_txPackets2-$net_if_txPackets1)"|bc|awk '{printf "%.2f",$0}'`
+ else
+ net_if_txErrorPerc=0.00
+ net_if_txDropPerc=0.00
+ fi
+ net_avai_baseInfo=${net_avai_baseInfo}${sep}"if"${index}"-"${net_if_name}" i18n_client.SystemInfo.netSpeed_n81i"${net_if_speed}"Mbps, i18n_client.SystemInfo.input_n81i"${net_if_rxBps}"bps、"${net_if_rxPps}"pps, Output"${net_if_txBps}"bps、"${net_if_txPps}"pps; "
+ net_detail_nopolice="if${index}-"${net_if_name}","${net_if_rxPackets2}","${net_if_txPackets2}","${net_if_rxByte2}","${net_if_txByte2}","${net_if_rxError2}","${net_if_txError2}","${net_if_rxDrop2}","${net_if_txDrop2}","${net_if_speed}","${net_if_rxBps}","${net_if_txBps}","${net_if_rxPps}","${net_if_txPps}","${net_if_rxErrorPerc}","${net_if_txErrorPerc}","${net_if_rxDropPerc}","${net_if_txDropPerc}$'\n'
+ #netResult_detail=${netResult_detail}"\"\",,,if${index}-"${net_if_name}","${net_if_rxPackets2}","${net_if_txPackets2}","${net_if_rxByte2}","${net_if_txByte2}","${net_if_rxError2}","${net_if_txError2}","${net_if_rxDrop2}","${net_if_txDrop2}","${net_if_speed}","${net_if_rxBps}","${net_if_txBps}","${net_if_rxPps}","${net_if_txPps}","${net_if_rxErrorPerc}","${net_if_txErrorPerc}","${net_if_rxDropPerc}","${net_if_txDropPerc}$'\n'
+ # police
+ if [ ! -z $net_polices ]
+ then
+ OLD_IFS="$IFS"
+ IFS=","
+ net_detail_nopolice_arr=(${net_detail_nopolice})
+ IFS=$OLD_IFS
+ net_police_most_level=0
+ net_police_flag_t=0 #临时变量
+ net_baseInfo_police=""
+ for((j=0;j<${#net_polices_arr[@]};j++));do
+ net_detail_police_t=""
+ OLD_IFS="$IFS"
+ IFS="|"
+ net_police_arr=(${net_polices_arr[$j]})
+ IFS=$OLD_IFS
+
+ if (($(echo "${net_detail_nopolice_arr[((${net_police_arr[0]}-1))]} ${net_police_arr[1]} ${net_police_arr[2]}"|bc) == 1))
+ then #触发告警
+ net_detail_police_t=${net_police_arr[0]}","${net_police_arr[3]}","${net_police_arr[2]}","
+ net_police_flag=1
+ net_police_flag_t=1
+ if ((${net_police_arr[3]} > ${net_police_most_level}))
+ then
+ net_police_most_level=${net_police_arr[3]}
+ net_detail_police=$net_detail_police_t
+ net_baseInfo_police="【${net_detail_nopolice_arr[0]}】"${net_police_arr[4]}${net_detail_nopolice_arr[((${net_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.abnormal_n81i</br>"
+ fi
+ elif [ $net_police_flag_t -eq 0 ]&&[ -z "${net_baseInfo_police}" ];then
+ net_detail_police="\"\",,,"
+ net_baseInfo_police="【${net_detail_nopolice_arr[0]}】"${net_police_arr[4]}${net_detail_nopolice_arr[((${net_police_arr[0]}-1))]}"% i18n_client.GetInfoRun.normal_n81i</br>"
+ fi
+ done
+ netResult_baseInfo_police=${netResult_baseInfo_police}${net_baseInfo_police}
+ else
+ net_detail_police="\"\",,,"
+ fi
+ netResult_detail=${netResult_detail}${net_detail_police}${net_detail_nopolice}
+ else
+ net_disa_baseInfo=${net_disa_baseInfo}${sep}"if"${index}"-"${net_if_name}"i18n_client.SystemInfo.disable_n81i; "
+ fi
+ done
+
+ sys_net_total_num=`echo "${sys_net_total_num}+${#special_detail_rows_arr[@]}"|bc`
+ net_total_num=`echo "$net_total_num+${#special_detail_rows_arr[@]}"|bc`
+ netResult_baseInfo=${netResult_baseInfo}"${sep}if"${index}"-"${#special_detail_rows_arr[@]}"i18n_client.SystemInfo.insert_n81i: "${special_base}${net_avai_baseInfo}${net_disa_baseInfo}$'\n'
+}
+
+# main
+index=1
+flag=1
+while [ $flag -eq 1 ]; do
+ key='ip'${index}
+ value=`eval echo '$'${key}`
+
+ if [ -z ${value} ]
+ then
+ flag=0
+ else
+ getDetail ${key} ${value}
+ let "index++"
+ fi
+done
+
+## result
+# cpu
+cpuResult_baseInfo=${cpuResult_baseInfo}"\""
+if ((${cpu_police_flag} == 0 ))
+ then
+ cpuResult_baseInfo_police="\""${cpuResult_baseInfo}
+ cpu_police_flag=1
+ else
+ cpuResult_baseInfo_police="\""${cpuResult_baseInfo_police}"\""
+ cpu_police_flag=0
+fi
+echo "${cpuResult_taskInfo}""${cpu_police_flag},""\"${cpuResult_coreNum}""i18n_client.SystemInfo.core_n81i: ""${cpuResult_baseInfo}"",""${cpuResult_baseInfo_police}"$'\n'"details,""$((cpuResult_coreNum+index-1))"$'\n'"${cpuResult_detail}" > ${cpu_dataFileDir}/${date}".csv" #${cpuResult}
+
+# mem
+memResult_baseInfo=${memResult_baseInfo}"\""
+if ((${mem_police_flag} == 0 ))
+ then
+ memResult_baseInfo_police=${memResult_baseInfo}
+ mem_police_flag=1
+ else
+ memResult_baseInfo_police="\""${memResult_baseInfo_police}"\""
+ mem_police_flag=0
+fi
+echo "${memResult_taskInfo}"${mem_police_flag}",${memResult_baseInfo}"",""${memResult_baseInfo_police}"$'\n'"details,""$((index-1))"$'\n'"${memResult_detail}" > ${mem_dataFileDir}/${date}".csv" #${memResult}
+
+# disk
+diskResult_baseInfo=${diskResult_baseInfo}"\""
+if ((${disk_police_flag} == 0 ))
+ then
+ diskResult_baseInfo_police=${diskResult_baseInfo}
+ disk_police_flag=1
+ else
+ diskResult_baseInfo_police="\""${diskResult_baseInfo_police}"\""
+ disk_police_flag=0
+fi
+echo "${diskResult_taskInfo}"${disk_police_flag}",${diskResult_baseInfo}"",""${diskResult_baseInfo_police}"$'\n'"details,$disk_total_num"$'\n'"${diskResult_detail}" > ${disk_dataFileDir}/${date}".csv" #${diskResult}
+
+# net
+netResult_baseInfo=${netResult_baseInfo}"\""
+if ((${net_police_flag} == 0 ))
+ then
+ netResult_baseInfo_police=${netResult_baseInfo}
+ net_police_flag=1
+ else
+ netResult_baseInfo_police="\""${netResult_baseInfo_police}"\""
+ net_police_flag=0
+fi
+echo "${netResult_taskInfo}"${net_police_flag}",${netResult_baseInfo}"",""${netResult_baseInfo_police}"$'\n'"details,$net_total_num"$'\n'"${netResult_detail}" > ${net_dataFileDir}/${date}".csv" #${netResult}
+
+# sys
+sysinfo=`cat ${sysinfoPath}`
+echo "${sysResult_taskInfo}""${sysinfo}" > ${sys_dataFileDir}/${date}".csv" #${sysResult}
diff --git a/linuxinstall/detectShell/monitor_net.py b/linuxinstall/detectShell/monitor_net.py
new file mode 100644
index 0000000..9e0b8bc
--- /dev/null
+++ b/linuxinstall/detectShell/monitor_net.py
@@ -0,0 +1,362 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+# created by zhongyoub
+'''
+get all net card info and write to file with csv format
+time: ms
+'''
+
+import time,re,os,csv
+import ConfigParser
+import StringIO
+from datetime import datetime
+
+global cfg_path_str
+global nic_path_str
+global marsio_cmd
+cfg_path_str="/home/nms/nc_config/net_net/net_net.cfg"
+nic_path_str="/proc/net/dev"
+marsio_cmd="monit_device"
+
+def round2(a):
+ return ("%.2f"%a)
+
+class monitor_net():
+ def __init__(self):
+ self.seqId="" # seqId
+ self.id="" # 监测设置ID
+ self.cattory="" # 监测类别
+ self.process="" # 进程名称
+
+ self.start_time=int(round(time.time()*1000)) # 监测服务启动时间
+ self.delay=0 # 检测时延
+ self.checktime=int(round(time.time()*1000)) # 本次检测时间
+ self.try_times=1 # 尝试次数
+ self.next_time=0 # 下次监测时间 self.start_time + self.interval
+ self.checkState=1 # 检测状态
+
+ self.checkGap=0
+ self.config_path=cfg_path_str
+ self.nic_path=nic_path_str
+
+ '''
+ nic info
+ '''
+ self.nic_info={"eth_name":"", "rx_packets":0, "tx_packets":0, "rx_bytes":0, "tx_bytes":0,
+ "rx_errs":0, "tx_errs":0, "rx_drop":0, "tx_drops":0, "speed":10000,
+ "rx_bps":0, "tx_bps":0, "rx_pps":0, "tx_pps":0,
+ "rx_err_perc":0, "tx_err_perc":0, "rx_drop_perc":0, "tx_drop_perc":0 }
+ self.marsio_info={"eth_name":"", "rx_packets":0, "tx_packets":0, "rx_bytes":0, "tx_bytes":0,
+ "rx_errs":0, "tx_errs":0, "rx_drop":0, "tx_drops":0, "speed":10000,
+ "rx_bps":0, "tx_bps":0, "rx_pps":0, "tx_pps":0,
+ "rx_err_perc":0, "tx_err_perc":0, "rx_drop_perc":0, "tx_drop_perc":0 }
+ # self.vf_dict={'0':'','1':'','2':''}
+ self.vf_list=[]
+ self.marsio_list=[]
+
+
+ '''
+ read config file
+ '''
+ def read_config(self):
+ '''
+ with open(self.config_path, 'r') as f:
+ section_string = '[dummy_section]\n' + f.read()
+ '''
+
+ config=StringIO.StringIO()
+ config.write('[dummy_section]\n')
+ config.write(open(self.config_path).read())
+ config.seek(0,os.SEEK_SET)
+
+ cfg = ConfigParser.ConfigParser()
+ # cfg.readfp(section_string)
+ cfg.readfp(config)
+ pubInfo=cfg.get("dummy_section", "pubInfo")
+ self.seqId=pubInfo.split(",",3)[0]
+ self.id=pubInfo.split(",",3)[1]
+ self.cattory=pubInfo.split(",",3)[2]
+ self.process=pubInfo.split(",",3)[3]
+
+ self.delay=cfg.get("dummy_section","checkOutTime")
+ self.try_times=cfg.get("dummy_section","checkMaxTimes")
+ self.checkGap=int(cfg.get("dummy_section","checkGap"))*60*1000 # ms
+ self.next_time=self.start_time+self.checkGap
+ self.checkState=cfg.get("dummy_section","checkState")
+
+
+ '''
+ get net card info/home/nms/nc_config/net_net
+ '''
+ def get_vfnet_info(self):
+ net_info=open("/proc/net/dev","r")
+ info=net_info.readlines()
+ net_info.close()
+# print self.marsio_list
+ for line in info: # find nic name like ens*f*
+ self.nic_info={"eth_name":"", "rx_packets":0, "tx_packets":0, "rx_bytes":0, "tx_bytes":0,
+ "rx_errs":0, "tx_errs":0, "rx_drop":0, "tx_drops":0, "speed":10000,
+ "rx_bps":0, "tx_bps":0, "rx_pps":0, "tx_pps":0,
+ "rx_err_perc":0, "tx_err_perc":0, "rx_drop_perc":0, "tx_drop_perc":0 }
+ if re.search(r'ens.f.',line):
+ field=line.split()
+ self.nic_info["eth_name"]=field[0].split(":")[0]
+ self.nic_info["rx_bytes"]=field[1]
+ self.nic_info["rx_packets"]=field[2]
+ self.nic_info["rx_errs"]=field[3]
+ self.nic_info["rx_drop"]=field[4]
+ self.nic_info["tx_bytes"]=field[9]
+ self.nic_info["tx_packets"]=field[10]
+ self.nic_info["tx_errs"]=field[11]
+ self.nic_info["tx_drop"]=field[12]
+ # self.vf_dict[str(i)]=self.nic_info
+ # print "nic_info"
+ # print self.nic_info
+ self.vf_list.append(self.nic_info)
+ # print self.vf_list
+# print self.vf_list[str(i)]
+
+ '''
+ eth_name=field[0].split(":")[0]
+ rx_bytes=field[1]
+ rx_packets=field[2]
+ rx_errs=field[3]
+ rx_drop=field[4]
+ tx_bytes=field[9]
+ tx_packts=field[10]
+ tx_errs=field[11]
+ tx_drop=field[12]
+ return(eth_name, int(rx_bytes),int(rx_packets),int(rx_errs),int(rx_drop),int(tx_bytes),
+ int(tx_packts),int(tx_errs),int(tx_drop))
+ '''
+
+ '''
+ get marsio net card info by open(monit_device)
+ '''
+ def get_marsionet_info(self):
+ info=os.popen(marsio_cmd)
+ for line in info:
+ if re.search(r'ens.f*',line):
+ self.marsio_info["eth_name"]=line.split(",")[1].split(":")[1].strip()
+ if re.search(r'Accu',line):
+ self.marsio_info["rx_packets"]=line.split()[1]
+ self.marsio_info["rx_bytes"]=int(line.split()[2])/8 # bit to byte(float)
+ self.marsio_info["rx_drop"]=line.split()[9]
+ self.marsio_info["rx_errs"]=line.split()[4]
+ self.marsio_info["tx_packets"]=line.split()[6]
+ self.marsio_info["tx_bytes"]=int(line.split()[7])/8
+ self.marsio_info["tx_errs"]=line.split()[8]
+ self.marsio_info['tx_drop']=line.split()[10]
+
+ if re.search(r'Second',line):
+ self.marsio_info["rx_bps"]=line.split()[3]
+ rx_packets=self.marsio_info["rx_pps"]=line.split()[2]
+ tx_packets=self.marsio_info["tx_pps"]=line.split()[7]
+ self.marsio_info["tx_bps"]=line.split()[8]
+
+ rx_err_per=line.split()[5]
+ tx_err_per=line.split()[9]
+ if int(rx_packets)!=0:
+ self.marsio_info["rx_err_perc"]=round2(float(rx_err_per)/int(rx_packets))
+ else:
+ self.marsio_info["rx_err_perc"]=round2(0)
+# print self.marsio_info["rx_err_perc"]
+ if int(tx_packets)!=0:
+ self.marsio_info["tx_err_perc"]=round2(float(tx_err_per)/int(tx_packets))
+ else:
+ self.marsio_info["tx_err_perc"]=round2(0)
+ # print self.marsio_info["tx_err_perc"]
+ rx_drop_per=line.split()[10]
+ tx_drop_per=line.split()[11]
+ if int(rx_packets)!=0:
+ self.marsio_info["rx_drop_perc"]=round2(float(rx_drop_per)/int(rx_packets))
+ else:
+ self.marsio_info["rx_drop_perc"]=round2(0)
+# print self.marsio_info["rx_drop_perc"]
+ if int(tx_packets)!=0:
+ self.marsio_info["tx_drop_perc"]=round2(float(tx_drop_per)/int(tx_packets))
+ else:
+ self.marsio_info["tx_drop_perc"]=round2(0)
+# print self.marsio_info["tx_drop_perc"]
+ self.marsio_list.append(self.marsio_info)
+# print "marsio_info"
+# print self.marsio_info
+
+def list_append(list1, dict1):
+ list1.append(dict1["eth_name"])
+ list1.append(dict1["rx_packets"])
+ list1.append(dict1["tx_packets"])
+ list1.append(dict1["rx_bytes"])
+ list1.append(dict1["tx_bytes"])
+ list1.append(dict1["rx_errs"])
+ list1.append(dict1["tx_errs"])
+ list1.append(dict1["rx_drop"])
+ list1.append(dict1["tx_drop"])
+ list1.append(dict1["speed"])
+ list1.append(dict1["rx_bps"])
+ list1.append(dict1["tx_bps"])
+ list1.append(dict1["rx_pps"])
+ list1.append(dict1["tx_pps"])
+ list1.append(dict1["rx_err_perc"])
+ list1.append(dict1["tx_err_perc"])
+ list1.append(dict1["rx_drop_perc"])
+ list1.append(dict1["tx_drop_perc"])
+
+def main():
+ monitor=monitor_net()
+ monitor.read_config()
+ monitor.chectime=int(round(time.time()*1000))
+ monitor.get_marsionet_info()
+ list3=monitor.marsio_list
+ monitor.get_vfnet_info()
+ list1=monitor.vf_list
+# print "list1"
+# print list1
+ monitor.vf_list=[]
+# print monitor.vf_list
+ # monitor.vf_list.clear()
+ time.sleep(1)
+ monitor.get_vfnet_info()
+ list2=monitor.vf_list
+# print "list2"
+# print list2
+ for x, y in zip(list1,list2):
+ rx_bytes_pers=int(y["rx_bytes"])-int(x["rx_bytes"])
+ tx_bytes_pers=int(y["tx_bytes"])-int(x["tx_bytes"])
+ rx_packet_pers=float(y["rx_packets"])-int(x["rx_packets"])
+ tx_packet_pers=float(y["tx_packets"])-int(x["tx_packets"])
+
+ rx_bps=rx_bytes_pers*8
+ rx_pps=rx_packet_pers
+ tx_bps=tx_bytes_pers*8
+ tx_pps=tx_packet_pers
+ if rx_packet_pers >0:
+ rx_err_rate=(int(y["rx_errs"])-int(x["rx_errs"]))/rx_packet_pers
+ else:
+ rx_err_rate=0
+ if tx_packet_pers>0:
+ tx_err_rate=(int(y["tx_errs"])-int(x["tx_errs"]))/tx_packet_pers
+ else:
+ tx_err_rate=0
+ if rx_packet_pers>0:
+ rx_drop_rate=(int(y["rx_drop"])-int(x["rx_drop"]))/rx_packet_pers
+ else:
+ rx_drop_rate=0
+ if tx_packet_pers>0:
+ tx_drop_rate=(int(y["tx_drop"])-int(x["tx_drop"]))/tx_packet_pers
+ else:
+ tx_drop_rate=0
+ '''
+ y["rx_bps"]=round2(rx_bps)
+ y["rx_pps"]=round2(rx_pps)
+ y["tx_bps"]=round2(tx_bps)
+ y["tx_pps"]=round2(tx_pps)
+ '''
+ y["rx_err_perc"]=round2(rx_err_rate)
+ y["tx_err_perc"]=round2(tx_err_rate)
+ y["rx_drop_perc"]=round2(rx_drop_rate)
+ y["tx_drop_perc"]=round2(tx_drop_rate)
+
+# print list2
+# print list3
+ vf_num=len(monitor.vf_list)
+ # print monitor.vf_list
+ # print vf_num
+ marsio_num=len(list3)
+
+ csv_file=datetime.now().strftime("%Y%m%d%H%M%S")
+
+ header=[monitor.seqId,monitor.id,monitor.cattory,monitor.process,monitor.start_time,monitor.delay,
+ monitor.chectime,monitor.try_times,monitor.next_time,monitor.checkState]
+
+ first_str=str(vf_num)+"i18n_client.SystemInfo.insert_n81i: "
+ for each in list2:
+ first_str=first_str+"$@$"+each["eth_name"]+ \
+ " i18n_client.SystemInfo.netSpeed_n81i10000Mbps,"+"i18n_client.SystemInfo.input_n81i"+ \
+ str(each["rx_bps"])+"bps、"+str(each["rx_pps"])+"pps,"+"Output"+str(each["tx_bps"])+"bps、"+str(each["tx_pps"])+ \
+ "pps;"
+
+ second_str=str(marsio_num)+"i18n_client.SystemInfo.insert_n81i: "
+ for each in list3:
+ second_str=second_str+"$@$"+each["eth_name"]+ \
+ " i18n_client.SystemInfo.netSpeed_n81i10000Mbps,"+"i18n_client.SystemInfo.input_n81i"+ \
+ str(each["rx_bps"])+"bps、 "+str(each["rx_pps"])+"pps,"+"Output"+str(each["tx_bps"])+"bps、"+str(each["tx_pps"])+ \
+ "pps;"
+
+ four_1=['\"','','']
+ four_2=['\"','','']
+ four_3=['\"','','']
+ if len(list2)>1:
+ first_dict=list2[0]
+ second_dict=list2[1]
+ list_append(four_1,first_dict)
+ list_append(four_2,second_dict)
+ elif len(list2)==1:
+ first_dict=list2[0]
+ list_append(four_1,first_dict)
+ four_2=[]
+ else:
+ four_1=[]
+ four_2=[]
+ if len(list3)>0:
+ three_dict=list3[0]
+ '''
+ three_dict["rx_bps"]=round2(int(three_dict["rx_bps"]))
+ three_dict["rx_pps"]=round2(int(three_dict["rx_pps"]))
+ three_dict["tx_bps"]=round2(int(three_dict["tx_bps"]))
+ three_dict["tx_bps"]=round2(int(three_dict["tx_bps"]))
+ three_dict["rx_err_perc"]=round2(int(three_dict["rx_err_perc"]))
+ three_dict["tx_err_perc"]=round2(int(three_dict["tx_err_perc"]))
+ three_dict["rx_drop_perc"]=round2(int(three_dict["rx_drop_perc"]))
+ three_dict["tx_drop_perc"]=round2(int(three_dict["tx_drop_perc"]))
+ '''
+ list_append(four_3,three_dict)
+ else:
+ four_3=[]
+ '''
+ four_1.append(first_list["eth_name"])
+ four_1.append(first_list["rx_packets"])
+ four_1.append(first_list["tx_packets"])
+ four_1.append(first_list["rx_bytes"])
+ four_1.append(first_list["tx_bytes"])
+ four_1.append(first_list["rx_errs"])
+ four_1.append(first_list["tx_errs"])
+ four_1.append(first_list["rx_drop"])
+ four_1.append(first_list["tx_drop"])
+ four_1.append(first_list["speed"])
+ four_1.append(first_list["rx_bps"])
+ four_1.append(first_list["tx_bps"])
+ four_1.append(first_list["rx_pps"])
+ four_1.append(first_list["tx_pps"])
+ four_1.append(first_list["rx_err_perc"])
+ four_1.append(first_list["tx_err_perc"])
+ four_1.append(first_list["rx_drop_perc"])
+ '''
+# print four_1
+# print four_2
+# print four_3
+ header.append(first_str)
+ header.append(second_str)
+ two_list=["details"]
+ two_list.append((vf_num+marsio_num))
+
+ with open(csv_file+".csv","w") as f:
+ f_writer=csv.writer(f,lineterminator='\n')
+ f_writer.writerow(header)
+ f_writer.writerow(two_list)
+ if len(four_1):
+ f_writer.writerow(four_1)
+ if len(four_2):
+ f_writer.writerow(four_2)
+ if len(four_3):
+ f_writer.writerow(four_3)
+ f.close()
+
+if __name__ == '__main__':
+ main()
+ exit(0)
+
+
+
+
diff --git a/linuxinstall/detectShell/remote_net.sh b/linuxinstall/detectShell/remote_net.sh
new file mode 100644
index 0000000..0476b01
--- /dev/null
+++ b/linuxinstall/detectShell/remote_net.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+python /root/zhong/monitor_net.py #py脚本的路径,需要手动填写
+cat `ls|grep csv`
+rm -f *.csv
diff --git a/linuxinstall/detectShell/sysinfo b/linuxinstall/detectShell/sysinfo
new file mode 100644
index 0000000..47eeb21
--- /dev/null
+++ b/linuxinstall/detectShell/sysinfo
@@ -0,0 +1,29 @@
+"$@$1-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1466.65MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i$@$2-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1498.72MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i$@$3-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1567.90MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i","$@$1-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1466.65MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i$@$2-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1498.72MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i$@$3-localhost.localdomain): 3.10.0-693.el7.x86_64, 8i18n_client.SystemInfo.message.core_n81i CPU, 1567.90MHz, 15.44i18n_client.SystemInfo.message.memery_n81i, 1885477224i18n_client.SystemInfo.message.disk_n81i, 4i18n_client.SystemInfo.message.netcard_n81i"
+details,3
+"",,,1-localhost.localdomain),"3.10.0-693.el7.x86_64",8,1466.65,15.44,63.99,1885477224,4,
+"",,,2-localhost.localdomain),"3.10.0-693.el7.x86_64",8,1498.72,15.44,63.99,1885477224,4,
+"",,,3-localhost.localdomain),"3.10.0-693.el7.x86_64",8,1567.90,15.44,63.99,1885477224,4,
+disk,9
+1:/,1884767064,
+1:/boot,505580,
+1:/boot/efi,204580,
+2:/,1884767064,
+2:/boot,505580,
+2:/boot/efi,204580,
+3:/,1884767064,
+3:/boot,505580,
+3:/boot/efi,204580,
+net,12
+1-enp0s31f6,Available,100,10.0.6.247,255.255.255.0,10.0.6.100,30:9c:23:4d:9c:93,
+1-wlp3s0,Unavailable,0,0.0.0.0,0.0.0.0,0,0,0,0,f8:28:19:d4:13:db,
+1-virbr0-nic,Unavailable,10,0.0.0.0,0.0.0.0,0,0,0,0,52:54:00:37:52:32,
+1-virbr0,Available,0,192.168.122.1,255.255.255.0,10.0.6.100,52:54:00:37:52:32,
+2-enp0s31f6,Available,100,10.0.6.247,255.255.255.0,10.0.6.100,30:9c:23:4d:9c:93,
+2-wlp3s0,Unavailable,0,0.0.0.0,0.0.0.0,0,0,0,0,f8:28:19:d4:13:db,
+2-virbr0-nic,Unavailable,10,0.0.0.0,0.0.0.0,0,0,0,0,52:54:00:37:52:32,
+2-virbr0,Available,0,192.168.122.1,255.255.255.0,10.0.6.100,52:54:00:37:52:32,
+3-enp0s31f6,Available,100,10.0.6.247,255.255.255.0,10.0.6.100,30:9c:23:4d:9c:93,
+3-wlp3s0,Unavailable,0,0.0.0.0,0.0.0.0,0,0,0,0,f8:28:19:d4:13:db,
+3-virbr0-nic,Unavailable,10,0.0.0.0,0.0.0.0,0,0,0,0,52:54:00:37:52:32,
+3-virbr0,Available,0,192.168.122.1,255.255.255.0,10.0.6.100,52:54:00:37:52:32,
+
diff --git a/linuxinstall/install.sh b/linuxinstall/install.sh
new file mode 100644
index 0000000..8164514
--- /dev/null
+++ b/linuxinstall/install.sh
@@ -0,0 +1,215 @@
+#!/bin/bash
+
+# --- set default value
+DEFAULT_DATA_DIR="/home/nms/nmsdata"
+DEFAULT_INSTALL_DIR="/home/nms/nmsclient"
+
+# --- set install dir
+PRG="$0"
+PRGDIR=`dirname "$PRG"`
+CUR_PRGDIR=`cd "$PRGDIR"; pwd`
+
+if [ $# = 0 ]
+ then
+ echo -n "enter intall dir [default: $DEFAULT_INSTALL_DIR]:"
+ read INSTALL_DIR
+ if [ -z "$INSTALL_DIR" ]; then
+ INSTALL_DIR="$DEFAULT_INSTALL_DIR"
+ fi
+else
+ INSTALL_DIR="$1"
+fi
+
+if [ ! -d $INSTALL_DIR ]
+ then
+ mkdir -p $INSTALL_DIR
+fi
+
+INSTALL_DIR=`cd "$INSTALL_DIR"; pwd`
+
+# --- check jdk and jdk-version
+install_jdk=0
+javaversion=`java -version 2>&1|grep "java version"`
+if [ -n "$javaversion" ]
+ then
+ # javaversion=${javaversion:14:3}
+ javavmajor=`echo $javaversion | cut -c15`
+ javavminor=`echo $javaversion | cut -c17`
+# OS_TYPE=$( lsb_release -d| cut -d: -f2| cut -f2 )
+# if [ "`echo $OS_TYPE | cut -c1-6`" = "Ubuntu" ]
+# then
+# if [ 2 -gt $javavmajor ]; then
+# if [ 6 -gt $javavminor ]; then
+# install_jdk=1
+# fi
+# fi
+# else
+ if [[ 2 -gt $javavmajor && 6 -gt $javavminor ]]; then
+ install_jdk=1
+ fi
+# fi
+ else
+ install_jdk=1
+fi
+
+# --- install jdk
+cd "$INSTALL_DIR"/..
+NMS_JDK="$(pwd)/nmsjdk"
+JDK_DIR="$(pwd)/jdk1.7.0_80"
+JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-i586.tar.gz"
+if [ "`uname -i`" = "x86_64" ];then
+ JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-x64.tar.gz"
+fi
+if [ $install_jdk = 1 ]
+ then
+ if [ ! -e "$NMS_JDK" ]
+ then
+ echo "JDK bin file: $JDK_BIN_FILE"
+ echo "now, install jdk: $JDK_DIR"
+ sleep 3
+ if [ ! -e "$JDK_DIR" ];then
+ mkdir -p $JDK_DIR
+ fi
+ tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
+ if [ -n "$installJdk" ];then
+ echo "install jdk failure, exit program"
+ exit 1
+ fi
+ ln -s $JDK_DIR $NMS_JDK
+ echo "install jdk done"
+ fi
+elif [ -n "$JAVA_HOME" ];then
+ ln -s $JAVA_HOME $NMS_JDK
+else
+ echo "JDK bin file: $JDK_BIN_FILE"
+ echo "now, install jdk: $JDK_DIR"
+ sleep 3
+ if [ ! -e "$JDK_DIR" ];then
+ mkdir -p $JDK_DIR
+ fi
+ tar -xzf $JDK_BIN_FILE -C $JDK_DIR --strip-components=1 || installJdk=1
+ if [ -n "$installJdk" ];then
+ echo "install jdk failure, exit program"
+ exit 1
+ fi
+ ln -s $JDK_DIR $NMS_JDK
+ echo "install jdk done"
+fi
+cd "$CUR_PRGDIR"
+
+echo "==========================================="
+echo "NMS_JDK: $NMS_JDK"
+echo "INSTALL_DIR: $INSTALL_DIR"
+echo "==========================================="
+
+# --- copy file to install_dir
+if [ "$INSTALL_DIR" == "$CUR_PRGDIR" ]
+ then
+ echo "install directory is current program directory..."
+else
+ echo "install program, it may take a few time..."
+ CP_DIR=(
+ bin
+ lib
+ conf
+ shell
+ )
+ #cp
+ for CP_NAME in ${CP_DIR[@]}
+ do
+ cp -a $CUR_PRGDIR"/$CP_NAME" $INSTALL_DIR
+ done
+fi
+
+
+function modify_file(){
+ if [ $# != 2 ]
+ then
+ echo "usage: modify_file [prop_name] [prop_value]"
+ exit 0
+ fi
+ prop_name="$1"
+ prop_value="$2"
+ #echo "modify_file $prop_name $prop_value"
+ if [ -z "$(cat $PROP_FILE |grep $prop_name)" ]
+ then
+ echo "" >> $PROP_FILE
+ echo "$prop_name=$prop_value" >> $PROP_FILE
+ else
+ sed -i "s@^$prop_name.*@$prop_name=$prop_value@" $PROP_FILE
+ fi
+}
+
+# --- modify property
+#-------------file path
+echo -n "please enter data path, notice: this path not within $INSTALL_DIR, [default $DEFAULT_DATA_DIR]: "
+read path
+if [ -z "$path" ]
+ then
+ path="$DEFAULT_DATA_DIR"
+fi
+#-------------include path
+echo -n "delete include path [default $INSTALL_DIR,$path ]: "
+read include_path
+if [ -z "$include_path" ]
+ then
+ include_path="$INSTALL_DIR,$path"
+else
+ include_path="$INSTALL_DIR,$path,$include_path"
+fi
+#-------------exclude path
+echo -n "delete exclude path [default $INSTALL_DIR/bin,$INSTALL_DIR/lib,$INSTALL_DIR/shell,$INSTALL_DIR/conf ]: "
+read exclude_path
+if [ -z "$exclude_path" ]
+ then
+ exclude_path="$INSTALL_DIR/bin,$INSTALL_DIR/lib,$INSTALL_DIR/shell"
+else
+ exclude_path="$$INSTALL_DIR/bin,$INSTALL_DIR/lib,$INSTALL_DIR/shell,$exclude_path"
+fi
+#-------------nmsserver ip
+echo -n "enter DataController ip: "
+read server_ip
+while [ -z "$server_ip" ]
+ do
+ echo -n "DataController ip cannot null, please enter ip: "
+ read server_ip
+done
+#-------------log4j dir
+echo -n "enter logs path [default $path/nc_logs]: "
+read logs_path
+if [ -z "$logs_path" ]
+ then
+ logs_path="$path/nc_logs"
+fi
+
+#path=${path//\//\\/}
+
+PROP_FILE=$INSTALL_DIR"/conf/myconfig.properties"
+#echo "PROP_FILE: $PROP_FILE"
+modify_file "local.data.path" $path
+modify_file "common.del.path.include" $include_path
+modify_file "common.del.path.exclude" $exclude_path
+modify_file "server_host" $server_ip
+
+# modify log4j
+PROP_FILE=$INSTALL_DIR"/conf/log4j.properties"
+encoding=${LANG#*.}
+modify_file "log4j.appender.stdout.encoding" $encoding
+modify_file "log4j.appender.debugAppender.encoding" $encoding
+modify_file "log4j.appender.infoAppender.encoding" $encoding
+modify_file "log4j.appender.debugAppender.File" "$logs_path/nmsclient_debug.log"
+modify_file "log4j.appender.infoAppender.File" "$logs_path/nmsclient_info.log"
+
+#permit
+cd $INSTALL_DIR"/shell"
+chmod 755 *.sh
+cd $CUR_PRGDIR
+
+if [ -z "$(cat /etc/rc.local|grep $INSTALL_DIR"/shell/startup.sh")" ]
+then
+ echo $INSTALL_DIR"/shell/startup.sh" >> /etc/rc.local
+fi
+
+echo ""
+echo "install successed..."
+echo "please use [$INSTALL_DIR/shell/startup.sh] to run the program..."
diff --git a/linuxinstall/readme.txt b/linuxinstall/readme.txt
new file mode 100644
index 0000000..d8631d2
--- /dev/null
+++ b/linuxinstall/readme.txt
@@ -0,0 +1,59 @@
+NC--Linux下的安装文件结构:
+
+|--NC_install
+| |--autoinstall.sh
+| |--install.sh
+| |--bin
+| | |--cer
+| | | |--client_ks
+| | | |--client_ts
+| | |--fileComment.jar
+| | |--nmsclient.jar
+| |--conf
+| | |--jvm.conf
+| | |--log4j.properties
+| | |--myconfig.properties
+| | |--version.properties
+| |--jre_install
+| | |--jre-6u45-linux-i586.bin
+| | |--jre-6u45-linux-x64.bin
+| |--lib
+| | |--ant.jar
+| | |--commons-beanutils-1.7.jar
+| | |--commons-collections.jar
+| | |--commons-io.jar
+| | |--commons-lang.jar
+| | |--commons-logging.jar
+| | |--ezmorph-1.0.4.jar
+| | |--java-unrar-0.3.jar
+| | |--javatar-2.5.jar
+| | |--jreloader.jar
+| | |--json-lib-2.2.2-jdk15.jar
+| | |--junit.jar
+| | |--log4j-1.2.15.jar
+| | |--ostermillerutils_1_07_00.jar
+| | |--sigar.jar
+| | |--libsigar-amd64-linux.so
+| | |--libsigar-x86-linux.so
+| |--shell
+| | |--check_userpass.sh
+| | |--execCmdBySu.sh
+| | |--nmsagent.sh
+| | |--nmsclient_shouhu.sh
+| | |--restart.sh
+| | |--shutdown.sh
+| | |--startup.sh
+
+
+脚本说明:
+
+1、安装脚本install.sh:
+ 先检查JDK是否安装且Java版本是否适合,来选择是否安装自带的JRE。
+ 若需自带安装,则判断系统的位数,相应安装32位JDK或64位JDK。
+ JDK安装目录为/home/nms/jre1.6.0_45, 并建软连接/home/nms/nmsjdk
+ 若系统已安装相应版本的JDK,则建连接/home/nms/nmsjdk
+
+2、自动安装脚本autoinstall.sh
+ JDK的检查逻辑与install.sh一样,只是所有参数都按默认值,不需人工交互,并安装完成后自动启动。
+
+3、shell目录下,脚本nmsagent.sh和datacontroller.sh,不检查JDK版本,只检查nmsjdk是否存在且nmsjdk/bin/Java命令能否正常使用 \ No newline at end of file
diff --git a/linuxinstall/shell/check_userpass.sh b/linuxinstall/shell/check_userpass.sh
new file mode 100644
index 0000000..6e6dc7d
--- /dev/null
+++ b/linuxinstall/shell/check_userpass.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/expect
+
+if {$argc!=3} {
+ send_user "usage: check_userpass.sh ip name password\n"
+ exit 1
+}
+
+set host [lindex $argv 0]
+set user [lindex $argv 1]
+set pass [lindex $argv 2]
+
+set isSend 0
+spawn ssh -t "${user}@${host}"
+
+while 1 {
+ expect {
+ "* (yes/no)*" {send "yes\r"}
+ "* ����*" {
+ send "${pass}\r"
+ set isSend 1
+ }
+ "* password:*" {
+ send "${pass}\r"
+ set isSend 1
+ }
+ "Permission denied" {
+ send_user "Not allowed\n"
+ exit 1
+ }
+ "*~]" {
+ send_user "OK\n"
+ send "exit\r"
+ exit 0
+ }
+ "Last login:*" {
+ send_user "OK\n"
+ send "exit\r"
+ exit 0
+ }
+ default {
+ send_user "error\n"
+ exit 2
+ }
+ }
+}
+
+
diff --git a/linuxinstall/shell/execCmdBySu.sh b/linuxinstall/shell/execCmdBySu.sh
new file mode 100644
index 0000000..4a94436
--- /dev/null
+++ b/linuxinstall/shell/execCmdBySu.sh
@@ -0,0 +1,78 @@
+#!/usr/bin/expect
+
+if {$argc!=4&&$argc!=3} {
+ send_user "usage: execCmdBySu.sh resultFlag command name \[password\]\n"
+ exit 1
+}
+# 0��ִ�����ȡ�ý����1��ִ��&��̨����
+set resultFlag [lindex $argv 0]
+set cmd [lindex $argv 1]
+set user [lindex $argv 2]
+set pass [lindex $argv 3]
+
+set timeout 30
+set flag 0
+
+#�رտ���̨�����Ϣ
+log_user 0
+
+spawn whoami
+expect "root" {set flag 1}
+
+# ��ִ������${cmd}��׷��"echo $?",Ϊ��ȡcmd�������е�ʵ�ʽ��, �����ε���������ص������Ϣ
+if {$resultFlag==0} {
+ spawn su - -c "${cmd};echo $?" ${user}
+
+ #��ǰ��¼�û�����root����������
+ if {$flag==0} {
+ expect {
+ "����*" {send ${pass}\r}
+ "password*" {send ${pass}\r}
+ default {
+ send_error "error\n"
+ exit 2
+ }
+ }
+ }
+
+ #�򿪿���̨�����Ϣ
+ log_user 1
+
+ expect {
+ "* ���벻��ȷ*" {exit 1}
+ #----�˴���Ŀ����Ϊ���ܶ�ȡ������������
+ eof {exit 0}
+ }
+
+} else {
+ spawn su - -c "${cmd}" ${user}
+
+ #��ǰ��¼�û�����root����������
+ if {$flag==0} {
+ expect {
+ "����*" {send ${pass}\r}
+ "password*" {send ${pass}\r}
+ default {
+ send_error "error\n"
+ exit 2
+ }
+ }
+ }
+ expect {
+ "* ���벻��ȷ*" {exit 1}
+ #----Ϊ��&��̨������������������
+ eof {
+ send_user "ok\n"
+ exit 0
+ }
+ }
+}
+interact
+exit 0
+
+
+#overlay chess
+#overlay program args
+#disconnect
+#close -onexec 0 -i ${spawn_id}
+#remove_nulls 1 \ No newline at end of file
diff --git a/linuxinstall/shell/nmsagent.sh b/linuxinstall/shell/nmsagent.sh
new file mode 100644
index 0000000..9450828
--- /dev/null
+++ b/linuxinstall/shell/nmsagent.sh
@@ -0,0 +1,260 @@
+#!/bin/sh
+
+# -----------------------------------------------------------------------------
+# Start/Stop Script for the NMS Client
+#
+# Environment Variable Prequisites
+#
+# NMSCLEINT_HOME May point at your Catalina "build" directory.
+#
+# NMSCLIENT_TASKDIR (Optional) Directory path location of taskresult directory
+# Defaults to %NMSCLIENT_HOME%/task.
+#
+# NMSCLIENT_TMPDIR (Optional) Directory path location of temporary directory
+# the JVM should use (java.io.tmpdir). Defaults to
+# $NMSCLIENT_HOME/temp.
+#
+# JAVA_HOME Must point at your Java Development Kit installation.
+# Required to run the with the "debug" argument.
+#
+# -----------------------------------------------------------------------------
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+#OS_TYPE=$( lsb_release -d| cut -d: -f2| cut -f2 )
+#echo $OS_TYPE
+while [ -h "$PRG" ]; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set NMSCLEINT_HOME if not already set
+[ -z "$NMSCLEINT_HOME" ] && NMSCLEINT_HOME=`cd "$PRGDIR/.." ; pwd`
+cd "$NMSCLEINT_HOME"/shell
+
+if [ -z "$NMSCLIENT_TMPDIR" ] ; then
+ NMSCLIENT_TMPDIR="$NMSCLEINT_HOME"/temp
+fi
+if [ ! -d $NMSCLIENT_TMPDIR ]
+ then
+ mkdir $NMSCLIENT_TMPDIR
+fi
+
+if [ -n "$4" ]; then
+ NMSCLIENT_TASKDIR=`dirname "$4"`
+fi
+if [ -z "$NMSCLIENT_TASKDIR" ] ; then
+ NMSCLIENT_TASKDIR="$NMSCLEINT_HOME"/task
+fi
+
+
+# -------- check jdk
+# check nmsjdk
+NMS_HOME=`cd "$NMSCLEINT_HOME/.." ; pwd`
+cd "$NMSCLEINT_HOME"/shell
+NMS_JDK="$NMS_HOME"/nmsjdk
+if [ ! -e "$NMS_JDK" ]
+ then
+ echo "$NMS_JDK not exist"
+ exit 0
+fi
+# check java -version
+javaversion=`$NMS_JDK/bin/java -version 2>&1|grep "java version"`
+if [ ! -n "$javaversion" ]
+ then
+ echo "$NMS_JDK cannot use, please install"
+ exit 0
+fi
+
+# -------- set jdk path
+export JAVA_HOME=$NMS_JDK
+export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
+export PATH=$JAVA_HOME/bin:$PATH
+
+temp=$CLASSPATH
+#setting libs path
+libs="$NMSCLEINT_HOME"/lib/*
+append(){
+ temp=$temp":"$1
+}
+for file in $libs; do
+ append $file
+done
+jars="$NMSCLEINT_HOME"/bin/*
+for file in $jars; do
+ append $file
+done
+export NC_CLASSPATH=$temp:.:$NMSCLEINT_HOME/conf
+export LD_LIBRARY_PATH=$NMSCLEINT_HOME/lib
+export LANG=zh_CN.UTF-8
+
+# Bugzilla 37848: When no TTY is available, don't output to console
+have_tty=0
+if [ "`tty`" != "not a tty" ]; then
+ have_tty=1
+fi
+
+# ----- Execute The Requested Command -----------------------------------------
+
+# Bugzilla 37848: only output this if we have a TTY
+if [ $have_tty -eq 1 ]; then
+ echo "Using NMSCLEINT_HOME: $NMSCLEINT_HOME"
+ echo "Using NMSCLIENT_TMPDIR: $NMSCLIENT_TMPDIR"
+ echo "Using JAVA_HOME: $JAVA_HOME"
+ echo "Using CLASSPATH: $NC_CLASSPATH"
+fi
+
+# ---- get jvm param
+jvmconf_file=$NMSCLEINT_HOME"/conf/jvm.conf"
+if [ -f $jvmconf_file ]
+ then
+ #sed -n '/Xmx=/p' $jvmconf_file | sed 's/Xmx=//g'
+ XmsOpt=`sed -n '/-Xms/p' $jvmconf_file`
+ XmxOpt=`sed -n '/-Xmx/p' $jvmconf_file`
+ JAVA_OPTS="$XmsOpt $XmxOpt -XX:+UseParNewGC"
+else
+ JAVA_OPTS="-Xms64m -Xmx128m -XX:+UseParNewGC"
+fi
+
+program="com.nis.nmsclient.NmsClient"
+name="NmsClient"
+
+proc_id=
+
+# handler agent upgrade result
+handleTask()
+{
+ if [ -d "$NMSCLIENT_TASKDIR" ]
+ then
+ cd $NMSCLIENT_TASKDIR
+ for i in *.upgrade;do mv "$i" "${i%.upgrade}.result";done >/dev/null 2>&1
+ cd "$NMSCLEINT_HOME"/shell
+ fi
+}
+writePid()
+{
+ ps aux|grep java|grep $program|grep -v grep|awk '{print $2}' > $NMSCLIENT_TMPDIR/agentPid.temp
+}
+getPid()
+{
+ unset proc_id
+ proc_id=`ps aux|grep java|grep $program|grep -v grep|awk '{print $2}'`
+}
+shouhu_proc="$NMSCLEINT_HOME"/shell/nmsclient_shouhu.sh
+stopShouhuProc()
+{
+ shouhu_proc_id=`ps aux|grep $shouhu_proc|grep -v grep|awk '{print $2}'`
+ if [ -n "$shouhu_proc_id" ]
+ then
+ echo "kill shouhu process ....."
+ kill -9 $shouhu_proc_id
+ fi
+}
+startShouhuProc()
+{
+ shouhu_proc_id=`ps aux|grep $shouhu_proc|grep -v grep|awk '{print $2}'`
+ if [ ! -n "$shouhu_proc_id" ]
+ then
+ echo "start shouhu process ....."
+ nohup $shouhu_proc $NMSCLIENT_TASKDIR >/dev/null &
+ fi
+}
+if [ "$1" = "start" ] ; then
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ echo "$name already running......"
+ else
+ nohup java $JAVA_OPTS -classpath $NC_CLASSPATH $program >/dev/null &
+ sleep 3
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ echo "$name start success!!!!!"
+ writePid
+ else
+ echo "$name start error!!!!!"
+ fi
+ handleTask
+ fi
+elif [ "$1" = "stop" ]; then
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ stopShouhuProc
+ sleep 1
+ echo "$name is start, now kill......"
+ kill -9 $proc_id
+ writePid
+ echo "$name kill ok !!!!!!!!!!!!!"
+ else
+ echo "$name is not start!!!!!!!!!!!"
+ fi
+elif [ "$1" = "restart" ] ; then
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ echo "$name is start, now restart......"
+ stopShouhuProc
+ sleep 1
+ startShouhuProc
+ kill -9 $proc_id
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ echo "$name stop error!!!!!!!!!!"
+ handleTask
+ exit 1
+ fi
+ else
+ echo "$name is not start, now start......"
+ fi
+ copyError=
+ if [ -n "$2" ] ; then
+ srcFile=$2
+ updateFile=/dev/null
+ if [ -d "$2" ]; then
+ srcFile="$2"/*
+ fi
+ if [ -n "$4" ]; then
+ updateFile=$4
+ fi
+ if [ -n "$3" ]; then
+ unalias cp >/dev/null 2>&1
+ cp -rvf $srcFile $3 >>$updateFile 2>&1 ||copyError=1
+ fi
+ rm -rf $2 >/dev/null 2>&1
+ fi
+ if [ -n "$copyError" ]
+ then
+ #----copy error
+ handleTask
+ else
+ #--------copy right, start proc
+ nohup java $JAVA_OPTS -classpath $NC_CLASSPATH $program >/dev/null &
+ sleep 3
+ getPid
+ if [ -n "$proc_id" ]
+ then
+ writePid
+ else
+ echo "$name restart error!!!!!!!!!!"
+ handleTask
+ fi
+ fi
+
+else
+ echo "Usage: nmsagent.sh ( commands ... )"
+ echo "commands:"
+ echo " start Start $name in a separate window"
+ echo " restart ReStart $name in a separate window"
+ echo " stop Stop $name"
+fi
diff --git a/linuxinstall/shell/nmsclient_shouhu.sh b/linuxinstall/shell/nmsclient_shouhu.sh
new file mode 100644
index 0000000..821884f
--- /dev/null
+++ b/linuxinstall/shell/nmsclient_shouhu.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set NMSCLEINT_HOME if not already set
+[ -z "$NMSCLEINT_HOME" ] && NMSCLEINT_HOME=`cd "$PRGDIR/.." ; pwd`
+cd "$NMSCLEINT_HOME"/shell
+
+NC_TASKDIR="$1"
+log_file="$NMSCLEINT_HOME"/temp/job.log
+echo "NC_TASKDIR:$NC_TASKDIR" >> $log_file
+
+#count=1
+while [ 1 -eq 1 ]
+do
+ sleep 50
+ if [ `ps -ef | grep NmsClient | grep -v grep | wc -l` -lt 1 ]
+ then
+ echo -n "Down at:" >> $log_file
+ date >> $log_file
+ # ---------- handler agent upgrade result
+ if [ -d "$NC_TASKDIR" ]
+ then
+ cd $NC_TASKDIR
+ for i in *.upgrade;do mv "$i" "${i%.upgrade}.result";done >>$log_file 2>&1
+ cd "$NMSCLEINT_HOME"/shell
+ fi
+ # --------- start NC
+ "$NMSCLEINT_HOME"/shell/startup.sh
+ echo "NmsClient start...." >>$log_file
+ fi
+ sleep 1
+ #count=$count+1
+
+ #if [ count -eq 900 ]
+ #then
+ # jpid=`ps -ef | grep java | grep -v grep | cut -c0-5`
+ # kill -9 $jpid
+ # count=1
+ #fi
+done \ No newline at end of file
diff --git a/linuxinstall/shell/restart.sh b/linuxinstall/shell/restart.sh
new file mode 100644
index 0000000..f3c288d
--- /dev/null
+++ b/linuxinstall/shell/restart.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# -----------------------------------------------------------------------------
+# Retart Script for the NMS Client
+#
+# -----------------------------------------------------------------------------
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+PRGDIR=`dirname "$PRG"`
+EXECUTABLE=nmsagent.sh
+
+if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+ echo "Cannot find $PRGDIR/$EXECUTABLE"
+ echo "This file is needed to run this program"
+ exit 1
+fi
+
+exec "$PRGDIR"/"$EXECUTABLE" restart $1 $2 $3 "$@" \ No newline at end of file
diff --git a/linuxinstall/shell/shutdown.sh b/linuxinstall/shell/shutdown.sh
new file mode 100644
index 0000000..bc5ecc9
--- /dev/null
+++ b/linuxinstall/shell/shutdown.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# -----------------------------------------------------------------------------
+# Stop Script for the NMS Client
+#
+# -----------------------------------------------------------------------------
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+PRGDIR=`dirname "$PRG"`
+EXECUTABLE=nmsagent.sh
+
+if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+ echo "Cannot find $PRGDIR/$EXECUTABLE"
+ echo "This file is needed to run this program"
+ exit 1
+fi
+
+exec "$PRGDIR"/"$EXECUTABLE" stop "$@" \ No newline at end of file
diff --git a/linuxinstall/shell/startup.sh b/linuxinstall/shell/startup.sh
new file mode 100644
index 0000000..a28c64a
--- /dev/null
+++ b/linuxinstall/shell/startup.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# -----------------------------------------------------------------------------
+# Start Script for the NMS Client
+#
+# -----------------------------------------------------------------------------
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`/"$link"
+ fi
+done
+
+PRGDIR=`dirname "$PRG"`
+EXECUTABLE=nmsagent.sh
+
+if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
+ echo "Cannot find $PRGDIR/$EXECUTABLE"
+ echo "This file is needed to run this program"
+ exit 1
+fi
+
+exec "$PRGDIR"/"$EXECUTABLE" start "$@" \ No newline at end of file