How to get Fortigate interface statistics such as errors/discards
October 9, 2014
Posted by on
Recently I have needed to get the interface statistics like errors and discards for a Fortigate 5.2. I was using the normal commands that I knew, and some from google such as “diag hardware deviceinfo nic wan1” But had no luck with these commands getting errors/discard count. Maybe this is something they removed.
Update- this has been changed to :
“diag hardware nic INT” for example, at the bottom of the page is the output from running “diag hardware nic port40”— this was the results from a 1500D that is running 10 gig.
I started doing some research and found that there was a command that would drop you down to a very limited Linux shell. There are a few commands that are support such as “ifconfig”. This blew me away. I have been wondering if there was a command like this for a long time.
Log in through CLI, and run ” fnsysctl <command>” for example “fnsysctl ls”.
So to get the interface stats, I would just run: “fnsysctl ifconfig port16” or whatever port you want to look at.
And there we go. I have search for some other ways to get this, and have not found anything. If someone finds something better please pass it along.
FGT# get hardware nic port40
Description :FortiASIC NP6 Adapter
Driver Name :FortiASIC Unified NPU Driver
PCI Slot :0000:0d:00.0
Major ID :3
Minor ID :0
lif id :19
lif oid :171
netdev oid :171
netdev flags :1303
phy name :port40
========== Link Status ==========
netdev status :up
============ Counters ===========
Rx Pkts :109497620
Rx Bytes :150634406914
Tx Pkts :74293345
Tx Bytes :42164760114
Host Rx Pkts :30734166
Host Rx Bytes :38611688664
Host Rx dropped :0
Host Tx Pkts :41309687
Host Tx Bytes :20219939267
Host Tx dropped :46