Measure ESP8266 battery
GPIO-0 when pulled low during startup allows you to flash code in it. If GPIO-0 is HIGH during startup, it allows normal boot-up from flash. You will have to ensure that any sensor attached to it it not driving the pin LOW during a start-up sequence.
I am not sure about ESP-01 but other versions (ESP-07) has adc pin which has input range of 0-1V. You can make a voltage divider using resistors to scale your battery voltage (9V) to 1V and give that to adc pin as an input. Here is an example:

Keep the voltage divider Resistor values high because it will consume a current = Battery Voltage / Total Resistance, 0.1 mA in this case.