Quick script to get path to latest nagios version

If you need to automate the retrieval of the latest Nagios version path to download this is how I do it.

Nothing fancy and it breaks if they change the sourceforge site but we can fix when that happens 🙂

 

curl -v http://www.nagios.org/download/core/thanks/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1

Result:

http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz

Of course this comes in handy when pulling for the clients being monitored so by extension:

 curl -v http://www.nagios.org/download/plugins/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1

Result:

http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

Getting the files in a script is as easy as :

curl -v http://www.nagios.org/download/plugins/ 2>&1 | grep tar\.gz | cut -d \” -f 2 | sort -r | head -n 1 | xargs wget

Ping me if this stops working for you.

Enjoy.

Write a Reply or Comment

Your email address will not be published.