Service Status Email Notification

Posted by: Uomo Del Ghiaccio

Service Status Email Notification - 02/06/08 11:42 AM

It would be nice to have thae ability to set some administration email status notifications in the event that a critical service fails.

This would primarily be for services that control the inputs such as telnet, lpd or ftp.

If a installation uses let's say telnet to receive data, then have a setting that will send an email if the telnet service is not running.

This could be polled at a predetermined amount of time and then have a method to configure what services to monitor and the email addresses to send the notice to.

Posted by: Philippe F.

Re: Service Status Email Notification - 02/06/08 12:55 PM

You can already implement this functionality fairly easily. Create a process that runs at whatever interval of time you prefer. In that process, insert a "Run External Program" task.

I'd recommend calling a good old batch file (.bat or .cmd) that would contain something like:
@Echo off
Echo LPR Service > C:\Services.txt
sc query pplpr6 | find /i /c "state" >> C:Services.txt
Echo Telnet Service >> C:\Services.txt
sc query pptelnet6 | find /i /c "state" >> C:Services.txt
(The first call to SC checks the status of the LPR service while the second one checks the Telnet service)
After this task, the file Services.txt would contain something similar to this:
LPR Service
        STATE              : 1  STOPPED
Telnet Service 
        STATE              : 4  RUNNING
You could then add a Folder Capture input to pick up the Services.txt file and process it according to your needs just like any other data file. (Which means you could send notification emails whenever you find the "STOPPED" status).

The good thing about this technique is that you aren't limited to just the PPSuite services. You can poll the status of any Windows Service with it.

Hope that helps,
Posted by: Uomo Del Ghiaccio

Re: Service Status Email Notification - 02/06/08 01:35 PM


I was thinking about it and wrote this small script to use inside of PlanetPress Watch.


Option explicit
Dim objFSO
Dim objOutputFile
Dim strTempName, strTempPath, strLine
Dim objHeaderFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTempPath = objFSO.GetFile(PW_GetJobFilename).ParentFolder.Path
strTempName = objFSO.GetTempName
Set objOutputFile = objFSO.GetFolder(strTempPath).CreateTextFile(strTempName)
' Variable declaration for Process Gathering
Dim objWMIService, objProcess, colProcess Dim strComputer, strList

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process")

' Main Loop

For Each objProcess in colProcess
    if objProcess.Name = "TelnetService.exe" then
       strList = strList & vbCrlf & objProcess.Name & " is running = TRUE"
    end if


' Finalize
objFSO.DeleteFile PW_GetJobFilename, true objFSO.MoveFile strTempPath & "\" & strTempName, PW_GetJobFileName

This works, but it still would be nice to have it built into a future version.