pass "logged on user" in quick action

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
DigNetwerk
Posts: 40
Joined: Fri Oct 25, 2013 7:29 am

pass "logged on user" in quick action

Post 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!
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: pass "logged on user" in quick action

Post 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
You do not have the required permissions to view the files attached to this post.
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: pass "logged on user" in quick action

Post by skynardo »

Great info, Thanks!
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: pass "logged on user" in quick action

Post by cdienger »

Thanks for sharing, SteveBeauchemin! Skynardo, did you have any further questions?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
skynardo
Posts: 136
Joined: Tue Sep 18, 2012 8:59 am
Location: St. Louis, MO

Re: pass "logged on user" in quick action

Post by skynardo »

cdienger, this wasn't my post/question I just happened upon it and found it useful.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: pass "logged on user" in quick action

Post by cdienger »

That sure is the case : ) Sorry for the confusion!

DigNetwerk, did you have more questions regarding this?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
DigNetwerk
Posts: 40
Joined: Fri Oct 25, 2013 7:29 am

Re: pass "logged on user" in quick action

Post by DigNetwerk »

Wow, thanks alot!

i think i know how to fish now ;-)
Locked