Compare commits

4 Commits

Author SHA1 Message Date
kgi-john 18516c90e1 inverted colors on justdoit 2025-03-06 14:41:14 -08:00
kgi-john 30d0a1d263 added script 2024-10-25 15:19:30 -07:00
kgi-john 95f009b40f snake 2024-08-20 08:53:53 -07:00
kgi-john 4fb8bc8445 jenkins image 2024-08-20 08:49:25 -07:00
4 changed files with 166 additions and 0 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 117 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

+163
View File
@@ -0,0 +1,163 @@
$license_server = 'http://10.138.253.108:8080/v1/admin/status'
# test public
# $workflow_server = 'https://prod-172.westus.logic.azure.com:443/workflows/ff2e50d150a4497fa5fb3998f19ff64d/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=7nd4_UM0vfGR4mS1853KGfmdla099Rg10JfGnaG07FE'
# server status
$workflow_server = 'https://prod-184.westus.logic.azure.com:443/workflows/0196c82aa13d4700b207cf20cf32689d/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=WS67Db7ck2pwmjkNopNBWOiNjlO2jwZdLk71oTQjW_8'
$adaptive_card = @{
type = 'message'
attachments = @(
@{
contentType = 'application/vnd.microsoft.card.adaptive'
content = @{
'$schema' = 'http://adaptivecards.io/schemas/adaptive-card.json'
type = 'AdaptiveCard'
version = '1.0'
msteams = @{
width = 'Full'
}
body = @(
@{
type = 'TextBlock'
text = 'Unity License Server Status'
wrap = $True
color = 'good'
size = 'large'
weight = 'bolder'
}
)
}
}
)
}
$response = Invoke-WebRequest -Method 'GET' -Uri $license_server -SkipHttpErrorCheck
if ($response.StatusCode -ne '200')
{
$json = (ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString($response.Content)) | ConvertTo-Json)
$adaptive_card.attachments[0].content.body += @{
type = 'CodeBlock'
language = 'JSON'
codeSnippet = $json
}
}
else
{
$json = (ConvertFrom-Json ([System.Text.Encoding]::UTF8.GetString($response.Content)) | ConvertTo-Json)
$adaptive_card.attachments[0].content.body += @{
type = 'FactSet'
facts = @(
@{
title = 'Name'
value = $json.serverContext.data.MachineName
}
@{
title = 'Status'
value = $json.serverStatus
}
@{
title = 'Up Time'
value = $json.serverUpTime
}
)
}
$table = @{
type = 'Table'
firstRowAsHeaders = $true
columns = @(
@{
width = 1
}
@{
width = 1
}
@{
width = 1
}
)
rows = @(
@{
type = 'TableRow'
cells = @(
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = 'Product'
weight = 'Bolder'
}
)
}
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = 'Active Licenses'
weight = 'Bolder'
}
)
}
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = 'Total Licenses'
weight = 'Bolder'
}
)
}
)
}
)
}
foreach ($license in $json.serverLicenses.data)
{
$table.rows += @{
type = 'TableRow'
cells = @(
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = $license.Product
}
)
}
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = "$($license.activeLicenseCount)"
}
)
}
@{
type = 'TableCell'
items = @(
@{
type = 'TextBlock'
text = "$($license.licenseCount)"
}
)
}
)
}
}
$adaptive_card.attachments[0].content.body += $table
}
Invoke-WebRequest -Uri $workflow_server -Method Post -Body (ConvertTo-Json -InputObject $adaptive_card -Depth 99) -ContentType 'application/json'