?
Solved

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

Posted on 2010-11-10
1
Medium Priority
?
1,726 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
r3nder earned 2000 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

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

777 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