1. I need to limit the user monthly usage, for example bandwidth 2Mbps with 5GB monthly usage.

1a.) You would not need script, you need "RLM SQLCOUNTER"  to limit daily/weekly/monthly traffic quota
1b.) you need to control the bandwidth using radius and radius client attributes, such as WISPr-Bandwidth-Max-Down; WISPr-Bandwidth-Max-Up

Thanks