Service Monitoring Software for Servers

pkt1237

Weaksauce
Joined
Jul 3, 2008
Messages
84
Not sure if this is the right place to ask but, at our company we have some software that has a few services running on the server that periodically shut off and we are working with a company to get it resolved but in the meantime we go in and manually restart the service and we were looking for some software that would send us notifications that the service in question went down. In my search for such programs I came across one called PA Server Monitor and was curious if anyone had any experience with this software and if so what are your thoughts about it. I'll try and explain better if needed but basically looking for some software to monitor services running on our servers and if it turns off would like it to send us either sms or email notification so we can log in and restart the service
 
Operations Manager from Microsoft will do it, but it comes with a hefty learning curve.

If you want something simple (quick and dirty), you could write a batch file and attach it to the service on the recovery tab. The script could do whatever you wanted....
 
Or a simple powershell command will list the status of the service on the remote server

get-service -computername xxxxx yyyyy

xxx is the computer name of the server to be queried
yyy is the name of the service you want queried
 
Log forwarding also. Basically, log files from whatever server you want can be transferred to another for easy viewing.
 
interesting I'll have to look into doing some powershell scripting or batch files haven't worked much with powershell but was also seeing if there was a way to have the server notify us that the service went down just more so to pull some log errors to give to the company for further testing. I know we are waiting on some new equipment to upgrade our datacenter and supposedly when we update the software to the newest version the issue seems to go away but we won't upgrade until we get the new equipment for some reason.
 
well with powershell you can also send email so you can set it to trigger an email when the service goes down

here is an example of the syntax to send email via ps

send-mailmessage -to xxxxxx -from zzzzzz -subject "lala" -body "yada" -smtpserver yy.yy.yyy.yyy

one way would be to set a scheduled task to check the service on the servers and when it goes down it triggers the mail ps script

or on a station you can loop a script to check remotely the service status and also trigger an email if you want

I'll try to make a bit of time and see if i can put together a complete script for you.
 
Ah man that would be awesome, I greatly appreciate the help with this we were looking at spending some cash on some software but if we can save the money that would be even better in my opinion especially if it can be done with some scripting. Thanks again for the help and input.
 
Ok here it is:

prerequisites:
on the server you'll need powershell 2.0 (get it from MS)
ps execution policy should be set to unrestricted (running as admin in the ps console type: set-executionpolicy unrestricted)
mail server that will accept mail from this server

make a folder c:\xxxxxx
in the folder a file named xxxx.ps1

here is script to put in the file:

$serviceName = "xxxx";
$serviceStatus = (get-service -computer 127.0.0.1 "$serviceName").Status;

if ($serviceStatus -eq "Running") {
write-host "Service is Running";
}
else {
write-host "Service is $serviceStatus";
send-mailmessage -to xxxxxxxx -from xxxxxxxx -subject "Service Status" -body "Service is $serviceStatus" -smtpserver xxx.xxx.xxx.xxx;
}



ofcourse replace the xxxx with the apropriate information (service name; email addresses, mail server address)

then make a scheduled task to run every 5 min or however often you want it to
in the task scheduler the command to start the script is:
powershell.exe c:\xxxxxx\xxxx.ps1
do not put spaces in the path (there is a way to make it work with spaces if you want)

If you need further info or customisation please ask
 
Awesome, will give this a shot thank you again for all the help. Definitely learning more about powershell will see if boss approves some additionaly training for me in the near future in how to manage our servers etc now that Im slowly getting into more of a server admin role and out of helpdesk 24X7.
 
Quick question with that script if I wanted more than one email address for it to be sent to would i use a comma or a semi-colon to separate the addresses
 
I think a ; should do

You can also add a -Cc xxxxxx or you should also be able to send it to a mail group

anyway i'll test it tomorow and let you know
 
Ive tested it to make it do a sms message by putting in [email protected] as the email to send to since we use AT&T at least for me and another teammate and it worked for us that way which is pretty sweet will see about testing another email in the to field if not then could always add it as a CC which would work just as well.
 
glad to hear it's running ok for you,

btw if you'll notice in the script i put a -computer 127.0.0.1

if you change the local 127 address with the server's ip or name you can also run this script from a station to check on the server remotely

of course the script should run on the remote machine under an account with enough privileges to access the server's services.
 
Ah yeah right now its just running on the server itself under our admin account if need be I'm sure i could relocate it to our backup server and run in under that admin account as it has high enough privileges on all our servers to do snap shots of open files and other things backup exec needs to do
 
Just for fun here is a version to check multiple services:

$services = 'xxxxx' , 'xxxxx';
foreach ($serviceName in $services)
{
write-host "Verify $serviceName";
$serviceStatus = (get-service -computer 127.0.0.1 "$serviceName").Status;

if ($serviceStatus -eq "Running") {
write-host "$serviceName is Running";
}
else {
write-host "$serviceName is $serviceStatus";
send-mailmessage -to xxxxxx -from xxxxxxx -subject "Service Status" -body "$serviceName is $serviceStatus" -smtpserver xxxxxxxx;
}
}


I can also make it to check multiple services on multiple computers/servers if you need it :)
 
I dig the multiple service one now i should be able to combine the two files i modified into a single script. When I was setting it up turns out that there are 2 service that are kinda tied together that needed to be monitored. Its like you read my mind or something. Thanks so much for taking the time and helping with this you guys have helped me out a lot.
 
We finally got to try testing it out with the setup as a scheduled task part and I seem to be having an issue with it actually running the script as a scheduled task. I put in the run part powershell.exe C:\xxxx\xxxx.ps1 but it doesn't seem to run the script is there maybe something im missing I also have under the advanced proprieties had it start at 11:20am and run every 10min for 23hrs 59min to have it that way it will start fresh again the next day is there maybe something im missing with this part that would cause it not to execute the script?
 
Could you check on that machine the powershell execution policy

open a ps console and type:

get-executionpolicy

what does it say?

------------

also in the C:\xxxx\xxxx.ps1 path do you have any spaces? that will cause issues
 
Last edited:
execution policy is set to unrestricted, and with the path there is no spaces. If i take the run command in the scheduled task and put it in the start->run area it executes just fine. My thinking was maybe security issue so I made sure our Domain admin account that was signed in to the server had full security rights even though it should be part of the admin group on the pc and am waiting to give it another test.
 
nevermind I got it working thanks for the help. Sorry to waste your time looks like adding the domain admin account to have full security worked.
 
np glad you got it figured out :)

do let me know if you want any modifications to the script, or need other scripts :)
 
Last edited:
Back
Top