I am able to add ec2 instances in nagios using puppet but how can I delete the instances from nagios configuration after instances get terminated.
I am looking for something, whenever any node gets terminated manually or via ASG, those, wait for 10 mins or so, if node is still down, delete it from nagios and restart nagios.
For long-running hosts, use your config management tool to update your Nagios config when changes are made.
For ASG hosts, I'd just write up a simple script that uses the EC2 API to get a list of hosts for each ASG and then have the script modify the Nagios config.
If you have added instance in monitoring then your nagios already maintain status for your EC2. Nagios also exposes API to query down hosts along with details on since how long they are in DOWN state. You can query nagios API to get list of down hosts and write a script to delete it if it is down for more than X mins.
Check cleanup script section of this blog. Scheduled cron job on nagios instance will periodically query down hosts and delete it from host file. Code is written in PHP and REST API is exposed so that it can be called from anywhere.