Page 1 of 1
User macro for actions component
Posted: Tue Aug 11, 2015 10:23 am
by WillemDH
Hello,
I already asked if it's possible to use a 'user' macro, so we can pass the user initiating the event chain to scripts for logging etc.
https://support.nagios.com/forum/viewto ... actor+user where TASK ID 5801 was created by Sean.
But now I have the same question for Nagios XI. I don't see an existing macro in the actions component documentation for the Nagios user initiating an action. As we have multiple actions where we need to know who initiated the action, I was wondering if it is already possible to somehow retrieve the user initiating the action in Nagios XI.
If not, please let me know, then I'll create a feature request for this.
Grtz
Willem
Re: User macro for actions component
Posted: Tue Aug 11, 2015 2:47 pm
by ssax
Looks like it would be possible:
If you edit:
Code: Select all
/usr/local/nagiosxi/html/includes/components/actions/actions.inc.php
And add (around line 973):
Code: Select all
"username" => "$_SESSION[username]",
So it looks like:
Code: Select all
$objectvars = array(
"objecttype" => "host",
"username" => "$_SESSION[username]",
"host" => $hostname,
Then at around line 1050 as well:
Code: Select all
$objectvars = array(
"objecttype" => "service",
"username" => "$_SESSION[username]",
"service" => $servicename,
Then you could use %
username% in the action URL and it would work for you.
Code: Select all
http://my.test.url/do_the_thing/?servicename=%servicename%&username=%username%
I've also submitted a feature request for it:
Code: Select all
NEW TASK ID 6244 created - Nagios XI Feature Request: Add the ability to use %username% in the actions component
Re: User macro for actions component
Posted: Thu Aug 13, 2015 8:12 am
by WillemDH
Sean,
It seems to work, but there is something weird. I set "Nagios - %
username%" in the Comment field in the Actions component. After Saving the actions, the field appears to be empty again. When executing the chain, it does seem to work however. if I set just Nagios - %
username% (without the double quotes, it does show.
Anyway it works. This particular use case I implemented it for was an event chain to initiate a VMware snapshot by the way. By providing the
username, our VMware admins can easily see who created the snashot. i'll see if I can find some time to release these scripts on the Nagios Exchange.
If one day we could provide field values in the Reactor action popup window, it would be perfect, then our sysadmins can also provide the reason for the snapshot for example. See
https://support.nagios.com/forum/viewto ... t=+reactor
Have a nice day and thanks alot.
Willem
Re: User macro for actions component
Posted: Thu Aug 13, 2015 3:08 pm
by ssax
Hmm, it's working for me in all the fields which field are you talking about, I don't see a comment field. Do you mean the command field? Can you send me a sanitized screenshot or paste the text with the field name?
Re: User macro for actions component
Posted: Fri Aug 14, 2015 2:54 am
by WillemDH
I'm sorry if I wasn't clear. The comment field is a field from my "NAF - Initiate VMware Snapshot" event chain. See screenshot.
Re: User macro for actions component
Posted: Fri Aug 14, 2015 10:40 am
by ssax
I believe we are running into the same type of bug as this (that we submitted earlier):
https://support.nagios.com/forum/viewto ... 54#p143154
Re: User macro for actions component
Posted: Mon Aug 17, 2015 8:30 am
by WillemDH
That is possible Sean. Although I thought this other issue was solved. Anyway this thread can be closed. Tx!
Re: User macro for actions component
Posted: Mon Aug 17, 2015 9:03 am
by hsmith
WillemDH wrote:That is possible Sean. Although I thought this other issue was solved. Anyway this thread can be closed. Tx!
Thanks for the feedback, Willem. I'll close this one.