星期一, 6月 27, 2016

Dell OpenManage (OMSA) on XenServer 7

XenServer 7 釋出的消息真的是讓人非常興奮

抱著嘗鮮的心態,立馬下載

另外值得慶賀的是,XenServer 終於從CENTOS5 升級到 CENTOS 7了 (灑花)

[安裝Dell Openmanage]
還沒來的及體驗新的功能,倒是花了不少時間把Dell Openmanage (OMSA) 安裝起來
大致上跟之前的安裝方式類似,不過有一些步驟有一些些的差異 (還好有善心的鄉民分享)

1.加入Dell OpenManage Repository安裝來源
wget -q -O - http://linux.dell.com/repo/hardware/DSU_16.06.00/bootstrap.cgi | bash

這部分我有測試使用16.06安裝,但似乎會有問題 ,還在測試中(暫時先用16.05)
實驗過後可以直接使用16.06來安裝

2.編輯 CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
 把[base] 部分的 mirrorlist 跟baseurl註解,手動加入來
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirrors.kernel.org/centos/7.2.1511/os/x86_64/
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
 3.安裝Openmanage,按下Y開始同意安裝套件
yum --enablerepo=base install srvadmin-all
 4.在防火牆中加入1311PORT
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m conntrack --ctstate NEW -m tcp -p tcp --dport 1311 -j ACCEPT
 重新啟動防火牆讓設定生效
systemctl restart iptables
 5.啟動Openmanage服務
 /opt/dell/srvadmin/sbin/srvadmin-services.sh start
6.打開瀏覽器就可以開始使用了
/opt/dell/srvadmin/sbin/srvadmin-services.sh start

[設定Email Notifications]
1.安裝mailx
wget http://mirror.centos.org/centos/7.2.1511/os/x86_64/Packages/mailx-12.5-12.el7_0.x86_64.rpm
rpm -ivh mailx-12.5-12.el7_0.x86_64.rpm
2.設定 ssmtpd.conf
vi /etc/ssmtp/ssmtp.conf
mailhub=mail.yourdomain.com:25
AuthUser=username
AuthPass=password
rewriteDomain=server1.yourdomain.com

hostname=server1.yourdomain.com

3.建立 shell script 來發送MAIL通知 (from http://idolinux.blogspot.tw)
# vi /usr/local/bin/om-alert.sh

#!/bin/sh
HOST=`hostname`
EMAIL="my_admin@my_network.net"
echo "There has been an OpenManage ALERT detected on $HOST.  Please login to the web interface to see details." | mail  -s "OM ALERT $HOST  $1" $EMAIL
注意,新版本的mailx 如果-s不是立刻接在後方會造成主旨空白,不知道是否後方接MAIL的格式有錯誤造成
4. 你可以在 web介面 一筆一筆加入通知或是利用命令列加入MAIL發送通知
chmod +x /usr/local/bin/om-alert.sh
逐個項目加入

omconfig system alertaction
omconfig system alertaction -?
omconfig system alertaction event=powersupply execappath=/usr/local/bin/om-alert.sh
omconfig system alertaction event=storagesyswarn alert=true broadcast=true execappath=/usr/local/bin/om-alert.sh
omreport system alertaction

或是加入所有項目的通知
for I in `omconfig system alertaction | sed 's/ *(.*)//; s/>.*//; s/.*[:<] *// ; s/|/ /g;'`; do
echo $I;
omconfig system alertaction event=$I alert=true broadcast=true execappath="/usr/local/bin/om-alert.sh $I"
done 
Reference
Dell Openmanage in XenServer 7
Quick Dell OpenManage Email Alerts
Manual Reference Pages  - MAILX (1)