HealthCheck on Exchnage Server 2007
Hi Team
i doing the health check on daily basis by running the scripts which is gievn below link. It working fine without any issue.
http://gallery.technet.microsoft.com/scriptcenter/693762cc-e214-4bd9-b8c4-5685c0b2319f
but i'ts only monitoring the Microsfot Exchange server services alone. Am ok with the above script as am having one Single Mailbox server in ex 2007
I would like to run the same kind scritpt which should monitor the all the services which are all running in automatic Statup type
Eg : in CCR / SCC . if the cluster service is down. Will the above script send the email ,saying the "Cluster Service is not running on the Server"
How do i check the cluster service in CCR / SCC and any other important service (automatic) to send the out the email if the Automcatic service are down.
Hope you all understand and Thanks in advance
ramakrishnan
December 15th, 2011 11:17am
On Thu, 15 Dec 2011 16:10:25 +0000, rush2ramki wrote:
>i doing the health check on daily basis by running the scripts which is gievn below link. It working fine without any issue.
>
>http://gallery.technet.microsoft.com/scriptcenter/693762cc-e214-4bd9-b8c4-5685c0b2319f
>
>but i'ts only monitoring the Microsfot Exchange server services alone. Am ok with the above script as am having one Single Mailbox server in ex 2007
>
>I would like to run the same kind scritpt which should monitor the all the services which are all running in automatic Statup type
>
>Eg : in CCR / SCC . if the cluster service is down. Will the above script send the email ,saying the "Cluster Service is not running on the Server"
>
>How do i check the cluster service in CCR / SCC and any other important service (automatic) to send the out the email if the Automcatic service are down.
>
>Hope you all understand and Thanks in advance
The script can be modified to check the status of any service. Start
by having a look at the "get-service" cmdlet.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 15th, 2011 11:59am
JFYI:
Checking exchange services on local server:
test-servicehealth
For remote server:
test-servicehealth -server servername
Thanks & Regards, Kottees **** Please mark as an answer if it is really helps you.
December 15th, 2011 1:17pm
HI Rich
Get-Service can all the services which are all running in the Servers, and good for this scripts which replace Test-ServiceHeath
but
When the try to run the same scritpt with out anthing modifed in CCR
i got the Below Error
Unexpected token 'Exchange' in expression or Statement
at C:\Healthcheck.PS1:50 Char:21
+ $subject = "Exchange <<<< Server Status"
As you Iam not good in scripting ...What is the Error refers to
When i run the same script , and works well in Single Mailbox Server (NO CCR)
Please suggest
ramakrishnan
Free Windows Admin Tool Kit Click here and download it now
December 16th, 2011 10:03pm
On Sat, 17 Dec 2011 02:56:45 +0000, rush2ramki wrote:
>
>
>HI Rich
>
>Get-Service can all the services which are all running in the Servers, and good for this scripts which replace Test-ServiceHeath
>
>but
>
>When the try to run the same scritpt with out anthing modifed in CCR
>
>i got the Below Error
>
>Unexpected token 'Exchange' in expression or Statement
>
>at C:\Healthcheck.PS1:50 Char:21
>
>+ $subject = "Exchange <<<< Server Status"
>
>As you Iam not good in scripting ...What is the Error refers to
>
>When i run the same script , and works well in Single Mailbox Server (NO CCR)
>
>Please suggest
Regardless of the server type the same code is executed each time.
The line (50) in the script is just a simple assignment:
$subject = "Exchange servers status"
For "Exchange" to be seen as a separate token (instead part of a
string literal) it would seem to me that you're missing a terminating
'"' on some other string literal.
If you run the script from some other machine and it works, try
running the script with the name of the CCR server as a parameter from
the same machine.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
December 16th, 2011 10:22pm
Hi Rich
I ran the same script in HUB Transport server without madification expect the send email
got the same error as i mentioned in aboveramakrishnan
Free Windows Admin Tool Kit Click here and download it now
December 17th, 2011 1:27am
Hi Rich
All i want is , i would like to just monitoring the cluster service in the CCR or SCC servers
if the Cluster service failed , it would trigger the email to me as admin.
that'
that is enough for me
ramakrishnan
December 17th, 2011 1:32am
Hi Rich
Now the below Script is working and sending the email with wrong info ( i did mistake some where below)
i changed the below line from the orginal script and rest of the script is original
"$o1=Get-Service | Where {$_.Name -match "Clu"}
NO ERROR while running the below script , but i received the email saying that
PROBLEM FOUND WITh SERVICES on SERVER NAME with these Server roles ClientAccess , HubTransport is Not Running
PROBLEM FOUND WITh SERVICES on SERVER NAME with these server roles MAILBOX Running
1. it is not showing service name which is nit running
2. Eventhough all the services are running , I received the email saying
"PROBLEM FOUND WITh SERVICES on SERVER NAME with these Server roles ClientAccess , HubTransport is Not Running
PROBLEM FOUND WITh SERVICES on SERVER NAME with these server roles MAILBOX Running"
3. If the Cluster Services are down, how can i get the get saying the Cluster services are down .
What i did wrong in the below script.
########################################################################################
#Date:25 Oct 2010
#Script:Checkexhealth.ps1
#Description:Check services on Exchange servers and check Queue status of transport servers
#Sends out an email if it finds some issue
#
#
#
########################################################################################
$probfound=""
Function docheck ($a)
{
clear
Write-host ""
Write-host "Server Name:" $a.name -ForegroundColor Yellow
Write-host "Server Role:" $a.ServerRole -ForegroundColor Green
Write-Host "Running service health Check"
$o1=Get-Service | Where {$_.Name -match "Clu"}
if ($o1 -ne $null)
{
$script:probfound += "<TR bgcolor=cyan><TD><p align=center> Problem Found with services on <b>" + $a.Name + " </b> with these server roles <i>" + $a.serverrole + ".</i> </TD></TR>"
$script:probfound += "<TR><TD><p align=center><font size=2 color=red ><i>" + $($o1.servicesnotrunning ) + " </i> </font>is not running.</TD><TR>"
}
if ($a.IsHubTransportServer -eq $true)
{
Write-Host "Getting Queue (Queues in Retry state) Info.."
$o2=Get-Queue -Server $a.Name -filter {status -eq "retry"} -ResultSize unlimited
if ($o2 -ne $null)
{
$script:probfound+= "<TR bgcolor=cyan><TD><p align=center>" + "Problem Found with <b>" + $a.Name + " </b> with these Queues in Retry State. </TD></TR>"
foreach ($q in $o2)
{
$script:probfound+= "<TR><TD><p align=center>" + $($q.identity.toString()) + " with next hop domain " + $($q.nexthopdomain.tostring()) + "<font size =2 color=red> (" +
$q.messagecount + ")</font><br></TD></TR>"
}
}
}
}
Function emailsend
{
$probfoundhead="<HTML><BODY><TABLE align=center cellspacing=0 bordercolor=black border=1>"
$emailFrom = "admin@labwinner.co.in"
$emailTo = "ram@labwinner.co.in"
$subject = "Exchange servers status"
$script:probfound+="</Table></Body></HTML>"
$body = $probfoundhead + $script:probfound
$smtpServer = "LWE2k7.labwinner.co.in"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg = New-Object Net.Mail.MailMessage($emailFrom, $emailTo, $subject, $body.ToString())
$msg.IsBodyHTML = $true
$smtp.Send($msg)
}
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
if ($($args.count) -ne 0)
{
$standalonever=$true
foreach ($svr in $args)
{
docheck (get-ExchangeServer $svr)
}
}
else
{
foreach ($a2 in (get-exchangeserver))
{
docheck $a2
}
}
if ($probfound.Length -ne 0)
{
if ($standalonever -ne $true)
{
emailsend
}
else
{
$probhtml="<HTML><BODY><TABLE align=center cellspacing=0 bordercolor=black border=1>" + $probfound + "</Table></Body></HTML>"
$probhtml|out-file exchangeservicehealth.htm
invoke-expression .\exchangeservicehealth.htm
}
}
else
{
Write-Host "All is well :)"
}ramakrishnan
Free Windows Admin Tool Kit Click here and download it now
December 17th, 2011 5:38am
On Sat, 17 Dec 2011 10:31:16 +0000, rush2ramki wrote:
>Now the below Script is working and sending the email with wrong info ( i did mistake some where below)
>
>i changed the below line from the orginal script and rest of the script is original
>
>"$o1=Get-Service | Where {$_.Name -match "Clu"}
The result is $o1 has a list of all the services that match the string
"clu". The original script only populated that variable if a required
service wasn't running.
If you want to see if the service is in any state *except* "running"
then your test should look something like this:
############################
$ServicesToCheck = @('alerter','mr2kserv')
$o1 = ""|select servicesnotrunning
$o1.servicesnotrunning = @()
$ServicesToCheck | foreach{
if ( (get-service $_).status -ne 'running' )
{
$o1.servicesnotrunning += $_
}
}
if ($o1.count -gt 0)
############################
Replace these lines:
$o1=Test-ServiceHealth $a.name|where {$_.requiredservicesrunning -eq
$false}
if ($o1 -ne $null)
With the stuff between the "rows of ####" and you'll be testing for
your own set of services.
Replace the contents of the $ServicesToCheck array with whatever set
of services you want to check.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
December 17th, 2011 5:04pm
On Sat, 17 Dec 2011 21:57:14 +0000, Rich Matheisen [MVP] wrote:
[ snip ]
That last line should be:
if ($o1.servicesnotrunning.count -gt 0)
Sorry.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 17th, 2011 7:24pm
Hi...rich
Now it is tottally confused and as i an not good in scripting
i request you to modify the stuff's to run the script better.
ramakrishnan
December 17th, 2011 11:36pm
On Sun, 18 Dec 2011 04:29:47 +0000, rush2ramki wrote:
>
>
>Hi...rich
>
>Now it is tottally confused and as i an not good in scripting i request you to modify the stuff's to run the script better.
Sorry, I'm not going to rewrite the script.
If you're interested in monitoring your environment you can use SCOM.
If you just want to monitor services, have a look at "Servers Alive!"
or find a script already written to do what you want instead of trying
to modify one that was written to do something else.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
December 17th, 2011 11:41pm
Hello,
To monitor all the services in Windows, you may create a new thread to Windows Forum and I believe it may be available in Power shell:
http://social.technet.microsoft.com/Forums/en/winserverpowershell/threads
Thanks,
Simon
December 18th, 2011 11:57am
Thanks Simon
i did post in the above link
ramakrishnan
Free Windows Admin Tool Kit Click here and download it now
December 23rd, 2011 10:03am