I am still very new to scripting and I have been tasked with creating a script that sends an email following an Dell openmanage event (processor failure, temperature warning etc etc etc). So far the company already has a set of scripts to do this. However, they want all those scripts (and there is one for each event) streamlined and collated into just one script that does everything. Is there a way to do this is a batch file? Maybe through the event viewer and task scheduler. I am working with server 2008. I have included 3 of the individual scripts below if you guys would like to take a look.
Code: Select all
@ECHO OFF
SET OPENMANAGEALERT=Temperature Warning
FOR /F %%A IN ('TYPE "D:\OpenManage-Alerts\hostname.ini"') DO (SET SUBJECT_HOSTNAME=%%A)
FOR /F %%B IN ('TYPE "D:\OpenManage-Alerts\smtp-server.ini"') DO (SET BMAIL_SERVER=%%B)
FOR /F %%C IN ('TYPE "D:\OpenManage-Alerts\smtp-port.ini"') DO (SET BMAIL_PORT=%%C)
FOR /F %%D IN ('TYPE "D:\OpenManage-Alerts\to.ini"') DO (SET BMAIL_TO=%%D)
FOR /F %%E IN ('TYPE "D:\OpenManage-Alerts\from.ini"') DO (SET BMAIL_FROM=%%E)
SET BMAIL_SUBJECT="[OpenManage] %SUBJECT_HOSTNAME% %OPENMANAGEALERT%"
D:\OpenManage-Alerts\bmail.exe -s %BMAIL_SERVER% -p %BMAIL_PORT% -t %BMAIL_TO% -f %BMAIL_FROM% -h -a %BMAIL_SUBJECT%
Code: Select all
@ECHO OFF
SET OPENMANAGEALERT=Processor Warning
FOR /F %%A IN ('TYPE "D:\OpenManage-Alerts\hostname.ini"') DO (SET SUBJECT_HOSTNAME=%%A)
FOR /F %%B IN ('TYPE "D:\OpenManage-Alerts\smtp-server.ini"') DO (SET BMAIL_SERVER=%%B)
FOR /F %%C IN ('TYPE "D:\OpenManage-Alerts\smtp-port.ini"') DO (SET BMAIL_PORT=%%C)
FOR /F %%D IN ('TYPE "D:\OpenManage-Alerts\to.ini"') DO (SET BMAIL_TO=%%D)
FOR /F %%E IN ('TYPE "D:\OpenManage-Alerts\from.ini"') DO (SET BMAIL_FROM=%%E)
SET BMAIL_SUBJECT="[OpenManage] %SUBJECT_HOSTNAME% %OPENMANAGEALERT%"
D:\OpenManage-Alerts\bmail.exe -s %BMAIL_SERVER% -p %BMAIL_PORT% -t %BMAIL_TO% -f %BMAIL_FROM% -h -a %BMAIL_SUBJECT%
Code: Select all
@ECHO OFF
SET OPENMANAGEALERT=System Power Failure
FOR /F %%A IN ('TYPE "D:\OpenManage-Alerts\hostname.ini"') DO (SET SUBJECT_HOSTNAME=%%A)
FOR /F %%B IN ('TYPE "D:\OpenManage-Alerts\smtp-server.ini"') DO (SET BMAIL_SERVER=%%B)
FOR /F %%C IN ('TYPE "D:\OpenManage-Alerts\smtp-port.ini"') DO (SET BMAIL_PORT=%%C)
FOR /F %%D IN ('TYPE "D:\OpenManage-Alerts\to.ini"') DO (SET BMAIL_TO=%%D)
FOR /F %%E IN ('TYPE "D:\OpenManage-Alerts\from.ini"') DO (SET BMAIL_FROM=%%E)
SET BMAIL_SUBJECT="[OpenManage] %SUBJECT_HOSTNAME% %OPENMANAGEALERT%"
D:\OpenManage-Alerts\bmail.exe -s %BMAIL_SERVER% -p %BMAIL_PORT% -t %BMAIL_TO% -f %BMAIL_FROM% -h -a %BMAIL_SUBJECT%
So far I am using bmail to send out an email on a per event basis (in the Dell openmanage server administrator each error event opens a specific batch file). I cant wrap my head around how to incorprate all this into one script though as surely the file paths in the Dell openmanage administrator would simply run the entire batch file and send out every single error message even if the only problems was that the temperature was too high
I would be eternally grateful for any input into this and I apologise if it seems like a noobish question but, like I said, I am very new to scripting
Thanks a lot
Dave