› Clovertech Forums › Cloverleaf › Run tcl from alert
I am trying to run a tcl from an alert.
I select tcl in the alert action
in the TCL Code box I have proc tpsFindNameSendEmail
Is this the proper way to run this?
The Guthrie Clinic
Sayre, PA
Yes. I just built one in a test site..
Here is the start of the proc I referenced:
proc send_SMTP {debug module email_to email_fr email_cc email_bc email_subject email_body table} {
package require mime
package require smtp
set module “$module.send_SMTP”
if {$debug > 1} {echo “$module email_su $email_subject”}
Here is the invocation in the Alerts file entry – tcl proc window:
send_SMTP “2” “alerts” “peterheggie@crouse.org” “dlitinterfaces@crouse.org” “” “” “tcl test subject” “tcl test email body” “Send_SMTP_Email”
After putting this in, and meeting the alert condition, I received my test email. What this tells me is:
Using echo functions sends the output to the hcimonitord.log file, although I suspect that Infor does not recommend doing this.
There are also ‘site-level’ variables that you can use in your code or passed parameters; I believe the list of these variables are in the documentation somewhere.
Peter Heggie
The tcl sends the test email from the testing tool and when I put it in a route. I cannot get it to send from the alert. I have a notify in the alert to show that the alert is firing and it is.
proc tpsSendAlertEmail { args } {
Alert Action: tcl
TCL Code: tpsSendAlertEmail
The Guthrie Clinic
Sayre, PA
ok I’m stumped, so far.. can you put some echo statements in “tpsSendAlertEmail”, just to see how far it gets? Did you store the tcl in the <site>/tclprocs folder and run “mktclindex” ? Look for the echos in ../<site>/exec/hcimonitord/hcimonitord.log
Peter Heggie
I created and saved the tcl using IDE so everything should be in the proper place.
in my actions window I have
tcl tpsSendAlertEmail
notify {}
I get this from the log
[aler:aler:ERR /0:_hcimonitord_:09/09/2020 11:26:36] Tcl error: invalid command name “tpsSendAlertEmail”
[aler:aler:WARN/0:_hcimonitord_:09/09/2020 11:26:36] Calling doActions(5, alert {{action notify} {name default.Alert_2} {type pid} {source {
[aler:aler:WARN/0:_hcimonitord_:–/–/—- –:–:–] {
[aler:aler:WARN/0:_hcimonitord_:–/–/—- –:–:–] { DAEMON hcilockmgr }
[aler:aler:WARN/0:_hcimonitord_:–/–/—- –:–:–] }
[aler:aler:WARN/0:_hcimonitord_:–/–/—- –:–:–] }} {repeatcnt 0} {message {Process hcilockmgr has been running for 35 seconds}} {gendate 1599665196} {host clovertest} {root /opt/cloverleaf/cis19.1/integrator} {site gene}})
The Guthrie Clinic
Sayre, PA
I am reaching my limit! Can you try removing ‘tcl’ from in front of the tps name?
Peter Heggie
I cannot remove that. The system puts that in when I select tcl as the alert action.
There are six actions. I am selecting tcl. Is that the correct action?
callback
exec
none
notify
tcl
The Guthrie Clinic
Sayre, PA
yes, tcl is the right action. It should work. When I tested my tcl I did not have notify{} in the window.
Peter Heggie
I took the notify out. It seems no matter what I do I get the same error.
Tcl error: invalid command name “tpsSendAlertEmail”
I am not trying to pass any variables. Just trying to get it to work.
Does the tcl show up in front of your tcl?
The Guthrie Clinic
Sayre, PA
ok so the top window in the Actions section has notify {} as the default. I change the Alert Action drop down to tcl. In the TCL Code window, I paste the invocation of my proc:
send_SMTP “2” “alerts” “peterheggie@crouse.org” “dlitinterfaces@crouse.org” “” “” “tcl test subject” “tcl test email body” “Send_SMTP_Email”
I click on the Update button. After clicking, the top window changes – the notify {} is removed, and my tcl invocation string is copied in, exactly as I pasted it in the TCL Code window below, except that it is prefixed with ‘tcl’ and then my entire invocation is enclosed in curly brackets. So it looks like this:
tcl {send_SMTP “2” “alerts” “peterheggie@crouse.org” “dlitinterfaces@crouse.org” “” “” “tcl test subject” “tcl test email body” “Send_SMTP_Email”}
Also the above parameters are delimited by quotes, but these are the ‘slanted’ quotes you see in Word, not the regular ‘straight up and down’ quotes. So I had to change the slanted quotes to straight quotes.
I did not click on any of the text icons (Append, Delete, Cut, Copy, Paste) and I did not click on the Advanced button.
I clicked on the plus sign in the Trigger window to create the rule, and then clicked Save on the File menu.
The alert is setup on a thread status down. I recycled the Monitor daemon and received the email.
Peter Heggie
Hi Gene,
Here is another way of doing this (run your script as a command instead of Tcl)
Good luck.
I finally got it to work.
Since I have
proc emailAlert { args } {
in my tcl I had to set the action to
emailAlert “ARG1 six”
to pass in an arg.
Thank you for your time.
The Guthrie Clinic
Sayre, PA