why not just use safe node manager ?
here is the resources script from the community git hub for resource logging.