DM-1651 Part 1. Remove redundant code, add helper function and move a function
Created by: SkyToGround
Description of work
- Removed duplicate code for getting the host name and PID.
- Added helper function for generating a random hex string (to be used in a later PR).
- Moved function for reading file into the only location where it is used.