Opened 8 years ago

Closed 8 years ago

#731 closed enhancement (fixed)

Send warning mails via PowerShell script under MS-Windows

Reported by: Gabriele Pohl Owned by: Christian Franke
Priority: minor Milestone: Release 6.6
Component: smartd Version: 6.5
Keywords: windows smartd.conf Cc:

Description

A smartmontools user wrote:

We use smartmontools on MS Windows computers (and of course on our Linux boxes)
because they are small, they support multi platform usage and they work just great.

The only point that we did not like too much was the use of an external
program to send email warnings (blat on Windows). That's why I changed
the file smard_warning.cmd and wrote a PowerShell script to send the warning emails.
Now, if you are interested, I would like to share my scripts with the
smartmontools dev team. If you like it - feel free to integrate it.

Attachments (5)

smartd_warning.cmd (649 bytes ) - added by Gabriele Pohl 8 years ago.
emailSender.ps1 (3.0 KB ) - added by Gabriele Pohl 8 years ago.
smartd_warning.2.cmd (5.9 KB ) - added by Christian Franke 8 years ago.
Proposed new version of smartd_warning.cmd. Runs smartd_mailer.ps1 if configured.
smartd_mailer.ps1 (2.0 KB ) - added by Christian Franke 8 years ago.
PowerShell script which sends mail via Send-MailMessage.
smartd_mailer.conf.ps1 (512 bytes ) - added by Christian Franke 8 years ago.
Sample confugration file for smartd_mailer.ps1.

Download all attachments as: .zip

Change History (8)

by Gabriele Pohl, 8 years ago

Attachment: smartd_warning.cmd added

by Gabriele Pohl, 8 years ago

Attachment: emailSender.ps1 added

comment:1 by Christian Franke, 8 years ago

Keywords: smartd.conf added; mail removed

Thanks for your contribution. Using PowerShell as an alternative to blat makes plenty of sense. This wasn't an option in the early days (2004) when email support was added to the Windows port of smartd.

Unfortunately the attached scripts are not backward compatible and break existing functionality (e.g. -m console, -m <nomailer> -M /path/to/script). Therefore these scripts cannot replace the current smartd_warning.cmd.

by Christian Franke, 8 years ago

Attachment: smartd_warning.2.cmd added

Proposed new version of smartd_warning.cmd. Runs smartd_mailer.ps1 if configured.

by Christian Franke, 8 years ago

Attachment: smartd_mailer.ps1 added

PowerShell script which sends mail via Send-MailMessage.

by Christian Franke, 8 years ago

Attachment: smartd_mailer.conf.ps1 added

Sample confugration file for smartd_mailer.ps1.

comment:2 by Christian Franke, 8 years ago

Milestone: Release 6.6
Owner: set to Christian Franke
Status: newaccepted

If possible, please test the above scripts:

  • Replace %PROGRAMFILES%/smartmontools/bin/smartd_warning.cmd with smartd_warning.2.cmd.
  • Copy smartd_mailer.ps1 and smartd_mailer.conf.ps1 to %PROGRAMFILES%/smartmontools/bin.
  • Edit %PROGRAMFILES%/smartmontools/bin/smartd_mailer.conf.ps1.
  • Run set SMARTD_ADDRESS=ADDRESS & smartd_warning.cmd --dryrun to see the parameters of the Send-MailMessage command that would be executed.
  • Run smartd service with -m ADDRESS -M test (and without -M exec ...) directive.

If smartd_mailer.conf.ps1 is not present, blat.exe is be used instead.

comment:3 by Christian Franke, 8 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.