DX Unified Infrastructure Management

  • 1.  Kill process through a LUA script

    Posted Sep 21, 2016 12:58 PM

    I am trying to kill a process through a LUA and AO.

     

    My code:

     

    a = alarm.get()
    nimid = a.nimid
    domain = a.domain
    hub = a.origin
    robot = a.robot
    message = a.message

    pidproc = "4432"
    addr = "/"..domain.."/"..hub.."/"..robot.."/processes"

    args = pds.create()
    pds.putString(args, "pid", pidproc)
    tab, rc = nimbus.request(addr, "kill_process", args)

     

    The rc code is 0 but this doesn't affect anything, the process is not killed.

    If I use the probe utility it works well!

     

    Can you help me?



  • 2.  Re: Kill process through a LUA script

    Broadcom Employee
    Posted Sep 21, 2016 01:27 PM

    I would add some logging with the lua script

    print out the domain hub and robot variables after setting them

    and print out the addr variable after setting it.

     

    the code looks correct so all I can think of is there is a problem with the variables.

     

    Also set the probe loglevel to 5 and logsize to 15000

    and the controller loglevel  to 3 and logsize to 3000 and make sure you see the command com in.



  • 3.  Re: Kill process through a LUA script

    Posted Sep 22, 2016 04:09 AM

    Thank you for the suggestions.

    The variables are correct, I printed all of them and for pidproc variable I tried to trim the variable...but it don't has any space before or after the number so, the same results.

    I increased the loglevel, in the controller.log I don't see any relevant but in the processes.log:

     

    Script Run:

    Sep 22 09:01:42:495 processes: RREQUEST: kill_process <-172.17.0.43/57316 h=273 d=13
    Sep 22 09:01:42:496 processes: nimSockaddr2Ip - found 172.17.0.43
    Sep 22 09:01:42:496 processes: SREQUEST: verify_login ->172.17.0.43/48000
    Sep 22 09:01:42:496 processes: RREPLY: status=OK(0) <-172.17.0.43/48000 h=37 d=49
    Sep 22 09:01:42:496 processes: sockClose:0000000000AB9170:172.17.0.43/57317
    Sep 22 09:01:42:496 processes: SREQUEST: _close ->172.17.0.43/48000
    Sep 22 09:01:42:497 processes: Error from Find process(0): The parameter is incorrect.

    Sep 22 09:01:42:497 processes: SREPLY: status = 0(OK) ->172.17.0.43/57316
    Sep 22 09:01:42:497 processes: RREQUEST: _close <-172.17.0.43/57316 h=266 d=0
    Sep 22 09:01:42:497 processes: sockClose:0000000000AB7CB0:172.17.0.43/48020

     

    Using Probe Utility:

    Sep 22 09:03:21:398 processes: RREQUEST: kill_process <-172.17.0.43/58854 h=277 d=13
    Sep 22 09:03:21:399 processes: nimSockaddr2Ip - found 172.17.0.43
    Sep 22 09:03:21:399 processes: SREQUEST: verify_login ->172.17.0.43/48000
    Sep 22 09:03:21:400 processes: RREPLY: status=OK(0) <-172.17.0.43/48000 h=37 d=49
    Sep 22 09:03:21:400 processes: sockClose:0000000000AB9170:172.17.0.43/58877
    Sep 22 09:03:21:400 processes: SREQUEST: _close ->172.17.0.43/48000
    Sep 22 09:03:21:401 processes: SREPLY: status = 0(OK) ->172.17.0.43/58854

     

    I don't have any clue about what's wrong!



  • 4.  Re: Kill process through a LUA script
    Best Answer

    Broadcom Employee
    Posted Sep 22, 2016 11:45 AM

    I THINK the problem is the proc is being done as a string instead of integer and that is why you are getting the invalid argument as an integer is expect but a string is being supplied.

     

    maybe something like:

    pds.putInt (args,"pid",pidproc)

     

    hope that helps



  • 5.  Re: Kill process through a LUA script

    Posted Sep 22, 2016 12:05 PM

    Wow, that line solved the problem, it makes sense...

    Thank you!