You can run that script from anywhere but my message in a bottle would be to exercise caution if putting it into client scripts.
If you build this into your client screen and 100 clients are launched with this screen, the analysis will execute 100x - 1 for each client.
Depending on the number of machine state changes and the time period used, this could be an expensive calculation.