What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

SMS notification with API link

Votes:

0

Hi,

Can we configure SMS notification with API link not using username and password

Thanks

api prtg sms

Created on Jun 15, 2022 11:25:48 AM



8 Replies

Votes:

0

Hello,

Thank you for your message.

From the Notification Delivery menu (Setup > System Aministration), if your SMS provider doesn't require authentication (or a simple token in the URL) then you can absolutely define the URL without any credentials.

Otherwise, if the latter requires authentication via specific HTTP header (ex: Authorization) then you need to use the Execute program method from a notification template to execute a script which will perform the HTTP request.

To be able to select the script from the dropdown list, the latter must be copied on the PRTG server under "C:\Program Files (x86)\PRTG Network Monitor\Notifications\EXE".

If you have questions, do not hesitate.

Regards.

Created on Jun 20, 2022 10:42:47 AM by  Florian Lesage [Paessler Support]

Last change on Jun 20, 2022 10:43:14 AM by  Florian Lesage [Paessler Support]



Votes:

0

Hi,

Thanks for the info

Could you please share a sample batch file for an executable program? We have a SMS gateway with headers that need to be passed for authorization.

When I set the variables %SMSNUMBER and %SMSTEXT within a batch file, will the variables be taken into account?

=========================================================================

curl -L -X POST 'https://3v3nx1.api.infobip.com/sms/2/text/advanced' \
-H 'Authorization: App 6d2e1d1274b8c344b5be3a6066e639ce-0155c1f8-6847-47bb-9e4b-88ed2322ea19' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
--data-raw '{
  "messages": [
    {
      "destinations": [
        {
          "to": "%SMSNUMBER"
        }
      ],
      "from": "InfoSMS",
      "text": "%SMSTEXT"
    }
  ]
}'

=============================================================================

Created on Jul 18, 2022 1:12:00 PM

Last change on Jul 18, 2022 1:28:10 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hi,

Unfortunately, we do not have example of batch script for that.

Regarding the variables %SMSNUMBER and %SMSTEXT, those cannot be used outside of the notification delivery settings. Therefore, the phone number must be passed within the parameters in the notification template.

NOTE: the placeholders must be surrounded by quotes "" to avoid issues due to spaces

Regards.

Created on Jul 18, 2022 2:51:24 PM by  Florian Lesage [Paessler Support]

Last change on Jul 25, 2022 7:42:14 AM by  Florian Lesage [Paessler Support]



Votes:

0

Hi,

As a text message, I need to send the following things. What changes should I make to my PowerShell script to get the below text as an SMS and what variables should I give in PowerShell?

[%sitename] %device %name %status %down (%message)

Below is the PowerShell program for SMS notification

param(
[string] $smsnumber = "",
[string] $smstext = ""
)



$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "App ***")
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")

$body = "{`n  `"messages`": [`n    {`n      `"destinations`": [`n        {`n          `"to`": `"+***`"`n        }`n      ],`n      `"from`": `"Info`",`n      `"text`": `"SMSTEXT145`"`n    }`n  ]`n}"

$response = Invoke-RestMethod 'http://***/sms/2/text/advanced' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

Created on Jul 24, 2022 1:52:03 PM

Last change on Jul 25, 2022 7:09:45 AM by  Florian Lesage [Paessler Support]



Votes:

0

Hi,

To be able to send the values provided by the placeholders you mentioned, it is preferable to have one variable for each of them (if you desire to perform operations on them and for flexibility). Therefore, the parameters should look like the following:

param(
[string] $smsnumber = "",
[string] $sitename = "",
[string] $device = "",
[string] $name = "",
[string] $status = "",
[string] $down = "",
[string] $message = "",
)

The Parameters field under "Execute Program" in the notification template must also be updated to pass all the placeholders in the same order:

"PHONENUMBER" "[%sitename]" "%device" "%name" "%status" "%down" "(%message)"

The phone number must be passed to the script as well, after verification the placeholders %smsnumber and %smstext are only usable within the notification delivery settings.

Finally, you can use the variables within the body you send.

Regards.

Created on Jul 25, 2022 7:39:33 AM by  Florian Lesage [Paessler Support]

Last change on Jul 25, 2022 7:43:40 AM by  Florian Lesage [Paessler Support]



Votes:

0

Hi Team,

Thanks for the details.

I have updated the details given in script and change the parameter option in PRTG under "Execute Program" but did get the expected output in the smstext . It shows as just "smstext"

=====================================================

Updated Script
============

param(
[string] $smsnumber = "",
[string] $sitename = "",
[string] $device = "",
[string] $name = "",
[string] $status = "",
[string] $down = "",
[string] $message = ""
)

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "App 6d2e1d1274b8c344b5be3a6066e639ce-0155c1f8-6847-47bb-9e4b-88ed2322ea19")
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")

$body = "{`n  `"messages`": [`n    {`n      `"destinations`": [`n        {`n          `"to`": `"+971582749858`"`n        }`n      ],`n      `"from`": `"Info`",`n      `"text`": `"%smstext`"`n    }`n  ]`n}"

$response = Invoke-RestMethod 'http://3v3nx1.api.infobip.com/sms/2/text/advanced' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
=================================

I need to pass the full parameters in the SMS text field. The %smstext contains below information.

"PHONENUMBER" "[%sitename]" "%device" "%name" "%status" "%down" "(%message)"

How do we put the above information in the %smstext variable in the script? Please help

Created on Jul 26, 2022 7:43:52 AM

Last change on Jul 26, 2022 3:51:05 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Hi,

The placeholder %smstext can not be used here I'm afraid, this is why it is not present as parameter within the script. However, this is not a problem as you can pass other placeholders such as the one configured under Send SMS/Pager Message (in the notification template).

With the parameters below defined in the Parameters field of the Execute Program action, the script will receive the corresponding value for each of them in the same order. "PHONENUMBER" "[%sitename]" "%device" "%name" "%status" "%down" "(%message)"

Of course, PHONENUMBER must be replaced by the phone number the sms must be sent to.

You will find all placeholders available here: https://www.paessler.com/manuals/prtg/list_of_placeholders_for_notifications

Created on Jul 27, 2022 5:48:12 AM by  Florian Lesage [Paessler Support]

Last change on Jul 27, 2022 5:49:23 AM by  Florian Lesage [Paessler Support]



Votes:

0

Hi,

Thanks for the solution.

Just one more query, how we can send SMS to multiple phone numbers or users. Where I have to do the changes?

Thanks

Created on Aug 8, 2022 1:25:40 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.