Skip to content

Conversation

@MuriloChianfa
Copy link
Contributor

Hey @phaag 👋,

Recently working with nfdump, I notice that sometimes when using the nfexpire tool, we can't be so sure how many files we'll delete using the arguments, so I tried to implement a new option to first make a dry-run, where will be possible to see which files and folders that will be deleted before executing it. Here are some examples:

Environment:

[root@processor: tmp]# ./nfexpire -r /netflow/vs-bgp/ 
Scanning files in /netflow/vs-bgp .. done.
Updating nfcapd bookkeeping records
First:     2026-01-26 05:20:00
Last:      2026-01-30 13:50:00
Lifetime:  376200 = 4.4 days
Numfiles:  1254
Filesize:  2903126016 = 2.7 GB
Max Size:  3865470566 = 3.6 GB
Max Life:  <none>
Watermark: 90%
Status:    OK

dry-run mode:

[root@processor: tmp]# ./nfexpire -e /netflow/vs-bgp/ -s 2.7G -n
DRY-RUN MODE: Simulating expire operation

Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601260520 (size: 1093632 = 1.0 MB)
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601260525 (size: 1040384 = 1016.0 KB)
...manually truncated for demo purposes
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601261820 (size: 3022848 = 2.9 MB)
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601261825 (size: 2994176 = 2.9 MB)

Would expire files:      158
Would expire file size:  296120320 = 282.4 MB
Would expire time range: 47400 = 13.2 hours

DRY-RUN MODE: No files deleted

First:     2026-01-26 05:20:00
Last:      2026-01-30 13:50:00
Lifetime:  376200 = 4.4 days
Numfiles:  1254
Filesize:  2903126016 = 2.7 GB
Max Size:  3865470566 = 3.6 GB
Max Life:  <none>
Watermark: 90%
Status:    OK

executing the expire:

[root@processor: tmp]# ./nfexpire -e /netflow/vs-bgp/ -s 2.7G   
Expired files:      158
Expired file size:  296120320 = 282.4 MB
Expired time range: 47400 = 13.2 hours

First:     2026-01-26 18:30:00
Last:      2026-01-30 13:50:00
Lifetime:  328800 = 3.8 days
Numfiles:  1096
Filesize:  2607005696 = 2.4 GB
Max Size:  2899102924 = 2.7 GB
Max Life:  <none>
Watermark: 90%
Status:    OK

dry-run showing the folder that would be deleted too:

[root@processor: tmp]# ./nfexpire -e /netflow/vs-bgp/ -s 2.3G -n
DRY-RUN MODE: Simulating expire operation

Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601261830 (size: 3055616 = 2.9 MB)
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601261835 (size: 3051520 = 2.9 MB)
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601261840 (size: 2981888 = 2.8 MB)
...manually truncated for demo purposes
Would delete: /netflow/vs-bgp/2026/01/26/nfcapd.202601262355 (size: 4194304 = 4.0 MB)
Would remove directory: /netflow/vs-bgp/2026/01/26
Would delete: /netflow/vs-bgp/2026/01/27/nfcapd.202601270000 (size: 4177920 = 4.0 MB)
Would delete: /netflow/vs-bgp/2026/01/27/nfcapd.202601270005 (size: 4141056 = 3.9 MB)
...manually truncated for demo purposes
Would delete: /netflow/vs-bgp/2026/01/27/nfcapd.202601270540 (size: 880640 = 860.0 KB)
Would delete: /netflow/vs-bgp/2026/01/27/nfcapd.202601270545 (size: 901120 = 880.0 KB)

Would expire files:      136
Would expire file size:  384692224 = 366.9 MB
Would expire time range: 40800 = 11.3 hours

DRY-RUN MODE: No files deleted

First:     2026-01-26 18:30:00
Last:      2026-01-30 13:50:00
Lifetime:  328800 = 3.8 days
Numfiles:  1096
Filesize:  2607005696 = 2.4 GB
Max Size:  2899102924 = 2.7 GB
Max Life:  <none>
Watermark: 90%
Status:    OK

I've updated the manual including the new -n option with some examples:

image image image

Let me know your thoughts for this new feature.

Kind regards,
Murilo Chianfa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant