#!/bin/bash

cat /etc/nagios/nrpe.cfg >> /etc/nagios/test.cfg
sed -i "201i\command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10\n" /etc/nagios/test.cfg
sed -i "202i\command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20\n" /etc/nagios/test.cfg
sed -i "203i\command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20% -p /dev/sda1\n" /etc/nagios/test.cfg
sed -i "204i\command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z\n" /etc/nagios/test.cfg
sed -i "205i\command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 450 -c 500\n" /etc/nagios/test.cfg
sed -i "206i\command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$\n" /etc/nagios/test.cfg
sed -i "207i\command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$\n" /etc/nagios/test.cfg
sed -i "208i\command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20% -c 10%\n" /etc/nagios/test.cfg
sed -i "209i\command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20%\n" /etc/nagios/test.cfg
sed -i "210i\command[check_run]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20% -p /run\n" /etc/nagios/test.cfg
sed -i "211i\command[check_run_shm]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20% -p /run/shm\n" /etc/nagios/test.cfg
sed -i "212i\command[check_disk_dev]=/usr/lib/nagios/plugins/check_disk -w 25% -c 20% -p /dev\n" /etc/nagios/test.cfg
sed -i "213i\command[check_mem]=/usr/lib/nagios/plugins/check_mem -f -w 2 -c 1\n" /etc/nagios/test.cfg
sed -i "214i\command[check_net]=/usr/lib/nagios/plugins/check_net\n" /etc/nagios/test.cfg
sed -i "215i\command[check_band]=/usr/lib/nagios/plugins/check_band 40960 102400 40960 102400\n" /etc/nagios/test.cfg
sed -i "216i\command[check_http]=/usr/lib/nagios/plugins/check_http -I $HOSTADRESS$" /etc/nagios/test.cfg
rm /etc/nagios/nrpe.cfg

cat /etc/nagios/test.cfg | sed '218,237d' >> /etc/nagios/test2.cfg

sed -i "81i\Allowed_hosts=88.120.58.145, 195.154.64.67" test2.cfg
rm test.cfg

cat /etc/nagios/test2.cfg | sed '82,83d' >> /etc/nagios/nrpe.cfg
rm test2.cfg
