-
Notifications
You must be signed in to change notification settings - Fork 2
/
Enable-NagiosServiceNotification.ps1
56 lines (48 loc) · 1.93 KB
/
Enable-NagiosServiceNotification.ps1
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
<#
.SYNOPSIS
Enables Nagios service notifications for a specified host.
.DESCRIPTION
This function is a shortcut to Invoke-Nagios to automatically choose
to enable nagios notifications for a specified service on a host.
.EXAMPLE
Enable-NagiosServiceNotifications -ComputerName SERVER01 -Service sqlserver
.EXAMPLE
Enable-NagiosServiceNotifications -ComputerName SERVER01 -Service sqlserver -Credential $Credential
.EXAMPLE
Enable-NagiosServiceNotifications -ComputerName SERVER01 -Service sqlserver -Credential $Credential -NagiosCoreUrl https://nagiosdev.domain.com/nagios
#>
Function Enable-NagiosServiceNotification {
Param (
# Nagios Host
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0,
HelpMessage = "What nagios refers to host(s) for which you wish to enable/disable checks and notifications. Nagios is case-sensitive for hosts (i.e. server01 != SERVER01)."
)]
[alias('host')]
[string[]]$ComputerName = $env:COMPUTERNAME,
# Service name (Case-Sensitive)
[Parameter(Mandatory = $false
, Position = 1
, HelpMessage = "Service name (case-sensitive)"
)]
[string]$Service,
# Nagios base url
[Parameter(
HelpMessage = "The base url of your nagios installation (i.e. http://nagios.domain.com/nagios)"
)]
[string]$NagiosCoreUrl,
# Nagios Credential
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]$Credential
)
begin {}
process {
foreach ($Computer in $ComputerName) {
Write-Verbose "Disabling Nagios service Notifications for $Service on $Computer"
Invoke-NagiosRequest -ComputerName $Computer -Service $Service -action 22 -Credential $Credential -NagiosCoreUrl $NagiosCoreUrl
}
}
end {}
}