Page 1 of 1

pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 7:46 am
by DigNetwerk
Hi,

I'm building a quick action where I have to pass the name of the user that initiates the quick action.
is there any marco i can use for this?

I already lookin here: https://assets.nagios.com/downloads/nag ... ios-XI.pdf
but couldn't find one.

thx in advance!

Re: pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 10:19 am
by SteveBeauchemin
This is a dump of data that I found. Related to the Quick Action variables.

One for Services, one for Hosts. At the time I collected this information I think I found them all. This was built Dec 2016 on Nagios XI 5.4.2 or older.

I found it handy for me as an admin to have access to see these bits, so I made a quick action that only I can use. I am attaching a small perl file that displays the data for a specific host or service. I put the file here -> /usr/local/nagios/libexec/eventhandlers/readparams.pl and the quick actions are aimed there.

I created 2 quick actions, of for services, and one for hosts.
Defined here for:
Object Type: Host
Action Type: Command
Action Text: Debug Helper - Dump all Variables for Host
Custom permissions only for my user account - or any other admins...
URL / Command: In the code block below

Code: Select all

/usr/local/nagios/libexec/eventhandlers/readparams.pl -username "%username% " -objecttype "%objecttype% " -notesurl "%notesurl% " -actionurl "%actionurl% " -notes "%notes% " -hostname "%hostname% " -hostaddress "%hostaddress% " -hostid "%hostid% " -hostdisplayname "%hostdisplayname% " -hostalias "%hostalias% " -hoststateid "%hoststateid% " -hoststatetype "%hoststatetype% " -hoststatustext "%hoststatustext% " -hoststatustextlong "%hoststatustextlong% " -hostperfdata "%hostperfdata% " -hostchecktype "%hostchecktype% " -hostactivechecks "%hostactivechecks% " -hostpassivechecks "%hostpassivechecks% " -hostnotifications "%hostnotifications% " -hostacknowledged "%hostacknowledged% " -hosteventhandler "%hosteventhandler% " -hostflapdetection "%hostflapdetection% " -hostisflapping "%hostisflapping% " -hostpercentstatechange "%hostpercentstatechange% " -hostdowntime "%hostdowntime% " -hostlatency "%hostlatency% " -hostexectime "%hostexectime% " -hostlastcheck "%hostlastcheck% " -hostnextcheck "%hostnextcheck% " -hosthasbeenchecked "%hosthasbeenchecked% " -hostshouldbescheduled "%hostshouldbescheduled% " -hostcurrentattempt "%hostcurrentattempt% " -hostmaxattempts "%hostmaxattempts% " -hostgroupnames "%hostgroupnames% " -hostownerpoc "%_HOST_OWNER_POC% "
Defined here for:
Object Type: Service
Action Type: Command
Action Text: Debug Helper - Dump all Variables for Service
Custom permissions only for my user account - or any other admins...
URL / Command: In the code block

Code: Select all

/usr/local/nagios/libexec/eventhandlers/readparams.pl -username "%username% " -objecttype "%objecttype% " -notesurl "%notesurl% " -actionurl "%actionurl% " -notes "%notes% " -hostname "%hostname% " -hostaddress "%hostaddress% " -hostid "%hostid% " -hostdisplayname "%hostdisplayname% " -hostalias "%hostalias% " -hoststateid "%hoststateid% " -hoststatetype "%hoststatetype% " -hoststatustext "%hoststatustext% " -hoststatustextlong "%hoststatustextlong% " -hostperfdata "%hostperfdata% " -hostchecktype "%hostchecktype% " -hostactivechecks "%hostactivechecks% " -hostpassivechecks "%hostpassivechecks% " -hostnotifications "%hostnotifications% " -hostacknowledged "%hostacknowledged% " -hosteventhandler "%hosteventhandler% " -hostflapdetection "%hostflapdetection% " -hostisflapping "%hostisflapping% " -hostpercentstatechange "%hostpercentstatechange% " -hostdowntime "%hostdowntime% " -hostlatency "%hostlatency% " -hostexectime "%hostexectime% " -hostlastcheck "%hostlastcheck% " -hostnextcheck "%hostnextcheck% " -hosthasbeenchecked "%hosthasbeenchecked% " -hostshouldbescheduled "%hostshouldbescheduled% " -hostcurrentattempt "%hostcurrentattempt% " -hostmaxattempts "%hostmaxattempts% " -servicegroupnames "%servicegroupnames% " -serviceid "%serviceid% " -servicedisplayname "%servicedisplayname% " -servicestateid "%servicestateid% " -servicestatetype "%servicestatetype% " -servicestatustext "%servicestatustext% " -servicestatustextlong "%servicestatustextlong% " -serviceperfdata "%serviceperfdata% " -servicechecktype "%servicechecktype% " -serviceactivechecks "%serviceactivechecks% " -servicepassivechecks "%servicepassivechecks% " -servicenotifications "%servicenotifications% " -serviceacknowledged "%serviceacknowledged% " -serviceeventhandler "%serviceeventhandler% " -serviceflapdetection "%serviceflapdetection% " -serviceisflapping "%serviceisflapping% " -servicepercentstatechange "%servicepercentstatechange% " -servicedowntime "%servicedowntime% " -servicelatency "%servicelatency% " -serviceexectime "%serviceexectime% " -servicelastcheck "%servicelastcheck% " -servicenextcheck "%servicenextcheck% " -servicehasbeenchecked "%servicehasbeenchecked% " -serviceshouldbescheduled "%serviceshouldbescheduled% " -servicecurrentattempt "%servicecurrentattempt% " -servicemaxattempts "%servicemaxattempts% " -serviceownerpoc "%_SERVICE_OWNER_POC% "
The pl file is attached in a zip format.

Once you have the quick action defined, even if you do not use the pl file, you can run it and see information. The pl file just make it a column. Nothing special.

As a special bonus - look at the very last item in the code block - That OWNER item is actually a Free Variable defined in a template. Basically, that means you can create ANY parameter you need and send it to the Quick Actions. Once you know the proper syntax...

I'm a believer in the 'teach a man to fish' concept. Now that you know more, you will not go hungry.

I know you only asked for the username, but maybe this data overload will help others too.

Steve B

Re: pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 11:06 am
by skynardo
Great info, Thanks!

Re: pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 1:27 pm
by cdienger
Thanks for sharing, SteveBeauchemin! Skynardo, did you have any further questions?

Re: pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 2:06 pm
by skynardo
cdienger, this wasn't my post/question I just happened upon it and found it useful.

Re: pass "logged on user" in quick action

Posted: Tue Jun 20, 2017 2:10 pm
by cdienger
That sure is the case : ) Sorry for the confusion!

DigNetwerk, did you have more questions regarding this?

Re: pass "logged on user" in quick action

Posted: Wed Jun 21, 2017 1:30 am
by DigNetwerk
Wow, thanks alot!

i think i know how to fish now ;-)