I should create two actions, first for CLI command, second for sending mail with %%result%% in message body.
I used this setting:
config system automation-action edit "get_config_errors" set action-type cli-script set script "diagnose debug config-error-log read" next edit "send_mail_result" set action-type email set email-from "***" set email-to "***" set email-subject "command output" set message "%%result%%" next end
# LogID 32009 = FortiGate Start config system automation-trigger edit "Start" set event-type event-log set logid 32009 next end
config system automation-stitch edit "send_config_errors_upon_start" set trigger "Start" config actions edit 1 set action "get_config_errors" set required enable set delay 5 next edit 2 set action "send_mail_result" set required enable next end next end
But when I test this automation (using one time schedule) I receive e-mail (two e-mails, there are two FortiGates in HA cluster) with body "%%result%%" verbatim, there is no command output.
By the way, it is message, not email-body (at least in 7.2.5).
The missing s (result vs results) was the only issue.
*** (send_mail_result) # set ? description Description. action-type Action type. email-to Email addresses. email-from Email sender name. email-subject Email subject. minimum-interval Limit execution to no more than once in this interval (in seconds). *message Message content. *replacement-message Enable/disable replacement message.
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.