Generate Nagios Configuration Using Shell Script – 1000 Configs 1 Minute

Are you thinking that configuring Nagios with thousands of hosts is difficult then your assumption is wrong. Just Simply within minute of time you can generate nagios configuration using shell script – 1000 configs will take 1 minute of time.

Really exited right..!! Let’s see the procedure and piece of code will do it for you.

Generate Nagios Configuration Using Shell Script – 1000 Configs 1 Minute

First we have to prepare .csv file with host IP addresses and host names then you can run below shell script it will generate every thing for you.

Conditions to run the shell script

  • .csv file name should be arkit-generate.csv (if your advanced user then change accordingly)
  • Generate One type of configuration files once which means Windows Machines once, Linux Machines and Other Machines once. You have to prepare multiple .csv files based there Operating System type.
  • Create Standard Template as a base
  • In .csv file Server name should not have any space

How to Create .csv file

Open excel sheet and file the data as mentioned below, IP Address in First Column (A) and Host Name in Second Column.

Generate Nagios Config Files

Save the excel file name with arkit-generate.csv (Do not put any other name until unless your not sure)

Then Download below template


of-course you can create your template as per your requirement, If you would like to create your own template then save the template name as Nagios-Template-Linux.cfg

Keep all the files in one directory, then create one file called

[root@Arkit ~]# touch

Copy below script and paste in newly created file called

Nagios Monitoring Tool Implementation: Configure 10000 Hosts in one minute NagiosCore

## Purpose: Generate Nagios Configuration
## Date: 27th Sep 2016
## Author: Ankam Ravi Kumar
## Web Site:
mkdir temp-cfg
cat  arkit-generate.csv | while read LINE
    HostIP=`echo $LINE | cut -d, -f1`
    HostName=`echo $LINE | cut -d, -f2`
    sed -e "s/XXXX/$HostName/g; s/ZZZZ/$HostIP/g" Nagios-Template-Linux.cfg > temp-cfg/$HostName.cfg

Now provide executable permission to that script file using below command

~]# chmod +x]# ./

After completion of script running you can able to see temp-cfg directory

~]# cd temp-cfg

then move the config files to appropriate location to monitor all your Hosts and Services

Default location is /usr/local/nagios/etc/objects/

Related  Articles

Monitoring Windows Clients using Nagios Core

Nagios Core Service Group Configuration

Nagios Core host Group Configuration

Change Nagiosadmin password when you forgot

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

6 Responses

  1. Kandhanadhan says:

    Your posts are awesome bro. Please help me in editing the template file

  2. blank Dave says:

    Hi ARK , I see your template download link no longer works. Could you share the template please? I am building a new Nagios Core server to replace an old one that was mis-configured. I have about 3000 devices that need new clean config files.
    Thanks Dave

Leave a Reply

Your email address will not be published. Required fields are marked *