views:

5624

answers:

2

I'm trying to setup an alert to let me know via email (SMTP) when free disk space on one of my servers is less than a specified value. To do this I'm using PerfMon alerts, as described at MSFT Technet. I have the alert working and writing to the system log, but when I try to set it to 'Run Program' it fails. The log alert fires but the program fails.

The program I'm using is a small C# app I wrote to send an smtp email. I have tested the app independently from this server, running it manually and it works fine, without any user interaction (console app). But when I have it set to run via the alert trigger it fails.

Thanks, Bryan

+1  A: 

Could it be that you have no command line arguments for your program? I found the following on http://support.microsoft.com/kb/324752/en-us

When an alert occurs, the service creates a process and runs the specified command file. The service also copies any command-line arguments you define to the command line that is used to run the file. Click Command Line Arguments, and then click to select the appropriate check boxes to include the arguments that you want when the program is run.

Note You must select at least one command-line argument or the program will not run. (This is true regardless of what program you have selected.)

Do you have some kind if exception handling/logging in your C# app? Do you get anything from it?

Could you put your C# app call in a batch file and start that from the alert? If you add something like

echo %date% %time% > log.txt

at the start of your batch file you could see if it started at all.

Guge
Thanks, it was the command line argument. I have to remember to read the fine print. Works great now. Thanks much!
+1  A: 

Did you set the Run As field in the alert properties? If not, your program is being run as a LocalService, which does not have network access (among other things).

Try setting it to a user account under which you were able to verify that your program works correctly.

atzz

related questions