#!/bin/bash

echo ' ' >> /usr/local/nagios/etc/servers/test.cfg
sed -i '1idefine host{' /usr/local/nagios/etc/servers/test.cfg
sed -i '2iuse                linux-server,host-pnp\n' /usr/local/nagios/etc/servers/test.cfg
sed -i '3ihost_name          '"$1" /usr/local/nagios/etc/servers/test.cfg
sed -i '4icontact_groups     admins' /usr/local/nagios/etc/servers/test.cfg
sed -i '5iaddress            '"$2" /usr/local/nagios/etc/servers/test.cfg
sed -i '6i}' /usr/local/nagios/etc/servers/test.cfg

cat example >> /usr/local/nagios/etc/servers/test.cfg
sed -i -e 's/sd-73131\/Web-Clients/'"$1"'/g' /usr/local/nagios/etc/servers/test.cfg
