Home

Keebler/Blog

« Be a computer scientist without the years (of hell)
‘Scrubs’ Season 8 Premiere LIVEBLOG »

.NET: Monitoring Windows processes from ASPX webpage

I was recently working on some ScribbleLive features that require asynchronous processes to be running in the background on Windows. Since I want to make sure they keep running, I wanted Pingdom to be able to monitor (and alert) on them.

I was happy to find that in .NET, a web application can access the processes running on the host server. I whipped up this little bit of C# (which will be on an ASPX page) to check for the processes, and report if they are “UP” or “DOWN”. Pingdom will then check for the word “DOWN” on a request to the page and let me know if it finds one.

Here are the using statements that you have to have for this code to run:

using System.Diagnostics;
using System.Collections.ObjectModel;

Then here’s the bulk of it:

Collection<string> RunningProcesses = new Collection<string>();
RunningProcesses.Add( "Program1" );
RunningProcesses.Add( "Program2" );

Response.ContentType = "text/plain";

foreach ( Process proc in Process.GetProcesses() )
{
    if ( RunningProcesses.Contains( proc.ProcessName ) )
    {
        Response.Write( proc.ProcessName + ": UP" + System.Environment.NewLine );
        RunningProcesses.Remove( proc.ProcessName );
    }
}

foreach ( string s in RunningProcesses )
{
    Response.Write( s + ": DOWN" + System.Environment.NewLine );
}

When I have a bit more time, I’m going to add a call to Process.Start(…) to restart and processes that have gone down. You know, at some point this code will probably make me unnecessary :)

Tags: .net, ASPX, processes, Windows

Related Posts

  • Adding SL to Windows Web App G…
  • Improving Response Times

This entry was posted on Saturday, January 3rd, 2009 at 11:40 am and is filed under My Releases, Software, Web Development. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.

  • Blog Home

  • Tags

    90210 alessandra ambrosio animals asp.net audrina patridge battlestar galactica bikini bunny bush C# canada canada election ctv ctvglobemedia development Election Entertainment/Celebrity facebook Gordon Ramsay gorilla gossip girl hayden panettiere iphone last.fm liveblog liveblogging mesh08 muchmusic Music obama palin rachel bilson scribblelive shenae grimes subway telemarketers the hills the killers the office toronto ttc toronto tv us election video yeah yeah yeahs

    WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

  • Recent Posts

    • Got tickets for USA vs. Switze…
    • On my way to YYZ to fly to the…
    • RT @scribblelive: Financial Po…
    • In Olympic Skelton, Canadian M…
    • Hoping people keep putting pre…
  • Categories

    • Election
    • Entertainment/Celebrity
    • Fake News
    • Featured
    • Funny
    • Keebler/Show
    • Music
    • My Releases
    • On-the-Road
    • RedDot
    • Reviews
    • Science/Technology
    • ScribbleLive
    • Security
    • Software
    • Torrent Live Stats
    • Tweets
    • Uncategorized
    • Web Development
  • Blogroll

    • Kitten-Monkey’s Cell
    • :: kattekylling ::
    • Adam Finley
    • blog-j
    • fuzzz.gaulin.ca
    • Idiot Banter
    • mad.greyarea.com
    • ob.blog
    • PollyPrissyPants
    • RedDot CMS Users Google Group
    • ScribbleLive Official Blog
  • My Sites

    • Flickr2Facebook
    • RedDot CMS
    • ScribbleLive
    • Where are my f(acebook)ing friends?
    • WhyYouShould