Windows Server 2008 process monitoring and restart

Ryom

[H]ard|Gawd
Joined
Oct 11, 2006
Messages
1,854
So I've got a small issue at work. We have a server running Windows Server 2008, and one of its functions is to run job ticketing software from Zoll which accepts runs from our contracted clients. The problem is that this program tends to crash, or the owner remotes into the server under his account and creates a duplicate process which stops it from accepting new runs as well. The main problem being that this is a silent failure until we get calls from clients asking why we aren't responding.

So I need an automated way to:
  • Constantly monitor for the process 'PPDatabasesevices' to verify that it is currently running
  • Execute that program if it is not running
  • Monitor that only ONE instance of the process is loaded
  • If there is more than one, kill the duplicate process that isn't running under the administrator user
  • Send an error message/email to a domain workstation(s) if any part of this script fails

I imagine this can be done via Powershell scripting rather than relying on 3rd party tools. Anyone running a PS1 script similar to this that can share?
 
So I need an automated way to:
  • Constantly monitor for the process 'PPDatabasesevices' to verify that it is currently running
  • Execute that program if it is not running
  • Monitor that only ONE instance of the process is loaded
  • If there is more than one, kill the duplicate process that isn't running under the administrator user
  • Send an error message/email to a domain workstation(s) if any part of this script fails
I imagine this can be done via Powershell scripting rather than relying on 3rd party tools. Anyone running a PS1 script similar to this that can share?

Try searching MS'es script repository. I'd start by focusing on OS specific scripts, then do keyword searches and drill down until you find if there's anything useful. For scripts with sub-tasks, you may need to look at example code for each task, test it to ensure you understand it and it works as intended, then cobble the script together from the task specific scripts.

https://gallery.technet.microsoft.com/scriptcenter/
 
Thanks for the reply, I actually solved this in a different manner. Here's what I did;

  • Removed all startup calls and shortcuts for this program from the server (it was in the startup folder of the owners login, among other areas, which is why the process got duplicated when he logged in).
  • Grabbed SRVANY.exe from the Server 2003 Resource Kit.
  • Installed the PPDataBaseServices.exe as a system level service via SRVANY.exe and "SC CREATE". This helps to prevent duplicate instances being created since the service manager will not initialize an already running service.
  • Added two scheduled tasks; one to taskkill the process and shutdown the service at midnight, and one to restart the service at 12:01am. The program tends to hang after it's been running awhile, so this is to prevent that.
It's been running without issue since I put this process in place, since any problems will self-correct every night at midnight :ROFLMAO:
 
Sweet. Whatever works really.
I've got a script similar to what you were asking for in vbscript, but not quite one like it in PS and being honest, I don't like simply providing a full answer or doing someone else's work for them - I'd rather point people in the right direction etc.

But you got the result and that's all that matters.
...and the reskit's are incredibly useful. I still have a big combo reskit I made from old versions, updated, with lots of supplements - which is still useful to this day.
 
Now I'm attempting to unknot some bad/outdated decisions the IT consultants made when they set the server and domain up in the first place. Who the hell doesn't use GPOs for a 2008-R2 and full Win7 environment? They had printer deployment setup via logon scripts, and not via GP, but rather the win98/NT compatible kind so the printers would try to install every time someone logged in. No organizational units are setup, so I can't even deploy printers the right way at the moment. As of now I have the printer installation portion of the logon script disabled and simply have the printers listed in the directory for install semi-manually (automatic driver download/install from the sever is sweeet).

And that's just the tip of the iceberg. :eek:
 
Back
Top