ユーザ用ツール

サイト用ツール


サイドバー

このページの翻訳:



最近の更新



Tag Cloud

01_linux:12_ツール:19_hpe_insight_management_agents_trap_alarm

19 HPE Insight Management Agents Trap Alarm

1.インストー

# yum -y install hp-snmp-agents

Centos7の場合

centos7 ではmailコマンドが無いのでインストー

# yum -y install mailx

2.初期設定

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

3.設定ファイル変更

/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

4.メールスクリプト設置

/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

5.プロセス再起動

# systemctl restart hp-snmp-agents
,
01_linux/12_ツール/19_hpe_insight_management_agents_trap_alarm.txt · 最終更新: 2020/01/09 15:20 by matsui