“If you can't sleep, don't count sheep. Talk to the shepherd.”
"Counting sheep" is a mental exercise for when you have trouble sleeping. The idea is that you imagine lots of sheep jumping over a fence, one by one, and counting them as they go - and that this is so boring that you will soon fall asleep.
Your phrase is a Christian proverb (quite recent, I think) suggesting that a better method is to pray to God (the Good Shepherd) to send you to sleep.
In some cultures, people try to count sheep in order to fall asleep. This is, for example, the source of the Serta sheep which all have numbers on them. However, this saying says that if you can't sleep, you shouldn't keep trying to count sheep -- that is, you shouldn't keep trying something that isn't working. Instead, you should talk to the shepherd--you should get to the root of the problem.
In the article you quoted, this saying is used in the context of sleep deprivation. It is giving you reasons why you should go to the shepherd and solve the causes of that deprivation, instead of absently counting sheep and continuing on the same path.