This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nms-oam/gloam/conf/collector/modify_config_seqId.sh
fangshunjian 788b321414 1、修改程序启动读取配置文件,修改node_table表信息
2、添加数据收集脚本,程序启动时主动下发监测脚本,同时修改监测配置文件seq_id
3、修改进程shell命令
2018-12-21 16:55:02 +06:00

64 lines
1.6 KiB
Bash

#!/bin/bash
basePath=$(cd `dirname $0`; pwd)
cd ${basePath}
echo "$basePath"
#处理device_config 脚本
if [ ! -f '/usr/local/bin/device_config' ];then
cp "$basePath"/device_config /usr/local/bin
if [ $? = 0 ];then
chmod +x /usr/local/bin/device_config
fi
fi
#修改configs文件夹下所有.cfg配置文件的pubInfo 中的seqid
while read line;do
eval "$line"
done < config
index=1
flag=1
while [ $flag -eq 1 ]; do
key='ip'${index}
value=`eval echo '$'${key}`
OLD_IFS="$IFS"
IFS=","
#ip{id}=ip,user,pwd,name,ethname,sort,isMaster
value_arr=($value)
IFS=$OLD_IFS
ip=${value_arr[0]}
username=${value_arr[1]}
password=${value_arr[2]}
isMaster=${value_arr[6]}
ethname=${value_arr[4]}
if [ -z ${value} ];then
flag=0
else
#是本台机器
isThis=`ifconfig $ethname | head -2 | tail -n 1 | awk '{print $2}'`
if [ $isThis = "$ip" ]; then
for file in ./configs/*.cfg
do
#修改seqid
sed -i "s/^pubInfo=[^,]*/pubInfo=$index/g" $file
echo "modfiy $ip $file $index"
done
if [ $isMaster -eq 1 ];then
if [[ -f ${basePath}"/merge.sh" && -z "$(grep "$basePath/merge.sh" /var/spool/cron/root |grep -v 'grep' 2>/dev/null)" ]];then
echo "*/1 * * * * $basePath/merge.sh">>/var/spool/cron/root
echo "isMaster add merge.sh crontab"
fi
fi
#检查是否开启定时任务
if [ -z "$(grep $basePath/getSingleMacInfo.sh /var/spool/cron/root | grep -v 'grep' 2>/dev/null)" ];then
echo "*/5 * * * * $basePath/getSingleMacInfo.sh" >>/var/spool/cron/root
echo "$ip add getSingleMacInfo.sh crontab"
fi
flag=0
fi
let "index++"
fi
done