How to measure the charge left in a dying battery? This question is not relative to a specific phone model, even though I will cite my P1000.

My P1000 is 3 years old, and it is often suddenly turning off (no shutdown sequence, just goes dead) out of the blue while the battery marker is at the 31ish percentile. If I try and turn it on right away, it goes dead again during boot sequence. If I plug the charger, the charging icon shows some battery left. Turning it on with the charger plugged shows the 31-ish percent on the charge indicator. If it is left on standby, it goes below that threshold without dying, but dies soon after.

The battery is almost dead, that is sure. Now the question is,

How can I measure how much energy the battery really have left before dying, and is there any app to tweak the display of battery charge so I can have a new "zero" at this dying point?
You would need to re-calibrate the battery. 

I would suggest reading the answers on: 


How frequently is it okay to let the battery discharge fully or as low as possible?
Looking for a consistent answer about battery calibration
Is there an efficient way to calibrate the battery than using some apps?