Configuration & Administration

Expand all | Collapse all

Getting username in user commands

Jump to Best Answer
  • 1.  Getting username in user commands

    Posted 12-10-2018 09:35 AM
    Hello,

    Is there a way to get the username of the user who executed a command?
    I mean something like ${user/id} since we can already get the device it is being executed on with ${device/id}

    Thank you


    ------------------------------
    Jad
    ------------------------------


  • 2.  RE: Getting username in user commands

    Posted 12-11-2018 03:45 AM
    Is this a command being executed by zencommand?  If not, please explain further.

    And where do you want to gather the parameters like the device and user?  In a template?  in the event console?

    Cheers,
    Jane

    ------------------------------
    Jane Curry
    Skills 1st United Kingdom
    jane.curry@skills-1st.co.uk
    ------------------------------



  • 3.  RE: Getting username in user commands

    Posted 12-11-2018 04:33 AM
    I'm performing some custom logic where my user commands are using a shell script on disk. So a typical command would look like
    /bin/sh /var/zenoss/command.sh actionX ${device/id}

    In my command.sh script for example, actionX is $1, ${device/id} is $2.
    This is a very custom setup where we are doing some custom work to execute commands on devices. This is working for us right now.
    I would like to be able to catch the user id of the user who performed this command in the same script. So my command would now look like:
    /bin/sh /var/zenoss/command.sh actionX ${device/id} ${user/id} (if there is such a thing)


    ------------------------------
    Jad
    ------------------------------



  • 4.  RE: Getting username in user commands

    Posted 12-13-2018 08:29 AM
    Edited by Michael De Simone 12-13-2018 08:30 AM
    You can use ${dev/zCommandUsername} to get the userid Zenoss is using to ssh to the device. I think that's what you are looking for. If you are just executing the commands on the Zenoss server, everything is run as the zenoss user.

    ------------------------------
    Michael De Simone
    Zenoss
    ------------------------------



  • 5.  RE: Getting username in user commands
    Best Answer

    Posted 12-13-2018 09:56 AM
    Further to that, if the command is run from within Zenoss, the username and password is defined in the zCommandUsername and zCommandPassword properties, which make for a generic command ID and not who initiated the command within the application. I suspect you're looking for an audit trail, which doesn't exist in the community edition. You'll need to purchase a subscription to Resource Manager to get that.

    ------------------------------
    Jason Olson
    ------------------------------