| Description | This article demonstrates using Switch Controller custom commands and Automation stitches to retrieve information from managed FortiSwitches without needing to log in to SSH locally on the FortiSwitch. |
| Scope | FortiGate managing FortiSwitch. |
| Solution |
FortiGate supports sending any FortiSwitch command to a managed FortiSwitch using the 'execute switch-controller custom-command <command> [<target-switch>]' command. See this document: Executing custom FortiSwitch scripts.
If needed, multiple FortiSwitch commands can be executed in the same FortiOS custom-command by separating with '%0a'.
config switch-controller custom-command edit "fan-temp-power" set command "diagnose sys fan status 0%a diagnose sys pcb temp 0%a diagnose sys psu status" next end
execute switch-controller custom-command "fan-temp-power" [<target-switch>]
Note that compound custom-commands will exit the first time a command returns an error on FortiSwitch.
Individual: It is sometimes preferable to configure individual custom commands, especially since some commands are not supported on all FortiSwitch models or FortiSwitch configurations.
config switch-controller custom-command edit "diagnose sys fan status" set command "diagnose sys fan status" next edit "diagnose sys pcb temp" set command "diagnose sys pcb temp" next edit "diagnose sys psu status" set command "diagnose sys psu status" next end
execute switch-controller custom-command "diagnose sys fan status" [<target-switch>]
This process can be automated if needed to execute commands or poll information periodically using this document: Creating automation stitches.
config system automation-trigger edit "Hourly XX:13" set trigger-type scheduled next end
config system automation-action edit "FortiSwitch fan temp psu script" set action-type cli-script next edit "Send switch script results" set action-type email next end
config system automation-stitch edit "Hourly switch diagnostics" set trigger "Hourly XX:13" config actions edit 1 set action "FortiSwitch fan temp psu script" set required enable next edit 2 set action "Send switch script results" set required enable next end next end
Notes:
|
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.
Copyright 2025 Fortinet, Inc. All Rights Reserved.