To make sure only fully transmitted files get considered on the server side, you would use code like this on the client side:
check_mk_agent | ssh user@checkmk-server \
"cat > $(hostname -f).part && mv $(hostname -f).part $(hostname -f)"
That is: pipe the output of check_mk_agent to a temporary file directly on the server through the ssh connection and then mv that temporary file to the final file (using the local hostname).
This works because mv is an atomic operation when done in the same filesystem. No need to scan the file for some last entry. The file either exists on the server side (and was completely transferred) – or not.