The little script compares the cumulative value in bytes that is just after "TX Bytes:" in your ifconfig command, to "40*1024*1024*1024" which is 40GB. The cumulative bytes resets after a network restart. If you haven't restarted in a while, the value is probably over 40GB, which is why the Wowza service is immediately stopped.
You'll have to modify the script to account for the possibility that your server restarts mid-month, by implementing a stack to record the new TX value each time the network restarts. Put that in a cronjob that runs every minute or so. Make another cron job that runs once a month which restarts the network and zeros the stack/file. Here's some psuedocode:
if tx < sum(stack)
if tx < top
else push (tx)
else stack = tx