Page 1 of 2
Custom Quick Actions
Posted: Wed Mar 05, 2014 10:45 am
by WillemDH
Hello,
Remember I wrote some Powershell script that installs the NSCP Agent on a Windows server?
http://support.nagios.com/forum/viewtop ... l&start=10
This is working fine in the meantime, but I have a new issue popping up as we have more and more endusers wanting acces to the Nagios data.
So I made an account with read-only permissions that has only acces to four hosts, but it seems the quick actions that link to the Powershell scripts are also shown for users with read-only permissions. This is really not acceptable, as I don't want endusers to start re-installing NSCP, updating nsclient.ini etc...
Is there a way to prevent my actions to show up in the quick actions of 'users'. Ideally they should only show up on the quick actions of users with admin permissions.
Thanks for any feedback. Let me know if I should make a feature request.
Grtz..
Willem
Re: Custom Quick Actions
Posted: Wed Mar 05, 2014 11:29 am
by lmiltchev
It's a good idea for a feature request for the "Actions" component. It would be nice to be able to limit who can view custom actions, based on the user's type, regex filtering, etc. I already filed an internal feature request. You are welcome to file another one on the
public site if you wish.
Re: Custom Quick Actions
Posted: Wed Mar 05, 2014 12:22 pm
by BanditBBS
fully agree this is a needed feature. I have a hack for you WillemDH, look here:
http://support.nagios.com/forum/viewtop ... 135#p82915
I did that to remove "disable notifications" but you could put in there the is_admin() or is_advanced_user() and only display something for the advanced users and/or admins.
keep in mind, you will have to redo this "hack" any time you perform an upgrade.
Re: Custom Quick Actions
Posted: Wed Mar 05, 2014 1:54 pm
by WillemDH
Feature request made =>
http://tracker.nagios.com/view.php?id=509
I'll try that Bandit, thanks for the tip.
Re: Custom Quick Actions
Posted: Wed Mar 05, 2014 2:09 pm
by slansing
Thank you for the submission, let us know if the "hack" works out for you in the meantime.
Re: Custom Quick Actions
Posted: Wed Mar 05, 2014 2:10 pm
by abrist
I updated the internal bug report to include your hack bandit.
Re: Custom Quick Actions
Posted: Thu Mar 06, 2014 5:50 am
by WillemDH
For ajaxhelpers-hoststatus.inc.php I suspect I would need to change the following:
Code: Select all
$cbdata=array(
"hostname" => $hostname,
"host_id" => $host_id,
"hoststatus_xml" => $xml,
"actions" => array(),
);
do_callbacks(CALLBACK_HOST_DETAIL_ACTION_LINK,$cbdata);
$customactions=grab_array_var($cbdata,"actions",array());
foreach($customactions as $ca){
$output.=$ca;
}
For ajaxhelpers-servicestatus.inc.php
Code: Select all
$cbdata=array(
"hostname" => $hostname,
"servicename" => $servicename,
"service_id" => $service_id,
"servicestatus_xml" => $xml,
"actions" => array(),
);
do_callbacks(CALLBACK_SERVICE_DETAIL_ACTION_LINK,$cbdata);
$customactions=grab_array_var($cbdata,"actions",array());
foreach($customactions as $ca){
$output.=$ca;
}
Where exactly should I put is_admin() or is_advanced_user() ?
Re: Custom Quick Actions
Posted: Thu Mar 06, 2014 9:12 am
by BanditBBS
You would wrap an is_admin around there somewhere...but it will affect ALL custom actions.
Something like this:
Code: Select all
if is_admin() {
$cbdata=array(
"hostname" => $hostname,
"servicename" => $servicename,
"service_id" => $service_id,
"servicestatus_xml" => $xml,
"actions" => array(),
);
do_callbacks(CALLBACK_SERVICE_DETAIL_ACTION_LINK,$cbdata);
$customactions=grab_array_var($cbdata,"actions",array());
foreach($customactions as $ca){
$output.=$ca;
}
}
Make a backup of the file and give it a shot...or better yet, if you have a dev server do it there

Re: Custom Quick Actions
Posted: Thu Mar 06, 2014 11:33 am
by lmiltchev
We will do some testing on our end and will keep you posted.
Re: Custom Quick Actions
Posted: Thu Mar 06, 2014 4:02 pm
by WillemDH
Well I still didn't find the time to setup a test server

I fear it will take some time before I can find some time.
But I'll wait for the results of the test by lmitchev..
Grtz..