DX Unified Infrastructure Management

  • 1.  LUA script to RDP

    Posted Feb 16, 2016 09:21 AM

    Hi,

     

    Can we use LUA to rdp to a server? If yes, can someone help me with the details.

     

    I know that this can be done by calling the nexec probe and passing the arguments, but I am trying to do it through lua. Any suggestion towards this will be much appreciated.

     

     

    -kag



  • 2.  Re: LUA script to RDP

    Posted Feb 16, 2016 12:18 PM

    Whats the context? What component are you having run the script? Lua can easily run executables

     

    -jon



  • 3.  Re: LUA script to RDP

    Posted Feb 17, 2016 04:29 AM

    Hi Jon,

     

    I am trying to run a script after a robot inactive alert to verify the following

    1) Ping the source to see if it respond and append the result in the alert message

    2) Verify if the server is hung or not : On this I thought if we are able to rdp and logoff back or check  if rdp does function. Our NOC team normally tries to ping and check if they are able to rdp or not.

     

    I also found that we could try test_service callback in the net_connect over the port 3389. However, I am not sure if we should add this port across all servers and dont wanna create confusions. So, I thought if we can make the script able to login and logoff successfully and append the message in the alert so that the team has a better understanding. I also understand that we can use nexec probe to call powershell do this, however this is a backup plan in case we cannot try this using lua. All that I am trying to do is to check if the robot is hung or not and add the message to alert post the ping test. This is the script

     

    alarm=alarm.list("message","Robot % is inactive")

    if alarm ~= nil then

       for i = 1,#alarm do

          a = alarm[i]

          printf("%02d %s %s %s",i,a.source,a.message)

          alert = a.source

          print(alert)

          ping_success = action.ping(alert)

             if ping_success then

                print("Ping success "..alert)

                ping_OK = "however pings OK"

                a.message = a.message.." "..ping_OK

                alarm.set (a)

             else

                print("Ping fail "..alert)

                ping_fail = "and no response to ping!"

                a.message = a.message.." "..ping_fail

                alarm.set(a)

             end

       end

    end

     

    Let me know your thoughts here.

     

    -kag



  • 4.  Re: LUA script to RDP

    Posted Feb 19, 2016 09:53 AM

    Kag,

     

    I really think Ping Up/Down should be built into the product & not require a LUA script & all this NAS modification with the Auto-Operators!!! Robot Inactive is ambiguous & doesn't say if the Robot is the problem or the server down is the root cause...

     

    Your script looks similar to the script I got from someone at CA, but it's a bit different. Here is the Full script I was given, except that I modified the Message Add lines for appending to the Alarm Text (I left the original lines, but commented them out). It works in my UIM server.

     

    -- Find inactive robots, ping them to see if just the robot which is down or the server.

    -- The script assumes robot inactive alarms from the hub have been changed to major, this could always be handled by the script of course

    -- just insert the following lines after line 26

    -- a.level = 4

    -- a.severity = major

     

    --Find inactive robot alarm(s)

    al=alarm.list("message","Robot % is inactive")

    if al ~= nil then

       for i = 1,#al do

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

          a = al[i]

          --
    Print nimid, hostname, severity and message for troubleshooting

          printf("%02d %s %s
    %s"
    ,i,a.source,a.severity,a.message)

          -- Get the ip of the robot from
    the alarm

          ip_addr = a.source

          -- Print for troubleshooting

          print(ip_addr)

          -- Ping the ip

          ping_success = action.ping(ip_addr)

             if ping_success then

                -- Print the status for
    troubleshooting

                print("Ping success
    "
    ..ip_addr)

                -- Edit the alarm message to
    to assist ops

                -- message_add_OK = "but
    server responds to ping OK"

                message_add_OK = "- PING OK"

                a.message = a.message.." "..message_add_OK

                alarm.set (a)

             else

                --Print the status for
    troubleshooting

                print("Ping fail "..ip_addr)

                -- Edit the alarm message to
    assist ops

                -- message_add_fail =
    "and no response to ping!"

                message_add_fail = "- PING Failure"

                a.message = a.message.." "..message_add_fail

                -- Change the severity to
    critical

                a.level = 5

                a.severity = critical

                alarm.set(a)

             end

       end

    end

     

    Either change the Robot Inactive Alarms to Major, or make the minor line changes in the script.

    UIM_Robot-Inactive-Script_PROFILE-SETUP_3.png

    You will also need a Profile to trigger the script when the Alarms come in. Something like this:

    Action Type: Script

    Script: {Script name}

    Action Mode: On Message Arrival

    Severity Level: Major & Critical

    Message String:     /(?i).*Robot[\w\d\s]*inactive.*/        <--- This is the Regular Expression for catching all the "Robot [Server Name] is inactive" Alarms.

     

    UIM_Robot-Inactive-Script_PROFILE-SETUP.PNG

     

    Let me know if this resolves your problem...

     

    Regards,

        Mike



  • 5.  Re: LUA script to RDP

    Posted Feb 19, 2016 11:41 AM
      |   view attached

    Hi Mike,

     

    Thanks for the update. And yes, I am trying to modify the script by making it do some additional work that will get rid of the ambiguity that not being able to identify if it is because of a server hung state. We have integrated our monitoring system with ITSM for auto ticketing. And the need is to get notified about the server state on a robot inactive alert. This change will ensure that the ticket is prioritized appropriately for the same so that the technical tracks are notified appropriately.

     

     

    -kag



  • 6.  Re: LUA script to RDP

    Posted Feb 19, 2016 12:04 PM

    Kag,

     

    If you do the steps with this script, you will change the Alarms for "Robot [Server] is inactive" --> "Robot [Server] is inactive - PING OK" (or PING Failure).

    UIM-Robot-Ping-Alarms.png

     

    You can do an easy modification to the script and make the Alarm Text say "Robot [Server] is inactive - Robot Down" or "Robot [Server] is inactive - Server Down".

    message_add_OK = "- Robot Down"

    &

    message_add_fail = "- Server Down"

     

    Does that resolve your problem so that the Alarms have more meaning?

     

    Regards,

    Mike



  • 7.  Re: LUA script to RDP

    Posted Aug 28, 2017 02:26 PM

    I have tried this script but found some issues that I would imagine others have experienced as well.  See my comments in https://communities.ca.com/thread/241721810 for the issues I am having.  Unless I have something else configured causing this that I have yet to find.

     



  • 8.  Re: LUA script to RDP

    Posted Aug 28, 2017 04:34 PM

    Yes, the original script I was sent from someone at CA had some quirks.
    Get rid of the loop: 
    al=alarm.list("message","Robot % is inactive")

     

    Make the script changes like this:

    -- Find inactive robots, ping them to see if just the robot which is down or the server.

    -- The script assumes robot inactive alarms from the hub have been changed to major, this could always be handled by the script of course

    -- just insert the following lines after line 26

    -- a.level = 4

    -- a.severity = major

     

    --Find inactive robot alarm(s)

    a=alarm.get()

    if a ~= nil then

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

       -- a = al

       -- Print nimid, hostname, severity and message for troubleshooting

       printf("%s %s %s",a.source,a.severity,a.message)

       -- Get the ip of the robot from the alarm

       ip_addr = a.source

       -- Print for troubleshooting

       print(ip_addr)

       -- Ping the ip

       ping_success = action.ping(ip_addr)

       if ping_success then

          -- Print the status for troubleshooting

          print("Ping success "..ip_addr)

          -- Edit the alarm message to to assist ops

          -- message_add_OK = "but server responds to ping OK"

          message_add_OK = "- PING OK"

          a.message = a.message.." "..message_add_OK

          alarm.set (a)

       else

          --Print the status for troubleshooting

          print("Ping fail "..ip_addr)

          -- Edit the alarm message to assist ops

          -- message_add_fail = "and no response to ping!"

          message_add_fail = "- PING Failure"

          a.message = a.message.." "..message_add_fail

          -- Change the severity to critical

          a.level = 5

          a.severity = critical

          alarm.set(a)

       end

    end

     

     

    By changing to the Alarm.Get(), it's only getting 1 Alarm. Before the loop was changing All the Robot Inactive Alarms everytime a new one came in.

    This way it will only go through the script once on New Alarm Message Arrival. Then the rest of Robot Alarms for that same system will be suppressed as Duplicates and only increase the Alarm Count.

    Test it and let us know how it works out...



  • 9.  Re: LUA script to RDP

    Posted Aug 28, 2017 05:06 PM

    Also change your Profile - Message String to:

    /(?i)^Robot[\w\d\s]*inactive$/

    Otherwise you can get into a loop where it keeps appending the extra Text over & over again to the end of the message.

     

    The Main Problem is that the Hub keeps repeating the Alarm every 5-15 min (the original Alarm without the Ping test). You'll notice the Count increases. Then the script runs again & appends the correct Ping results again, but if you watch the IM Console, you'll keep seeing the message reset & then re-append.

    I don't have a solution for that, other than to complain to CA that the HUB should be doing the PING TEST and produce different Alarms for depending if it's a Robot Down, Vs Server Unreachable!



  • 10.  Re: LUA script to RDP

    Posted Aug 29, 2017 05:15 PM

    Look at this article: NAS script to ping inactive robots to check if just robot or robot and server are down 

    Check out the solution Posted today by Alquin Gayle. This might be the solution you are looking for.