Thanks for sharing. Here is my take on how to minimize execution time if it miss the exact second. It should take less than 1 sec.

https://github.com/bbhenry/check_mk_local/blob/master/check_http_code_counter