forked from zampat/icinga2-monitoring-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2031a-st_win_exchange.sh
221 lines (201 loc) · 6.02 KB
/
2031a-st_win_exchange.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#
#Services (as template)
# HowTo Export:
# # icingacli director service show Agent_Win_Service --json
#
# Pre-Requisites: Command: Powershell and service template "generic_agent_powershell"
RES=`icingacli director service exists "generic_agent_powershell"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service template 'generic_agent_powershell' does not exists This is a pre-requisite.".
echo "Please import this Service template from service windows templates.".
exit 3
fi
# HTTP Exchange
#
RES=`icingacli director service exists "https_exchange_owa"`
if [[ $RES =~ "does not exist" ]]
then
echo "Command 'https_exchange_owa' does not exists"
icingacli director service create https_exchange_owa --json '
{
"imports": [
"http_website_availability"
],
"object_name": "https_exchange_owa",
"object_type": "template",
"vars": {
"http_ssl": true
}
}
'
fi
# Check Command:Powershell Exchange scripts
#
RES=`icingacli director command exists "powershell_exchange"`
if [[ $RES =~ "does not exist" ]]
then
echo "Command 'powershell_exchange' does not exists"
icingacli director command create powershell_exchange --json '
{
"object_name": "powershell_exchange",
"methods_execute": "PluginCheck",
"command": "c:\\Windows\\system32\\cmd.exe",
"object_type": "object",
"arguments": {
"(no key)": {
"set_if_format": "string",
"skip_key": true,
"value": "\/c echo c:\\Scripts\\$powershell_script$ ; exit ($$lastexitcode) | powershell.exe -command -"
}
}
}
'
fi
######
## Services for Windwows Exchange
######
# Service template for Exchange via PowerShell
#
RES=`icingacli director service exists "generic_agent_powershell_exchange"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'generic_agent_powershell_exchange' does not exists"
icingacli director service create --json '
{
"check_command": "powershell_exchange",
"imports": [
"generic_agent_powershell"
],
"object_name": "generic_agent_powershell_exchange",
"object_type": "template"
}
'
fi
# NSCP Services check: Windows Services "Exchange Services"
RES=`icingacli director service exists "Exchange Services"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'Exchange Services' does not exists"
icingacli director service create --json '
{
"imports": [
"Agent_Win_NscpServices"
],
"object_name": "Exchange Services",
"object_type": "template",
"vars": {
"nscp_service_name": [
"MSExchangeADTopology",
"MSExchangeAntispamUpdate",
"MSComplianceAudit",
"MSExchangeCompliance",
"MSExchangeDagMgmt",
"MSExchangeDiagnostics",
"MSExchangeEdgeSync",
"MSExchangeFrontEndTransport",
"MSExchangeHM",
"MSExchangeHMRecovery",
"MSExchangeIS",
"MSExchangeMailboxAssistants",
"MSExchangeMailboxReplication",
"MSExchangeDelivery",
"MSExchangeSubmission",
"MSExchangeRepl",
"MSExchangeRPC",
"MSExchangeFastSearch",
"HostControllerService",
"MSExchangeServiceHost",
"MSExchangeThrottling",
"MSExchangeTransport",
"MSExchangeTransportLogSearch",
"MSExchangeUM",
"MSExchangeUMCR",
"FMS"
],
"nscp_showall": true
}
}
'
fi
######
## PowerShell: Services for Windwows Exchange
######
# Service Template
RES=`icingacli director service exists "Exchange2016 Mailbox Health status"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'Exchange2016 Mailbox Health status' does not exists"
icingacli director service create --json '
{
"imports": [
"generic_agent_powershell_exchange"
],
"object_name": "Exchange2016 Mailbox Health status",
"object_type": "template",
"vars": {
"exchange2016_powershell": "exchange-QueueHealth.ps1",
"powershell_script": "MailboxHealth.ps1"
}
}
'
fi
# Service Template
RES=`icingacli director service exists "Exchange2016 FullBackup status"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'Exchange2016 FullBackup status' does not exists"
icingacli director service create --json '
{
"imports": [
"generic_agent_powershell_exchange"
],
"object_name": "Exchange2016 FullBackup status",
"object_type": "template",
"vars": {
"exchange2016_powershell": "exchange-QueueHealth.ps1",
"powershell_script": "exchange-FullBackupMonitoring.ps1"
}
}
'
fi
# Service Template
RES=`icingacli director service exists "Exchange2016 IncrementalBackup status"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'Exchange2016 IncrementalBackup status' does not exists"
icingacli director service create --json '
{
"imports": [
"generic_agent_powershell_exchange"
],
"object_name": "Exchange2016 IncrementalBackup status",
"object_type": "template",
"vars": {
"exchange2016_powershell": "exchange-QueueHealth.ps1",
"powershell_script": "exchange-IncrementalBackupMonitoring.ps1"
}
}
'
fi
# Service Template
RES=`icingacli director service exists "Exchange2016 QueueHealth status"`
if [[ $RES =~ "does not exist" ]]
then
echo "Service 'Exchange2016 QueueHealth status' does not exists"
icingacli director service create --json '
{
"imports": [
"generic_agent_powershell_exchange"
],
"object_name": "Exchange2016 QueueHealth status",
"object_type": "template",
"vars": {
"exchange2016_powershell": "exchange-QueueHealth.ps1",
"powershell_script": "exchange-QueueHealth.ps1"
}
}
'
fi
echo "[+] All Service Templates for Microsoft Exchange created"
exit 0