If the power to the main breaker is intermittent, you may need to call the power company. Depends on where you live how far they own, but it could be a bad connection at the transformer, or from the meter to the panel. If you measure from hot to hot, what do you read on the meter? It could be a bad neutral. A bad neutral can mess up all sorts of things.