-
Notifications
You must be signed in to change notification settings - Fork 0
/
nagios-generate-config.sh
52 lines (49 loc) · 1.94 KB
/
nagios-generate-config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
if [[ $# -eq 0 ]]; then # If no arguments are given to the script
echo "Usage:" # then print a usage statement and exit
echo "generate_config.sh hostname ip
"
exit 0;
fi
host="$1"
ip="$2"
echo "
# Host Definition
define host {
use linux-server ; Inherit default values from a template
host_name $host ; The name we're giving to this host
alias $host server ; A longer name associated with the host
address $ip ; IP address of the host
}
# Service Definition
define service{
use generic-service ; Name of service template to
host_name $host
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service ; Name of service template to
host_name $host
service_description users
check_command check_nrpe!check_users
}
define service{
use generic-service ; Name of service template to
host_name $host
service_description disk
check_command check_nrpe!check_disk
}
define service{
use generic-service ; Name of service template to
host_name $host
service_description totalprocs
check_command check_nrpe!check_total_procs
}
define service{
use generic-service ; Name of service template to
host_name $host
service_description memory
check_command check_nrpe!check_mem
}
">> /etc/nagios/server/"$host".cfg