Solved

How do i for monitoring a RAID with an script (VBs, powershell, batch file)?

Posted on 2010-11-10
1
1,687 Views
Last Modified: 2012-05-10
Hello,

There is a command for monitoring the status of a RAID Hardware called hpacucli.exe (C:\Program Files (x86)\Compaq\Hpacucli\Bin\hpacucli.exe)...

The output of that command is

hpacucli.exe ctrl all show status

Smart Array B110i SATA RAID in Slot 0 (Embedded)
   Controller Status: OK

I need a script that could be added as a scheduled task  to check that the array is healthy, and if not, send an email informing of it.

Thanks in advance
0
Comment
Question by:VMWARE
1 Comment
 
LVL 6

Accepted Solution

by:
r3nder earned 500 total points
ID: 34109047
Change username, Password, emails, etc - Compile this in Visual studio in a C# Windows app - just replace the code in the form with this and go to the release folder and get your exe - schedule it to run when ever - should do the trick

Thanks
R3nder
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Management;
using System.Xml;
using System.Xml.Schema;
using System.IO;
using System.Security;
using System.Runtime.InteropServices;
using System.Net.Mail;
using System.Reflection;
using System.Security.Principal;


namespace RaidTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            bool errorRedirect = false;

            string curFile = @"C:\Program Files (x86)\Compaq\Hpacucli\Bin\hpacucli.exe";
            MessageBox.Show((File.Exists(curFile) ? "Opening......" : "File does not exist"));
            if (File.Exists(curFile))
            {
                var proc = new Process();
                proc.StartInfo.FileName = "C:/Program Files (x86)/Compaq/Hpacucli/Bin/hpacucli.exe";
                proc.Start();
                proc.WaitForExit();
                proc.BeginErrorReadLine();
                
                {
                    MailToME();
                }

                var exitCode = proc.ExitCode;
                proc.Close();
                
            }
        }
        
            public void MailToME()
            {
                //create the mail message
                MailMessage mail = new MailMessage();

                //set the addresses
                mail.From = new MailAddress("MyName@mycompany.com");
                mail.To.Add("Anothername@mycompany.com");
                mail.Bcc.Add("Anothername@mycompany.com");

                //set the content
                mail.Subject = "Raid failed";
                mail.Body = "I geuss I should see what happened on:"  + DateTime.Now;
                //send the message
                SmtpClient smtp = new SmtpClient("172.0.0.1");
                smtp.Credentials = new System.Net.NetworkCredential("USER", "PASS");
                smtp.Send(mail);
                
                this.Close();
                this.Dispose();
            }
        }
    }

Open in new window

0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question