Notifications on program startup. Minor changes in scripts.

Notifications on program startup. Minor changes in scripts.
This commit is contained in:
Alexander I. Chebykin
2022-06-27 18:14:13 +03:00
parent 577ad19b9f
commit ccb471dcc2
7 changed files with 118 additions and 10 deletions

View File

@@ -0,0 +1,20 @@
[main]
check_interval = 10000
rules_count = 2
[notifications]
email = admin@server.local
command = ./send-telegram.ps1 <message>
service_start = true
[rule1]
service = Test1
address = http://127.0.0.1:3000/api/v1/
email = admin@server.local
command = ./send-telegram.ps1 <message>
[rule2]
service = Test2
address = http://127.0.0.1:3300/api/v1/
email = admin@server.local
command = ./send-telegram.ps1 <message>

View File

@@ -0,0 +1,9 @@
$EmailFrom = "yourmailadress@somedomain.com"
$EmailTo = $args[0]
$Subject = $args[1]
$Body = $args[0]
$SMTPServer = "smtp.somedomain.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

View File

@@ -0,0 +1,10 @@
Param([Parameter(Mandatory=$true)][String]$Message)
$Telegramtoken = "Your_Telegram_Token"
$Telegramchatid = "Your_Telegram_Chat_ID"
$Message = $args[0]
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$Response = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($Telegramtoken)/sendMessage?chat_id=$($Telegramchatid)&text=$($Message)"