mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-08-22 11:10:24 +00:00
modify enablesnmp postscript to show 'net' command (#6030)
This commit is contained in:
@@ -18,10 +18,7 @@ fi
|
||||
|
||||
#get snmp attribute
|
||||
#NOTE: the length of SNMP Password has to be min=8
|
||||
xCATSettingsSTART="xCAT settings START"
|
||||
xCATSettingsEND="xCAT settings END"
|
||||
xCATSettingsOID="xCAT customized"
|
||||
xCATSettingsInfo="Entries between the START and END lines will be replaced each time by running enablesnmp"
|
||||
xCATSettingsOID="xCAT setting"
|
||||
snmpversion=$SNMPVERSION
|
||||
snmpuser=$SNMPUSER
|
||||
snmppwd=$SNMPPASSWD
|
||||
@@ -36,21 +33,8 @@ if [ $? -eq 0 ]; then
|
||||
cp ${snmp_conf}.cumulus $snmp_conf
|
||||
fi
|
||||
|
||||
grep "$xCATSettingsSTART" $snmp_conf 2>&1 1> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
#remove the previous snmp rule generated by xCAT
|
||||
sed -i "/$xCATSettingsSTART/,/$xCATSettingsEND/ d" $snmp_conf
|
||||
else
|
||||
sed -i "/^\s*agentAddress/s/^/#/" $snmp_conf
|
||||
sed -i '/agentAddress udp\:161\,udp6\:\[\:\:1\]\:161/s/^#//' $snmp_conf
|
||||
sed -i "/view\s*systemonly\s*included\s*.1.3.6.1.2.1.17/s/^#//" $snmp_conf
|
||||
sed -i "/pass_persist\s*.1.3.6.1.2.1.17\s*\/usr\/share\/snmp\/bridge_pp.py/s/^#//" $snmp_conf
|
||||
fi
|
||||
|
||||
|
||||
# Mark the start of xCAT section
|
||||
echo "# $xCATSettingsSTART" >> $snmp_conf
|
||||
echo "# $xCATSettingsInfo" >> $snmp_conf
|
||||
# config snmpd to all the listening address
|
||||
net add snmp-server listening-address all
|
||||
|
||||
if [[ "$snmpversion" =~ "3" ]]; then
|
||||
#set up snmp version 3
|
||||
@@ -58,21 +42,17 @@ if [[ "$snmpversion" =~ "3" ]]; then
|
||||
len=${#snmppwd}
|
||||
if [ $len -lt 8 ]; then
|
||||
echo "SNMP v3 specification requires password to have a minimum of 8 characters"
|
||||
echo "# $xCATSettingsEND" >> $snmp_conf
|
||||
exit -1
|
||||
fi
|
||||
snmpauth=`echo $snmpauth | tr '[a-z]' '[A-Z]'`
|
||||
snmpauth=`echo $snmpauth | awk '{print tolower($0)}'`
|
||||
if [ -n "$snmppriv" ]; then
|
||||
snmppriv=`echo $snmppriv | tr '[a-z]' '[A-Z]'`
|
||||
echo "createUser $snmpuser $snmpauth $snmppwd $snmppriv $snmppwd" >> $snmp_conf
|
||||
echo "rwuser $snmpuser" >> $snmp_conf
|
||||
snmppriv=`echo $snmppriv | awk '{print tolower($0)}'`
|
||||
net add snmp-server username $snmpuser auth-$snmpauth $snmppwd encrypt-$snmppriv $snmppwd
|
||||
else
|
||||
echo "createUser $snmpuser $snmpauth $snmppwd" >> $snmp_conf
|
||||
echo "rouser $snmpuser" >> $snmp_conf
|
||||
net add snmp-server username $snmpuser auth-$snmpauth $snmppwd
|
||||
fi
|
||||
else
|
||||
echo "Please define user/password/auth for SNMP v3 specification"
|
||||
echo "# $xCATSettingsEND" >> $snmp_conf
|
||||
exit -1
|
||||
fi
|
||||
elif [ -n "$snmppwd" ]; then
|
||||
@@ -81,10 +61,8 @@ elif [ -n "$snmpc" ]; then
|
||||
community=$snmpc
|
||||
fi
|
||||
|
||||
echo "rocommunity $community default" >> $snmp_conf
|
||||
echo "rocommunity $community default -V systemonly" >> $snmp_conf
|
||||
|
||||
echo "# $xCATSettingsEND" >> $snmp_conf
|
||||
net add snmp-server readonly-community $community access any
|
||||
net commit
|
||||
|
||||
#create snmpd restart conf file
|
||||
mkdir -p /etc/systemd/system/snmpd.service.d
|
||||
|
Reference in New Issue
Block a user