このページの翻訳:
- 日本語 (ja)
- English (en)
最近の更新
- 02 Apache2で自己認証ssl [中間証明書の整合性確認]
最近の更新
# yum -y install hp-snmp-agents
centos7 ではmailコマンドが無いのでインストール
# yum -y install mailx
community名は適当にpublicとかで
# /sbin/hpsnmpconfig This configuration script will configure SNMP to integrate with the HPE SIM and the HPE System Management Homepage by editting the snmpd.conf file. The HP-SNMP-Agents can also exist in a more secure SNMP environment (e.g. VACM) that you have previously configured. See the hp-snmp-agents(4) man page for specific details on how to configure the VACM entries in the 'snmpd.conf' file. You may press <ctrl+c> now to exit now if needed. Do you wish to use an existing snmpd.conf (y/n) (Blank is n): You will now be asked a series of SNMP configuration questions. How you answer these question will affect the way SNMP behaves. Configuring SNMP could have security implications on your system. If you are not sure how to answer a question, you can abort by pressing <Ctrl-c> and no changes will be made to your SNMP configuration. Enter the localhost SNMP Read/Write community string (one word, required, no default): You will now be asked a series of SNMP configuration questions. How you answer these question will affect the way SNMP behaves. Configuring SNMP could have security implications on your system. If you are not sure how to answer a question, you can abort by pressing <Ctrl-c> and no changes will be made to your SNMP configuration. Enter the localhost SNMP Read/Write community string (one word, required, no default): You will now be asked a series of SNMP configuration questions. How you answer these question will affect the way SNMP behaves. Configuring SNMP could have security implications on your system. If you are not sure how to answer a question, you can abort by pressing <Ctrl-c> and no changes will be made to your SNMP configuration. Enter the localhost SNMP Read/Write community string (one word, required, no default): You will now be asked a series of SNMP configuration questions. How you answer these question will affect the way SNMP behaves. Configuring SNMP could have security implications on your system. If you are not sure how to answer a question, you can abort by pressing <Ctrl-c> and no changes will be made to your SNMP configuration. Enter the localhost SNMP Read/Write community string (one word, required, no default): Re-enter the same input to confirm: ERROR: inputs mismatch! Press ENTER to try again. You will now be asked a series of SNMP configuration questions. How you answer these question will affect the way SNMP behaves. Configuring SNMP could have security implications on your system. If you are not sure how to answer a question, you can abort by pressing <Ctrl-c> and no changes will be made to your SNMP configuration. Enter the localhost SNMP Read/Write community string (one word, required, no default): Re-enter the same input to confirm: ACCEPTED: inputs match! Enter localhost SNMP Read Only community string (one word, Blank to skip): Enter Read/Write Authorized Management Station IP or DNS name (Blank to skip): Enter Read Only Authorized Management Station IP or DNS name (Blank to skip): Enter default SNMP trap community string (One word; Blank to skip): Enter SNMP trap destination IP or DNS name (One word; Blank to skip): The system contact is set to syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf) Do you wish to change it (y/n) (Blank is n): The system location is set to syslocation Unknown (edit /etc/snmp/snmpd.conf) Do you wish to change it (y/n) (Blank is n): ============================================================================== NOTE: New snmpd.conf entries were added to the top of /etc/snmp/snmpd.conf ============================================================================== snmpd is started
/opt/hp/hp-snmp-agents/cma.conf
trapemail /bin/mail -s 'HPE Insight Management Agents Trap Alarm' root ↓ #trapemail /bin/mail -s 'HPE Insight Management Agents Trap Alarm' root trapemail /usr/bin/logger -t 'HPE Insight Management Agents Trap Alarm' trapemail /bin/bash /opt/hp/zbxsender_hpima.sh -m
/opt/hp/zbxsender_hpima.sh
#!/bin/bash
EXCLUDE="Trap-ID=11020
NIC Link is Up"
MAILTO="hoge@hogehoge.com"
ZBX_KEY="hp.ima.trap"
while getopts mz OPTION ; do
case $OPTION in
m )
TO="MAIL"
;;
z )
TO="ZABBIX"
;;
esac
done
shift $(($OPTIND - 1))
DATA=$(cat -)
if [ $(echo -e "${DATA}" |grep -c -f <(echo -e "${EXCLUDE}")) -le 0 ] ;then
NAME=${HOST}${HOSTNAME}
if [ "${TO}" = "ZABBIX" ] ;then
ZBXS=$(grep Server= /etc/zabbix/zabbix_agentd.conf |grep -v "^#" |awk -F'=' '{print $2}' |sed 's/,/ /g')
OK=0
for ZBX in ${ZBXS} ;do
if [ ${OK} -ne 1 ];then
/usr/bin/zabbix_sender -z ${ZBX} -s ${NAME} -k ${ZBX_KEY} -o "${DATA}" && OK=1
fi
done
elif [ "${TO}" = "MAIL" ] ;then
RELEASE=$(cut -d. -f1 /etc/redhat-release)
if [ "${RELEASE}" = "CentOS Linux release 7" ] ;then
echo -e "${DATA}" |mail -s "HPE Insight Management Agents Trap Alarm ( ${NAME} )" -r ${NAME}@gmocloud.com ${MAILTO}
elif [ "${RELEASE}" = "CentOS release 6" ] ;then
echo -e "${DATA}" |mail -s "HPE Insight Management Agents Trap Alarm ( ${NAME} )" -r ${NAME}@gmocloud.com ${MAILTO}
elif [ "${RELEASE}" = "CentOS release 5" ] ;then
echo -e "${DATA}" |mail -s "HP Insight Management Agents Trap Alarm ( ${NAME} )" ${MAILTO} -- -f ${NAME}@gmocloud.com
else
echo -e "Not Supported.\n${RELEASE}" 1>&2
fi
fi
fi
exit