> Source: [sk184144](https://support.checkpoint.com/results/sk/sk184144)

# sk184144 - "api stats -calc_avg_duration" command fails with IndexError on Security Management Server

| Property | Value |
|----------|-------|
| Solution ID | sk184144 |
| Date Created | 2025-10-18 |
| Last Modified | 2026-07-23 |
| Technical Level | General |
| Products | Security Management Server |
| Versions | R82.10, R82, R81.20 |
| OS | Gaia |

## Symptoms

- * Running the "`api stats`" command with the "`-calc_avg_duration`" flag on the Security Management server fails with error:

  ```
  
  IndexError: list index out of range
  ```

  <br />

* The error occurs specifically when requesting statistics in text format, for example:

  ```
  
  api stats -from_date ... -to_date ... -calc_avg_duration -f text
  ```

  <br />

* Other subcommands of the `"api stats"` command work as expected.

* Replacing script files or removing the *$FWDIR/log/api.csv* file does not resolve the issue.

## Cause

An issue with the Security Management Server API statistics parser handling certain User-Agent strings (e.g., Apache-HttpClient/4.5.13 (Java/1.8.0_372)).   
This results in malformed entries in the *$FWDIR/log/api.csv* and its rotated files, where the expected number of columns is not met. When the `-calc_avg_duration` flag is used, the script attempts to access a non-existent list index, causing an `IndexError`.

## Solution

This problem was fixed. The fix is included in:

* [Jumbo Hotfix Accumulator for R82.10](https://sc1.checkpoint.com/documents/Jumbo_HFA/R82.10/Default.htm) starting from Take 36
* [Jumbo Hotfix Accumulator for R82](https://sc1.checkpoint.com/documents/Jumbo_HFA/R82/Default.htm) starting from Take 118
* [Jumbo Hotfix Accumulator for R81.20](https://sc1.checkpoint.com/documents/Jumbo_HFA/R81.20/Default.htm) starting from Take 158

If you choose not to upgrade, Check Point can supply a **Hotfix** . [Contact Check Point Support](https://www.checkpoint.com/support-services/contact-support/) to get a Hotfix for this issue.  
A Support Engineer will make sure the Hotfix is compatible with your environment before providing the Hotfix.  
For faster resolution and verification, please collect [CPinfo files](http://supportcontent.checkpoint.com/solutions?id=sk92739) from the Security Management Server and Security Gateways involved in the case.

**Hotfix installation instructions:**   
Refer to [sk168597 - How to install a Hotfix](https://support.checkpoint.com/results/sk/sk168597).

### Workaround

Remove Malformed Entries:  

**Note** : Editing these files may impact system behavior. Always back up before making changes.  

1. Edit the file: *$FWDIR/log/api.csv*.
2. Remove all lines with malformed User-Agent strings (e.g., missing closing quotes or brackets).
3. Repeat this step for all rotated files: *$FWDIR/log/api.csv.1* , *$FWDIR/log/api.csv.2*, etc.
4. Restart the API service with the command "`api restart`" to apply the changes.

**Note:**Editing these files may impact system behavior. Back up before making changes.

**Verification**

1. After applying the workaround or hotfix, run this command to make sure that the error no longer occurs:  
   `api stats -from_date ... -to_date ... -calc_avg_duration -f text`
2. Confirm that the command completes successfully and returns the expected statistics.

---

# Agent Instructions

This content is from the Check Point Support Center (https://support.checkpoint.com), the official knowledge base for Check Point cybersecurity products.

## Navigating This Knowledge Base

- **Complete index**: [llms.txt](https://support.checkpoint.com/llms.txt)
- **All SK articles**: [SecureKnowledge Sitemap](https://support.checkpoint.com/sitemaps/secureknowledge-sitemap-index.xml)
- **SK article URL pattern**: `https://support.checkpoint.com/results/sk/{skId}`
- **Markdown responses**: AI bot User-Agents automatically receive `text/markdown` content
