Quantcast
Channel: SQL Diagnostic Manager for SQL Server - Recent Threads
Viewing all articles
Browse latest Browse all 241

Idera Alert - Powershell - Create Jira Ticket

$
0
0

This is a sample of how I am creating Jira Tickets from Idera SQLDM.  I could not find anything on the internet.

#Install-Module JiraPS  https://github.com/AtlassianPS/JiraPS
#Install DNSClient Client module (Windows 10 and Server 2016)

#PowerShell Action command in Idera .D:\JiraPS\JiraPS.PS1 -AlertSummary "$(AlertSummary)" -AlertText "$(AlertText)" -Metric "$(Metric)"-Severity "$(Severity)" -Instance "$(Instance)" -Database #"$(Database)" -Timestamp #"$(Timestamp)" -Value "$(Value)" -Description "$(Description)" -Resource "$(Resource)"

#Test .\JiraPS.PS1 -AlertSummary "Test AlertSummary" -AlertText "Test AlertText" -Metric "Test Metric"

param (
[string]$AlertSummary = $null,
[string]$AlertText = $null,
[string]$Metric = $null,
[string]$Severity = $null,
[string]$Instance = $null,
[string]$Database = $null,
[string]$Timestamp = $null,
[string]$Value = $null,
[string]$Description = $null,
[string]$Resource = $null)

if ((Get-Module -ListAvailable -name DNSClient ) -and ($instance)){
$servername = Resolve-DnsName -name $Instance | Select NameHost
}

$Text = "AlertSummary: $AlertSummary`r`n"
$Text+= "AlertText: $AlertText`r`n"
$Text += "Severity: $Severity`r`n"
$Text += "Instance: $Instance`r`n"
$Text += "Servername: $($Servername.namehost)`r`n"
$Text += "Database: $Database`r`n"
$Text += "Timestamp: $Timestamp`r`n"
$Text += "Value: $Value`r`n"
$Text += "Description: $Description`r`n"
$Text += "Resource: $Resource`r`n"

Set-JiraConfigServer -Server "https://*JiraSite*/"
$Username = "*JiraUserName*"

##To set the password login in with AD account that is running Idera service.  Create the password using the below.  That profile will be able to decrypt the password.  

##Set Password for confluence
##$File = "\\Machine1\SharedPath\Password.txt"
##$Password = "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force
##$Password | ConvertFrom-SecureString | Out-File $File

##Use Password
$encrypted = Get-Content D:\JiraPS\Password\Password.txt | ConvertTo-SecureString
$Cred = New-Object System.Management.Automation.PsCredential($username, $encrypted)
Get-JiraIssueCreateMetadata -Project DBA -IssueType Task -Credential $cred
$Jiraresults = New-JiraIssue -Project DBA -IssueType Task -Summary "Idera: $AlertSummary" -Description "$Text" -Credential $cred


$Text += "Jiraresults: $Jiraresults`r`n"


$timer = (Get-Date -Format yyy-mm-dd-hhmmss)
$Text | Out-File "D:\JiraPS\log\test_$($timer).txt"


$From = "PRDDBADMIN@Company.com"
$To = "DBAdministrators@Company.com"
$attachment = "D:\JiraPS\log\test_$($timer).txt""
$Subject = "Idera Monitoring Jira Ticket $Jiraresults"
$Body = "$Text"
$SMTPServer = "company.mail.protection.outlook.com"
$SMTPPort - "25"
Send-MailMessage -From $from -To $To -Subject $Subject -Body $Body -SMTPServer $SMTPServer


Viewing all articles
Browse latest Browse all 241

Trending Articles