Fusion - custom links and url's

This support forum board is for questions relating to Nagios Fusion.
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Fusion - custom links and url's

Post by vishfx »

Hi Nagios Team,

Am using Nagios Fusion 4.1.7

I had a few queries :

a) How can I add custom links or Dashboard links to the Fusion homepage , something like below, hope you get the idea.
add-Capture.PNG
b) Custom URL dashlet does not seem to work with URL's with basic auth like http://user:passwd@10.0.0.1:8080/mypage.html
I see a blank page.

Kindly assist.

Regards,
Vish.
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Fusion - custom links and url's

Post by ssax »

NOTE: Please note that while sometimes we may have time to do stuff like this to help you out to get what you want it should not be expected as the standard level of support, not all of us in the support department know how to develop or have the time to do it.

Please download the attached component that I wrote for you to do what you want.

Then go to Admin > Manage Components:
- Click the Browse button and select the downloaded zip file
- Click the Upload & Install button

Now if you go to the Home menu item you will see 3 new links:

Under Server Status you will see:

Code: Select all

Custom Home Link 1
Under Alerts you will see:

Code: Select all

Custom Alerts Link 1
Under Visualizations you will see:

Code: Select all

Custom Visualization Link 1 
To change them, please edit this file and adjust them:

Code: Select all

/usr/local/nagiosfusion/html/includes/components/fusioncustomlinks/fusioncustomlinks.inc.php
For example, you could change the top link from this:

Code: Select all

$menu->add_link(menu_link(_('Custom Home Link 1'), 'includes/components/fusioncustomlinks/tactical_overview.php'), 'home-server-status');
To this:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), 'https://username:password@your.domain.com/website/'), 'home-server-status');
Let us know if you have any questions.

Thank you!
You do not have the required permissions to view the files attached to this post.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Fusion - custom links and url's

Post by cdienger »

You could also add a new section to store the custom links:

Code: Select all

<?php
register_fusioncustomlinks();

function register_fusioncustomlinks() {
       $component_args = array(
           COMPONENT_TYPE              => COMPONENT,
           COMPONENT_NAME              => 'fusioncustomlinks',
           COMPONENT_TITLE             => _('Fusion Custom Links Component'),
           COMPONENT_VERSION           => '1.0.0',
           COMPONENT_DATE              => '03/26/2019',
           COMPONENT_AUTHOR            => 'Nagios Enterprises, LLC',
           COMPONENT_DESCRIPTION       => _('Provides Custom Menu Entries'),
           COMPONENT_REQUIRES_VERSION  => 4100,
           COMPONENT_FUNCTION          => 'fusioncustomlinks_successful_registration',
   );

   register_component($component_args);
}

function fusioncustomlinks_successful_registration() {
   register_fusioncustomlinks_callbacks();
}

function register_fusioncustomlinks_menu($cb, &$menu) {
    
    $menu->add_section('home', _('stuff'), 'home-stuff');
    
   $menu->add_link(menu_link(_('Nagios'), 'http://www.nagios.com'), 'home-stuff');

}

// register callbacks for fusion functionality
function register_fusioncustomlinks_callbacks() {
   register_callback(CALLBACK_MENU_INITIALIZED, 'register_fusioncustomlinks_menu');
}

?>
I wasn't able to reproduce the problem with the basic auth - are there any special characters in the credentials maybe? Try using the browsers dev tools to monitor the network traffic to see what the issue may be.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Fusion - custom links and url's

Post by vishfx »

Thanks, Custom links works !!! I will try it out.


Yes, there are some special chars.
Below is a url which does not work with Custom URL Dashlet :

http://api_key:eyJrIjoiR0ZXZmt1UFc0OEpI ... sk&orgId=1

Also,
The fusion node I use can't talk to the internet.
So, Where can I download all the components listed under "Manage Components" ?
For eg:
Home Page Modification component is 4.0.1 dated 10/04/2017

From where can I download the latest versions ?

Regards,
Vish.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Fusion - custom links and url's

Post by ssax »

Run the URLs through a URL encoder such as this and use the encoded URLs instead:

https://meyerweb.com/eric/tools/dencoder/

Or you could change the code to this:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), rawurlencode('https://username:password@your.domain.com/website/')), 'home-server-status');
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Fusion - custom links and url's

Post by vishfx »

ssax wrote:Run the URLs through a URL encoder such as this and use the encoded URLs instead:

Code: Select all

$menu->add_link(menu_link(_('My Custom Link'), rawurlencode('https://username:password@your.domain.com/website/')), 'home-server-status');
I added the rawurlencode, but I get the below error :
The requested URL /nagiosfusion/http://username:password@your.domain.com/website/ was not found on this server.
It seems to be due to "/nagiosfusion/" to the URL.

I also see the below in chrome inspect :
Subresource requests whose URLs contain embedded credentials (e.g. `https://user:pass@host/`) are blocked. See https://www.chromestatus.com/feature/5669008342777856 for more details.
Kindly advise.

Regards,
Vish.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Fusion - custom links and url's

Post by ssax »

Please PM me your file with the changes so that I can review it.
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Fusion - custom links and url's

Post by vishfx »

Hi Sean,

I'll circle back with that info at a later point. Can live with it for now.

Meanwhile had another requirement,

I want to create a one-click enable/disable Maintenance page for a bunch of HOSTGROUPS/HOSTS
I know this can be achieved using curl call on the below :

http://nagiosxi-lab/nagiosxi/includes/c ... _HOSTGROUP

My question was , how can I deploy a custom 'host_maintenance.php' in the fusion folder "/usr/local/nagiosfusion/html/" for this functionality ?

The idea is to use Fusion as a single point of control.

Is this something that can be done ? Or if you have any other best practice , Kindly Advice ?

Regards,
Vish.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Fusion - custom links and url's

Post by ssax »

You would likely need to write your own component for this, please see here:

https://assets.nagios.com/downloads/nag ... onents.php
vishfx
Posts: 134
Joined: Tue Apr 24, 2018 12:30 pm

Re: Fusion - custom links and url's

Post by vishfx »

Thanks Sean.
I will check .

Meanwhile, I have attached a word doc with screenshots and related queries.
fusion-queries.docx
Kindly advise, if these are possible or the only option is to go with own component.

Regards,
Vish.
You do not have the required permissions to view the files attached to this post.
Locked