This entry was posted on Thursday, August 7th, 2008 at 4:20 pm and is filed under IBM Lotus Notes, LotusScript, Show 'n Tell Thursday. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
BizzyBee’s BizzyThoughts
Think Outside The Hive - About Notes and Web
Check if an agent is currently running

I needed a way to see if an agent is running. To my knowledge, there’s no such thing possible with “normal” Notes-programming (is there such thing is normal programming in Notes?).
Collegue Jo Van Eynde (all credits go to him) came with the idea of sending a console command and capturing the output the console returns. Brilliant!
If the agent manager isn’t doing anything, it’s just idle, otherwise it returns something like Running agent ‘x’. Once you know that, it gets really simple.
Here’s the code:
Sub Click(Source As Button) Dim ConsoleReturn As String Dim StringToFind As String Dim AgentName As String Dim session As New NotesSession ‘Specify the server to check ConsoleReturn = session.SendConsoleCommand(“<Servername>”,“sh ta”) ‘Specify the agent to check AgentName=“<AgentToCheck>” StringToFind=“Running agent ‘”+AgentName+“‘” Dim array1(0) As String Dim array2(0) As String Dim array3(0) As String Dim ret As Variant array1(0) =ConsoleReturn array2(0) = StringToFind array3(0) = “” ret = Replace(array1, array2, array3) If ret(0)<>consoleReturn Then Msgbox |Agent “|+agentName+|” RUNS!|,64,“Check Agent” Else Msgbox |Agent “|+agentName+|” DOESN’T run!|,64,“Check Agent” End If End Sub
The only thing I don’t check in my code, is the database name, so you if your agents have the same name across different databases, it might be another agent in another database that is running (instead of the one you wanted to check).
Articles
Da Honey Pot
About me

August 7th, 2008 at 4:48 pm
This is what CodeLock is for, y’know.
http://www.lotus911.com/nathan/escape.nsf/d6plinks/NTFN-7H3UVQ
August 7th, 2008 at 5:06 pm
Just to be clear… Jo’s solution is completely awesome.
August 7th, 2008 at 9:53 pm
Please be gentle with this simple Domino Admin, but is the agent signed by server or by someone that is permitted to run console commands?
August 8th, 2008 at 9:45 am
@Nathan: I didn’t know about the codelock. I didn’t read your article in-depth, thanks pointing to an alternative!
@Gregg: the person who runs the script should have permission to run console commands (if not, he would get an “You’re not authorized to look at me” prompt.