The code is well commented and fairly self-explanatory.
Currently written to use the Ping sensor, and to look at a seven day period. Replace the following with your values: yourservername, yourusername, yourpasshash, yourdevicetag, yourfilepath, yourdomain (e.g. yourdevicetag -- domaincontrollers)