所有Dell伺服器都配有Dell OpenManage Server Administrator軟體,該軟體能夠監視和顯示系統級指示燈。此外,透過警報管理選項卡,您可以配置在觸發警報時執行的操作。不幸的是,沒有一個工具可以對所有事件應用統一的通知,因此我們將提供一個指令碼,它將配置所有警報操作,以傳送一封電子郵件通知您相應的事件。雖然您可以手動設定這些,但擁有一個指令碼非常理想,因為您可以輕鬆地跨多個...
所有Dell伺服器都配有Dell OpenManage Server Administrator軟體,該軟體能夠監視和顯示系統級指示燈。此外,透過警報管理選項卡,您可以配置在觸發警報時執行的操作。不幸的是,沒有一個工具可以對所有事件應用統一的通知,因此我們將提供一個指令碼,它將配置所有警報操作,以傳送一封電子郵件通知您相應的事件。雖然您可以手動設定這些,但擁有一個指令碼非常理想,因為您可以輕鬆地跨多個伺服器部署它。
工作原理
劇本很簡單。有一個setup命令,將每個警報設定為“執行應用程式”,應用程式本身就是指令碼。當指令碼執行時,它只生成一封電子郵件(透過使用Blat工具),其中包含計算機名、日期、時間和觸發的警報。
在執行指令碼之前:
指令碼執行後:
所有警報都使用電子郵件通知指令碼:
要求
當然,您需要安裝Dell OpenManage Server Assistant。如果您的系統未提供此軟體,則可透過Dell的支援站點下載。
此外,您需要在系統上配置Blat,一個命令列電子郵件程式。要配置Blat,只需下載二進位制檔案並提取它們(共3個:blat.exe檔案, blat.dll, blat.lib檔案)到系統路徑變數中的某個位置,例如Windowssystem32資料夾。然後從命令列執行:
blat -install my.mailserver.com [email protected]
適當更換郵件伺服器和發件人電子郵件地址。在大多數情況下,您只需要執行這個命令,但是如果您的伺服器有特殊的配置(備用埠等),您可以在Blat的網站上看到完整的安裝選項。
電子郵件警報通知設定
一旦有了這些需求,就可以使用指令碼了。編輯指令碼以包含要通知的電子郵件地址(“ToEmail”變數)。如果您的伺服器需要身份驗證才能中繼,則必須將這些引數新增到指令碼中記錄的Blat命令中。
要設定Server Assistant警報以使用指令碼,只需執行安裝程式:
DellAlert /setup
確認要將此指令碼用作警報操作,並且您已全部設定好。作為設定的一部分,會觸發一個示例警報,這樣您就可以確保電子郵件到達了預期的收件人。
劇本
@ECHO OFF TITLE Dell Hardware Email Alert ECHO Dell Hardware Email Alert ECHO Written by: Jason Faulkner ECHO SysadminGeek.com ECHO. ECHO. REM Sends email alerts when Dell hardware warnings are triggered. REM This script should _not_ be in a path which contains spaces. REM REM Usage: REM DellAlert {/SETUP | Alert message} REM /SETUP Configure Dell Server Assistant to use this script for alerts. REM Alert Message REM Message to send. REM REM Requires: REM Blat : (command line emailer) is configured and working on the current system. REM If your email server requires authentication to relay, see comments below. REM Email address(es) to send alerts to (comma separated) SET
[email protected] SETLOCAL EnableExtensi*** IF /I {%1}=={/SETUP} GOTO Setup IF NOT {%1}=={} GOTO Alert GOTO End :Alert SET Log="%TEMP%DellAlert.txt" DATE /T > %Log% TIME /T >> %Log% ECHO Dell Alert Tripped! >> %Log% ECHO %* >> %Log% REM If your email server requires autentication to relay, REM add the following to the end of the line below: REM -u UserName -pw Password BLAT %Log% -to %ToEmail% -subject "%ComputerName% Hardware Alert" IF EXIST %Log% DEL /F /Q %Log% GOTO End :Setup ECHO This will replace all the current Dell Server Assistant alerts with a call ECHO to this script. To confirm you want to continue, enter YES (case sensitive). SET /P Confirm= IF NOT {%Confirm%}=={YES} GOTO End SET ScriptPath=%~dpnx0 ECHO Configuring alerts to use: %ScriptPath% omconfig system alertaction event=powersupply execappath="%ScriptPath% power supply failure" omconfig system alertaction event=powersupplywarn execappath="%ScriptPath% power supply warning" omconfig system alertaction event=tempwarn execappath="%ScriptPath% temperature warning" omconfig system alertaction event=tempfail execappath="%ScriptPath% temperature failure" omconfig system alertaction event=fanwarn execappath="%ScriptPath% fan speed warning" omconfig system alertaction event=fanfail execappath="%ScriptPath% fan speed failure" omconfig system alertaction event=voltwarn execappath="%ScriptPath% voltage warning" omconfig system alertaction event=voltfail execappath="%ScriptPath% voltage failure" omconfig system alertaction event=intrusion execappath="%ScriptPath% chassis intrusion" omconfig system alertaction event=redundegrad execappath="%ScriptPath% redundancy degraded" omconfig system alertaction event=redunlost execappath="%ScriptPath% redundancy lost" omconfig system alertaction event=memprefail execappath="%ScriptPath% memory pre-failure" omconfig system alertaction event=memfail execappath="%ScriptPath% memory failure" omconfig system alertaction event=hardwarelogwarn execappath="%ScriptPath% hardware log warning" omconfig system alertaction event=hardwarelogfull execappath="%ScriptPath% hardware log full" omconfig system alertaction event=processorwarn execappath="%ScriptPath% processor warning" omconfig system alertaction event=processorfail execappath="%ScriptPath% processor failure" omconfig system alertaction event=watchdogasr execappath="%ScriptPath% watchdog asr" omconfig system alertaction event=batterywarn execappath="%ScriptPath% battery warning" omconfig system alertaction event=batteryfail execappath="%ScriptPath% battery failure" omconfig system alertaction event=systempowerwarn execappath="%ScriptPath% system power warning" omconfig system alertaction event=systempowerfail execappath="%ScriptPath% system power failure" omconfig system alertaction event=storagesyswarn execappath="%ScriptPath% storage system warning" omconfig system alertaction event=storagesysfail execappath="%ScriptPath% storage system failure" omconfig system alertaction event=storagectrlwarn execappath="%ScriptPath% storage controller warning" omconfig system alertaction event=storagectrlfail execappath="%ScriptPath% storage controller failure" omconfig system alertaction event=pdiskwarn execappath="%ScriptPath% physical disk warning" omconfig system alertaction event=pdiskfail execappath="%ScriptPath% physical disk failure" omconfig system alertaction event=vdiskwarn execappath="%ScriptPath% virtual disk warning" omconfig system alertaction event=vdiskfail execappath="%ScriptPath% virtual disk failure" omconfig system alertaction event=enclosurewarn execappath="%ScriptPath% enclosure warning" omconfig system alertaction event=enclosurefail execappath="%ScriptPath% enclosure failure" omconfig system alertaction event=storagectrlbatterywarn execappath="%ScriptPath% storage controller battery warning" omconfig system alertaction event=storagectrlbatteryfail execappath="%ScriptPath% storage controller battery failure" ECHO. ECHO Sending sample alert to: ECHO %ToEmail% CALL :Alert Testing Dell hardware alert warnings... ECHO. PAUSE GOTO End :End ENDLOCAL
指令碼修改/維護
所提供指令碼中的事件警報來自我們的一臺Dell伺服器。根據您的Dell伺服器硬體和server Assistant版本,警報可能會有所不同。通常,您可以在執行安裝指令碼時判斷事件是否對伺服器無效(例如,如果您沒有Dell RAID控制器),因為某些儲存事件建立專案將失敗。
以上指令碼中的事件觸發器是透過從命令提示符執行以下命令獲得的:
omconfig system alertaction /?
此命令列出所有事件關鍵字以及相應警報的說明。要新增其他警報,請執行上面的命令並將缺少的條目新增到指令碼的設定部分,然後使用/setup開關重新執行指令碼。
連結
從下載Dell伺服器電子郵件警報腳本系統管理員網站
下載Blat命令列Emailer
Dell支援站點