DX Unified Infrastructure Management

 View Only
Expand all | Collapse all

UIM - SMS Integration (SMS URL Based)


Ankur_EhealthMay 20, 2016 06:27 AM

  • 1.  UIM - SMS Integration (SMS URL Based)

    Posted May 19, 2016 03:48 AM



    I have a SMS URL through which i am trying to send sms notification upon alarms, below is the structure of ths URL


    https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message>


    So given this, does anyone have any idea or a hint that how i exactly i can achieve this.


    As for me i simply tried making a Lua script in which i wrote: -


    os.execute("start chrome.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message> ");

    os.execute("start https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message> ");


    but as i execute i don't see anyhting happening nor it gave me any errors, so after some banging my head for a while i found that it does execute but somehow that particlar process goes into background and gets session 0 isolation which is something in windows, So for now i'm stuck here !!!!!



    Please let me know if you people got any idea or did came across this certain requirement.





  • 2.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 19, 2016 06:50 AM



    I've been using cURL for similar thing, so URL based SMS sending. Using then lua: action.command("curl.exe http://webaddress ".. parameters) and that has been working pretty nicely.



  • 3.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 19, 2016 09:30 AM

    Hi Teppo,


    I tried it but i am getting certain certificate errors from curl, did you use other parameters for this certificate error if you did got it ??




  • 4.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 19, 2016 09:42 AM

    Hi Teppo,


    Thanks, it's working now !!!


    Can you also tell me how i am suppose to pass the message text from the alarm in the URL ?? IN the URL there is parameter with message and i need to pass the alarm message there. Any ideas ???


    https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message>




  • 5.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 19, 2016 11:16 AM

    I am also trying to use script argument in this but somehow not able to get the result And i'm using $message as the argument in the script paramter in the profile i created in Auto-operator


    This is how i am writing it


    action.command("curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message>")

    message = SCRIPT_ARGUMENT

  • 6.  Re: UIM - SMS Integration (SMS URL Based)

    Broadcom Employee
    Posted May 19, 2016 04:33 PM

    here is an example of how to send en email.

    Not exactly the same but should work with a little modification to make yours work


    sendto = (" -To 5156815555@email.domain.net")

    sendfrom = (" -From nimsof@domain.com")

    smtpserver = (" -SmtpServer iport1.domain.com")

    command = ("\nPowershell")

    sendcommand = (" Send-MailMessage")



    -- Fetch all critical alarms, place in table 'al'.



    if al ~= nil then

    for i=1,#al do

    -- Place current row al[i] into a (for readability)


    -- Add hostname, severity, arrival time and message to variable

    subject = (" -Subject".." {"..a.severity.." alert".."}")

    emailbody = (" -Body".." \"".."`r`n'"..a.hostname.."'".."`r`n'"..a.time_arrival.."'".."`r`n'"..a.message.."'".."\"")





    --send SMTP alert




    Basically you have to get the alarm message into a variable and add it in BEFORE the action command line.

  • 7.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 05:00 AM

    Thanks Gene i'm trying with all inputs you have provided , but i am a complete newbie for this scripting n all. so if possible can you guide me exactly for the query and the output i'm looking for

    In the below URL i just want to put the alarm message on the bold part, that's all


    action.command("curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=<Alarm message>")




  • 8.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 05:16 AM

    Hi Gene,

    This time i wrote it like this


    msg = ("SCRIPT_PARAMETER")


    action.command("curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message=msg")


    but i don't know every time its the same, i suppose after doing this it should substitute the msg with the script parameter that i have mentioned in the script parameter in the profile.


    Can you please tell me what exactly am i doing wrong ?




  • 9.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 05:25 AM

    Hi Nura,


    now you are just sending a string ("curl....&message=msg"). You should do something like

    Command="curl ...... &message="..msg



    As Howard said, you need the put the variable content into that string before the action.command, or otherwise you need to reformat the whole long line a bit differently.



  • 10.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 05:40 AM

    Thanks Gene & TTahkappa,


    Thanks a lot i did got to send the string in the msg part , Now i am just wondering when triggering the alert the alarm message is not being added to it, i already added the script parameter $message but still i'm just being sent with the SCRIPT_PARAMETER text as the message


    msg = ("SCRIPT_PARAMETER")

    Command="curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message="..msg




    So am i still missing something ???







  • 11.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 05:54 AM

    I forgot to mention i'm trying to create an AO profile which will trigger script and will send the alarm message, that why i am using $message as the script parameter as shown in the pic shared before

  • 12.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:08 AM

    Hi Nura,


    might be that I am not understanding now, in your script you tell this:

              msg = ("SCRIPT_PARAMETER")

    so the variable msg is containing the text "SCRIPT_PARAMETER"


    You have to use the logic Gene explained in his first reply

         a=alarm.get() [this gets the alarm in table a]

    then use

         a.message [this uses the row message from table a]

    as the alarm message


    so something like this:



    Command="curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message="..a.message



  • 13.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:15 AM

    Ok, then what's the use of script parameter in AO profile ?? I thought I just have to select script parameter and pass it on in the script

    I am referring to the script parameter option provided in auto operator, profile tab whlie using script as the action

    I'll try the method you mentioned but still what's the use of script parameter in the profile tab of auto operator 



  • 14.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:22 AM



    yes you can use it also that way, then you have this in your code:

         msg=SCRIPT_ARGUMENT [it is ARGUMENT and no " around it]



         msg="SCRIPT_PARAMETER" [this is just the string]


    In our SMS implementation i use those SCRIPT_ARGUMENTs to send those phone numbers to script to where the SMS should be sent, that way same script can be used for several receivers.



  • 15.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:27 AM

    I already tried that way but gives me error.

  • 16.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:38 AM

    So if i write like this



    Command="curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message="msg




    and select $message in the script parameter in AO, then this should work right ? it should trigger a SMS which in the message context will contain the alarm message of any critical alert which i have selected in AO


    But somehow its not, its just sending msg as the message




  • 17.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:49 AM

    could you try that




  • 18.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:54 AM

    Ok i will, hey btw that script parameter did work but not completely as it seems like its just picking the first word from the alarm message, any ideas why ??


    And yes i'm trying the other method but it will take some time as i'm so dull with scripting n all. Though what i want is to just trigger an alert with each critical alert, so if i try the other method do i just need to write those two lines




  • 19.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 06:59 AM


    every word in that message are it's own parameter in argument table, then you need to have some kind of loop to parse them together in one string.


    Believe me, the a.message is much easier, and all you need is already in examples above.



  • 20.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 07:00 AM

    I'll try the other method you said about, this script parameter seems not so reliable, it seems be sending message on each count of the message

  • 21.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 07:03 AM

    Yes, i'm trying alarm get solution now, just getting the pieces together from the thread about where and what to write in the script. THANKS GENE AND TEPPO

  • 22.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 07:04 AM

    That is because you have Action mode = message arrival! That means that every time message arrives.


    Change that to "On overdue age" 30s, then it sends only once, and 30 secs after the message first comes.



  • 23.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 07:12 AM

    ok, Teppo if it's not much to ask can you provide with the whole code thing that i need to write in script for my scenario using that alarm get uhhh thing. simple scenario trigger alert on critical and just send alarm message content (the message context only).


    Also do you know why its just sending only the first word of the message text For ex: the mesaage is - Alarm on abc, then its just sending "Alarm"




  • 24.  Re: UIM - SMS Integration (SMS URL Based)
    Best Answer

    Posted May 20, 2016 07:57 AM

    first: the argument is a table, every word is one part of that, check lua tables about how tho handle those.


    the code is from my earlier example:


    Command="curl.exe https://<IP>:8443/bulksms/bulksms?username=abc^&password=****^&dlr=1^&destination=999999999^&source=ABCD^&message="..a.message



    it is then much more easier to test if you use one existing alarm, and add its ID into alarm.get, like      a=alarm.get("AG123456-7890")

    then have the


    so you can debug what it sends out.



  • 25.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 08:39 AM

    Thanks Teppo, I got what's wrong, actually its only taking the first character as after that a space is there, i tried to send message while including the whole message in "" then i was able to send the whole message (i did this by simply pasting the url in the browser)


    So do you know how i can include the message part in some inverted commas or anything as if try it like this


    Command = "curl.exe https://sms6.routesms.com:8443/bulksms/bulksms?username=Saraswattran^&password=sd34ergh^&type=0^&dlr=1^&destination=919953248447^&source=SARBNK^&message=".."a.message"


    it just gives an error, so is there any way we can include the message string in something like inverted commas





  • 26.  Re: UIM - SMS Integration (SMS URL Based)

    Posted Jun 08, 2016 08:28 AM

    I don't know, have you search google about curl and those commas?

    One way could be that you save the message to file and then send that with curl.



  • 27.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 20, 2016 09:12 AM

    So is there any way i can include the string in commas or something which will send the whole message a single string ??

  • 28.  Re: UIM - SMS Integration (SMS URL Based)

    Posted May 23, 2016 07:20 AM




    I tried it this way


    a = alarm.get("BD78908247-03129")

    Command = "curl.exe https://sms6.routesms.com:8443/bulksms/bulksms?username=Saraswattran^&password=sd34ergh^&type=0^&dlr=1^&destination=919953248447^&source=SARBNK^&message=\""..a.message.."\""




    i did work but it seems like "" doesn't work in curl, So you do you have any idea how can i solve this problem, as if i just send the alarm text in normal way then curl takes every character after the space as a parameter (attached snap for this) and if i use it like this then it just does not do anything at all


    so did you had the problem in your scenario