Skip to main content
rgala
Visitor III
August 30, 2023
Solved

automation stitch to send output of an CLI command

  • August 30, 2023
  • 1 reply
  • 5190 views

Hello,

 

FortiGate with FortiOS 7.2.5.

I try to create an automation stitch that sends me output of

diagnose debug config-error-log read

command upon FortiGate start.

 

As described e.g. here

https://docs.fortinet.com/document/fortigate/7.2.5/administration-guide/639044

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.

 

Any tip what is wrong?

 

Best answer by AlexC-FTNT

It may be the variable:

 set email-body "%%results%%"

but I see you use:

 set email-body "%%result%%"

 

1 reply

AlexC-FTNT
Staff
Staff
August 30, 2023

It may be the variable:

 set email-body "%%results%%"

but I see you use:

 set email-body "%%result%%"

 

rgala
rgalaAuthor
Visitor III
August 30, 2023

Thank you very much for confirming I'm half blind.

And for saving time to find the s.

rgala
rgalaAuthor
Visitor III
August 30, 2023

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.

*** (send_mail_result) # set