添加OAM、tsg-cli自动部署部分
This commit is contained in:
BIN
roles/tsg-cli-mxn/files/cmm_api_tst
Normal file
BIN
roles/tsg-cli-mxn/files/cmm_api_tst
Normal file
Binary file not shown.
93
roles/tsg-cli-mxn/files/rsyslog.conf
Normal file
93
roles/tsg-cli-mxn/files/rsyslog.conf
Normal file
@@ -0,0 +1,93 @@
|
||||
# rsyslog configuration file
|
||||
|
||||
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
|
||||
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
|
||||
|
||||
#### MODULES ####
|
||||
|
||||
# The imjournal module bellow is now used as a message source instead of imuxsock.
|
||||
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
|
||||
$ModLoad imjournal # provides access to the systemd journal
|
||||
#$ModLoad imklog # reads kernel messages (the same are read from journald)
|
||||
#$ModLoad immark # provides --MARK-- message capability
|
||||
|
||||
# Provides UDP syslog reception
|
||||
$ModLoad imudp
|
||||
$UDPServerRun 514
|
||||
|
||||
# Provides TCP syslog reception
|
||||
$ModLoad imtcp
|
||||
$InputTCPServerRun 514
|
||||
|
||||
|
||||
#### GLOBAL DIRECTIVES ####
|
||||
|
||||
# Where to place auxiliary files
|
||||
$WorkDirectory /var/lib/rsyslog
|
||||
|
||||
# Use default timestamp format
|
||||
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
||||
$template tsgformat,"%$NOW% %TIMESTAMP:8:15% %HOSTNAME:F,45:3%:<%PRI%> [%syslogseverity-text%] %msg%\n"
|
||||
$ActionFileDefaultTemplate tsgformat
|
||||
|
||||
# File syncing capability is disabled by default. This feature is usually not required,
|
||||
# not useful and an extreme performance hit
|
||||
#$ActionFileEnableSync on
|
||||
|
||||
# Include all config files in /etc/rsyslog.d/
|
||||
$IncludeConfig /etc/rsyslog.d/*.conf
|
||||
|
||||
# Turn off message reception via local log socket;
|
||||
# local messages are retrieved through imjournal now.
|
||||
$OmitLocalLogging on
|
||||
|
||||
# File to store the position in the journal
|
||||
$IMJournalStateFile imjournal.state
|
||||
|
||||
|
||||
#### RULES ####
|
||||
|
||||
# Log all kernel messages to the console.
|
||||
# Logging much else clutters up the screen.
|
||||
#kern.* /dev/console
|
||||
|
||||
# Log anything (except mail) of level info or higher.
|
||||
# Don't log private authentication messages!
|
||||
*.notice;mail.none;authpriv.none;cron.none /var/log/messages
|
||||
|
||||
# The authpriv file has restricted access.
|
||||
authpriv.* /var/log/secure
|
||||
|
||||
# Log all the mail messages in one place.
|
||||
mail.* -/var/log/maillog
|
||||
|
||||
|
||||
# Log cron stuff
|
||||
cron.* /var/log/cron
|
||||
|
||||
# Everybody gets emergency messages
|
||||
*.emerg :omusrmsg:*
|
||||
|
||||
# Save news errors of level crit and higher in a special file.
|
||||
uucp,news.crit /var/log/spooler
|
||||
|
||||
# Save boot messages also to boot.log
|
||||
local7.* /var/log/boot.log
|
||||
|
||||
|
||||
# ### begin forwarding rule ###
|
||||
# The statement between the begin ... end define a SINGLE forwarding
|
||||
# rule. They belong together, do NOT split them. If you create multiple
|
||||
# forwarding rules, duplicate the whole block!
|
||||
# Remote Logging (we use TCP for reliable delivery)
|
||||
#
|
||||
# An on-disk queue is created for this action. If the remote host is
|
||||
# down, messages are spooled to disk and sent when it is up again.
|
||||
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
|
||||
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
|
||||
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
|
||||
#$ActionQueueType LinkedList # run asynchronously
|
||||
#$ActionResumeRetryCount -1 # infinite retries if host is down
|
||||
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
|
||||
#*.* @@192.168.40.165:514
|
||||
# ### end of the forwarding rule ###
|
||||
15
roles/tsg-cli-mxn/files/tsg-monitor.service
Normal file
15
roles/tsg-cli-mxn/files/tsg-monitor.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=tsg monitor service
|
||||
Requires=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
#WorkingDirectory=/opt/tsg/tsg-monitor/
|
||||
ExecStart=/opt/tsg/tsg-monitor/tsg-monitor.sh
|
||||
#ExecStop=/bin/kill $MAINPID
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
75
roles/tsg-cli-mxn/files/tsg-monitor.sh
Normal file
75
roles/tsg-cli-mxn/files/tsg-monitor.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
#mxn
|
||||
|
||||
#防止因上一次的命令阻塞或长时间未返回,
|
||||
#导致10秒内还不结束, 要强行杀掉,
|
||||
#否则长时间运行后, 会有大量后台进程运行!
|
||||
killall_uncompleted_cmd(){
|
||||
killall -9 -q tsg_cluster_register
|
||||
#killall -9 -q tsg_diagnose_background
|
||||
killall -9 -q tsg_update_tags
|
||||
}
|
||||
|
||||
start_background_cmd(){
|
||||
#后台并发运行, 保证所有命令的开始运行时间基本一样,
|
||||
#且不会因某个命令网络拥塞、执行时间长等问题,阻塞while(1)主循环
|
||||
/opt/tsg/tsg-monitor/tsg_cluster_register > /dev/null &
|
||||
|
||||
#mxn板只检测cpu, mem, disk等, 前台cli命令启用diagnose,
|
||||
#后台服务依靠oam snmp模块, 无需运行tsg_diagnose_background
|
||||
#/opt/tsg/tsg-monitor/tsg_diagnose_background &
|
||||
/opt/tsg/tsg-monitor/tsg_update_tags > /dev/null &
|
||||
}
|
||||
|
||||
#return value: current time in ms
|
||||
get_current_time_in_ms(){
|
||||
time_sec=`date +"%s"`
|
||||
time_nsec=`date +"%N"`
|
||||
#echo $time_sec
|
||||
#echo $time_nsec
|
||||
|
||||
time_epoch_ms=`echo | awk -v a=$time_sec -v b=$time_nsec '{printf("%.f"), a*1000+b/1000/1000}'`
|
||||
|
||||
echo $time_epoch_ms
|
||||
}
|
||||
|
||||
#args:
|
||||
#begin from time, in ms
|
||||
#wait for n ms
|
||||
sleep_for_time_ms(){
|
||||
last_time=$1
|
||||
wait_sec=$2
|
||||
#break_time=`echo | awk -v a=$last_time -v b=$wait_sec '{printf("%.f"), a+b}'`
|
||||
break_time=`expr $last_time + $wait_sec`
|
||||
break_time_int=`expr $break_time`
|
||||
#echo "start: last_time is:$last_time, expect break timeis:$break_time!"
|
||||
|
||||
current_time=0
|
||||
break_time=0
|
||||
#break_time=`expr $last_time + 1000*$1`
|
||||
while [ 1 ]; do
|
||||
current_time=`get_current_time_in_ms`
|
||||
current_time_int=`expr $current_time`
|
||||
if [ $current_time_int -ge $break_time_int ]; then
|
||||
#echo "current is: $current_time_int, break_time is:$break_time_int, break!"
|
||||
break
|
||||
else
|
||||
#echo "break is: $current_time_int, last_time is:$break_time_int, continue!"
|
||||
# usleep is us
|
||||
usleep 1000
|
||||
fi
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
while [ 1 ]; do
|
||||
start_time=`get_current_time_in_ms`
|
||||
#echo tsg-monitor start at `date +"%Y/%m/%d, %H:%M:%S.%N"` >> /tmp/tsg-monitor.log
|
||||
|
||||
start_background_cmd
|
||||
sleep 10
|
||||
killall_uncompleted_cmd
|
||||
|
||||
sleep_for_time_ms $start_time 15000
|
||||
done
|
||||
110
roles/tsg-cli-mxn/files/tsg_read_sn.sh
Normal file
110
roles/tsg-cli-mxn/files/tsg_read_sn.sh
Normal file
@@ -0,0 +1,110 @@
|
||||
#!/bin/bash
|
||||
# ====================================================
|
||||
# Main Script Test for Check ZHK's CSA-7400 Chassis ID
|
||||
# Edit:Edgar.Tang
|
||||
# Release date: 2019.9.16
|
||||
# ====================================================
|
||||
a=`date`
|
||||
Tstart=$(date +%s)
|
||||
Stime=`date +%Y%m%d-%H%M%S`
|
||||
open_intf.inst
|
||||
patch=`pwd`
|
||||
Version="A2"
|
||||
#SPVer=`cat release_note.txt | grep VERSION | head -n 1 | awk -F ":" '{print $2}'`
|
||||
i=0
|
||||
chmod 777 *
|
||||
rm -f *.log
|
||||
rm -f *.LOG
|
||||
rm -rf *.bin
|
||||
rm -rf tmp*
|
||||
rm -rf *dat
|
||||
rm -rf *PASS
|
||||
rm -rf *id
|
||||
rm -rf *ipmi
|
||||
clear
|
||||
function maintest(){
|
||||
#echo "##########################################################################"
|
||||
#echo "=========================Check chassis id information==============="
|
||||
#echo "-------------------------Check chassis id information---------------"
|
||||
|
||||
if [ ! -f "cmm_api_tst" ];then
|
||||
echo "not found cmm_api_tst!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./cmm_api_tst 9 1 1 127.0.0.1 | tee chid.id
|
||||
if [ $? != 0 ]; then
|
||||
echo "cmm_api_tst failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CHID=`cat chid.id | sed -n '1p' | awk -F ":" '{print $2}' | sed 's/ //g'`
|
||||
CHIDL=`echo $CHID | awk '{print length($0)}'`
|
||||
|
||||
if [ $CHIDL != 20 ];then
|
||||
echo "CHID length is not 20!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "{\"sn\": \"$CHID\"}" > ./tsg_sn.json
|
||||
}
|
||||
|
||||
#echo "#######################################################################"
|
||||
#echo "==========================Check Main Switch information================ "
|
||||
#echo "--------------------------Check Main Switch information----------------"
|
||||
|
||||
ipmitool raw 0x2e 0x32 0x00 0x5f 0x13 | tee main.ipmi
|
||||
ipmitool raw 0x2e 0x32 0x00 0x5f 0x13 | tail -n 1 | awk '{print $5}' | sed 's/ //g' | grep 01
|
||||
if [ $? == 0 ]; then
|
||||
echo "ipmitool: Check DUT Switch for Main!.......................................PASS"
|
||||
maintest $CHID $PSN $1
|
||||
else
|
||||
sdrnum=`ipmitool sdr | grep -a ok | wc -l`
|
||||
if [ $sdrnum == 23 ]; then
|
||||
echo "sdrnum: Check DUT Switch for Main!.......................................PASS"
|
||||
maintest $CHID $PSN $1
|
||||
else
|
||||
echo "===================================================================================="
|
||||
echo "====================FFFFFF======A========IIIIIIIII===LL============================="
|
||||
echo "====================F==========A=A===========I=======LL============================="
|
||||
echo "====================F=========A===A==========I=======LL============================="
|
||||
echo "====================FFFFF====AAAAAAA=========I=======LL============================="
|
||||
echo "====================F=======A=======A========I=======LL============================="
|
||||
echo "====================F======A=========A=======I=======LL============================="
|
||||
echo "====================F=====A===========A==IIIIIIIII===LLLLLLLLL======================"
|
||||
echo "===================================================================================="
|
||||
echo "FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL FAIL"
|
||||
echo "Check DUT Switch for Main!......................................FAIL"
|
||||
echo "====================================================================================== "
|
||||
echo "Please changed CMM for Main and please reboot another CMM via Serial Port;then retest"
|
||||
echo "====================================================================================== "
|
||||
read
|
||||
i=1
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#end=$(date +%s)
|
||||
#endt=$((end-Tstart))
|
||||
#echo "Test time: $endt seconds"
|
||||
#
|
||||
#clear
|
||||
#echo "========================================================================"
|
||||
#echo "Chassis Program Ver : $SPVer"
|
||||
#echo "------------------------------------------------------------------------"
|
||||
#echo "Chassis ID : $CHID"
|
||||
#echo "Chassis ID length : $CHIDL"
|
||||
#echo "------------------------------------------------------------------------"
|
||||
#echo "Test Time : $endt seconds"
|
||||
#echo "========================================================================"
|
||||
#echo "=================PPPPP=======A=======SSSSSSSSS==SSSSSSSS================"
|
||||
#echo "=================P====P=====A=A======S==========S======================="
|
||||
#echo "=================P====P====A===A=====S==========S======================="
|
||||
#echo "=================PPPPP====A=====A====SSSSSSSSS==SSSSSSSS================"
|
||||
#echo "=================P=======AAAAAAAAA===========S=========S================"
|
||||
#echo "=================P======A=========A==========S=========S================"
|
||||
#echo "=================P=====A===========A=SSSSSSSSS==SSSSSSSS================"
|
||||
#echo "========================================================================"
|
||||
|
||||
#echo "Chassis ID : $CHID"
|
||||
Reference in New Issue
Block a user