TECHZEN Zenoss User Community ARCHIVE  

Getting username in user commands

Subject: Getting username in user commands
Author: Jad Baz
Posted: 2018-12-10 10:35

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
------------------------------


Subject: RE: Getting username in user commands
Author: Jane Curry
Posted: 2018-12-11 04:45

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
------------------------------


Subject: RE: Getting username in user commands
Author: Jad Baz
Posted: 2018-12-11 05:33

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
------------------------------


Subject: RE: Getting username in user commands
Author: Michael De Simone
Posted: 2018-12-13 09:29

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
------------------------------
/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
------------------------------


Subject: RE: Getting username in user commands
Author: Jason Olson
Posted: 2018-12-13 10:56

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
------------------------------


< Previous
No alerts received since last four days
  Next
Zenoss 6.2.1, are application audit logs not available in Zenoss Core?
>