FortiManager
FortiManager supports network operations use cases for centralized management, best practices compliance, and workflow automation to provide better protection against breaches.
ydong01
Staff
Staff
Article Id 354764
Description This article describes API query policy for IT audit.
Scope FortiManager.
Solution

There is a requirement from IT audit department for find unused policy. It can use FortiGate API to find it, but if lot of FortiGate managed by FortiManager, use FortiManager API will be quick. 

 

Hitcount information is not actively updated in FortiManager. It needs to be manually refreshed by GUI or API as described below to get the latest values ā€‹ā€‹by associating the FortiGate via the API sent by FortiManager.

 

Example:

 

  1. The FortiManager default policy view does not contain a hit count:

 

1-fmg-policy-default.PNG

 

  1. After adding a hit count, the policy looks like this:

 

2-add-hitcount-for display.PNG

 

  1. Refresh hit count:

 

3-Refresh-hit-count.PNG

 

  1. Refresh option triggers a taskļ¼š

 

4-trigger-task.PNG

 

  1. Task result:

 

5-task.PNG

 

  1. Use tools to find unused policies:

 

6-tools-find-unused-policies.PNG

 

  1. Find unused policies:

 

7-unused-policies.PNG

 

The above operations are manual and are not easy for plenty of FortiGate and ADOMs.

The following are the API steps:

 

  1. Log in to FortiManager to get the session ID:

 

8-api-login.PNG

 

  1. Get ADOMs list:

 

9-get-adom-name.PNG

 

  1. Get policy package name:

 

10-get-policy-name.PNG

 

  1. Trigger hit count task:
                                   

11-get-task-id.PNG

 

  1. Get unused policy ID:
                                                   

12-get-unused-policy-id.PNG

 

  1. Logout FortiManager:
                                                 

13-api-logout.PNG

 

Troubleshooting:

The below commands can be used on FortiManager CLI to debug the API Calls:

 

diagnose debug service httpd 255

diagnose debug service main 255

For more details, visit https://fndn.fortinet.net/