This is a script that combines a single run of perfstat and a rolling perfstat for an intermittent issue.
The script will take care of creating the necessary key for perfstat to run
All you need is copy this script into the same directory as the latest perfstat binary is.
Change the top parameters in the script:
the perfstat outputs will be collected in dstpath directory. In this case, the same diretory where perfstat binary is.
start screen, run the script and <ctrl>a+d to detach from the session.
For the rolling perfstat with a graceful stop of the loop. All you need to do is touch a file called stop in the same directory as the script. So the current perfstat will finish gracefully and the loop stops.
Similarly for running a single perfstat with the above parameters, touch a file named stop and it will perform 5 iterations with 5 minute sample as stated above.
KB#1015417 - How to collect a Perfstat from a clustered Data ONTAP system in Linux
KB#1012616 - How to collect Performance Statistics for Intermittent Issues