We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ddec392 commit e95f541Copy full SHA for e95f541
ansible/playbooks/nagios/roles/Nagios_Server/scripts/nagios_host_group_remove.sh
@@ -0,0 +1,20 @@
1
+#!/bin/bash
2
+while read -p "Enter the hostgroup name (Enter to finish) :" -r hostgroup_name
3
+do
4
+ if [[ "$hostgroup_name" ]]
5
+ then
6
+ awk -vhostgroup_name="${hostgroup_name}" '
7
+ /^define hostgroup/ { buf=""; addbuf=prtbuf=1 }
8
+ addbuf {
9
+ buf=(buf $0 ORS)
10
+ if ($1=="hostgroup_name" && $2==hostgroup_name) prtbuf=0
11
+ if ($1=="}") { addbuf=0; if (prtbuf) printf "%s", buf }
12
+ next
13
+ }
14
+ { print }
15
+ ' /usr/local/nagios/etc/objects/hostgroups.cfg > junk.out
16
+ mv junk.out /usr/local/nagios/etc/objects/hostgroups.cfg
17
+ else
18
+ break;
19
+ fi
20
+done
0 commit comments