have multiple "Customer View" on a single map

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
krabs
Posts: 4
Joined: Wed Oct 19, 2011 9:55 am

have multiple "Customer View" on a single map

Post by krabs »

Hi everybody.

I'm trying to find a way to provide statusmap views to my customers based on a single map.
what I did first was to write the right contact in each host/service and write these contacts in cgi.cfg and in htpasswd.users

Like this, customers see only their own host on the statusmap, but, they have a "global" view of the whole statusmap. I mean, if some hosts are down, they see red spots even if they don't see details on hosts..
In host/service view it's OK (because it's well filtered). But in statusmap... :cry:

I'm searching in statusmap.c how to not to draw some hosts based on contact but I didn't find right objects/method at this time..

Somebody can help ?
thank you.
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: have multiple "Customer View" on a single map

Post by jsmurphy »

The best way to achieve this would probably be building custom maps with Nagvis http://www.nagvis.org/. I believe this has the functionality to restrict who can view what, but there's going to be quite a bit of additional configuration overhead.
krabs
Posts: 4
Joined: Wed Oct 19, 2011 9:55 am

Re: have multiple "Customer View" on a single map

Post by krabs »

Thanks.
I'll try nagvis once I'll have time :) it seems to be a huge "add-on" :shock: interesting..
Seeking 2 hours in cgi/* , i think i'm about to find what I need to modify statusmap.c
I'll keep you informed.
krabs
Posts: 4
Joined: Wed Oct 19, 2011 9:55 am

Re: have multiple "Customer View" on a single map

Post by krabs »

Now, I have replaced the function "find_eligible_hosts" by the following code (for testing purpose) :

Code: Select all

   int total_eligible_hosts=0;
    host *temp_host;
    host *previous_host;
    temp_host=host_list;
    previous_host=host_list;

    while(temp_host!=NULL){
        if(is_authorized_for_host(temp_host,&current_authdata)==FALSE){
            if (total_eligible_hosts==0){
                host_list=host_list->next;
                temp_host=host_list;
                previous_host=host_list;
            }else if(temp_host->next==NULL){
                previous_host->next=NULL;
                return;
            }else{
                previous_host->next=temp_host->next;
                temp_host=temp_host->next;
            }
        }else{
            total_eligible_hosts++;
            previous_host=temp_host;
            temp_host=temp_host->next;
        }
    }
    return;
it's a little bit drastic but it works :) I delete from the host_list all hosts I don't want to hear about (according to auth) :lol:
I just have some problem about parent/child links. A host with a parent which has been deleted is drew at same coords as "nagios process" icon..

Next step is to update the code above by adding the following action :

each time I delete a host, I search its children and I update their parents by replacing with parents of the deleted host..
In this way I will keep relation between host as much as possible...

let's go eat a sandwich and back to work :P
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: have multiple "Customer View" on a single map

Post by jsmurphy »

that's pretty cool, If you don't mind sharing i wouldn't mind checking that out when you work the bugs out of it :)
krabs
Posts: 4
Joined: Wed Oct 19, 2011 9:55 am

Re: have multiple "Customer View" on a single map

Post by krabs »

hi,

DONE :D

find_eligible_hosts has 2 steps :
1/ rewrite all parents for all hosts by selecting recursively (if necessary) only parents which will be kept. In others words, it's like "compressing" the map :roll:
2/ delete all hosts which we need to hide.

Before while struct in find_eligible_hosts, I add this for the step 1 :

Code: Select all

host *temp_host_ini;
    for (temp_host_ini=host_list;temp_host_ini!=NULL;temp_host_ini=temp_host_ini->next){
        temp_host_ini->parent_hosts=good_parents(temp_host_ini);
    }
And the code of the function "good_parents" :

Code: Select all

hostsmember *good_parents(host *a_host){

    hostsmember *new_list;
    hostsmember *p;
    host *p2;
    hostsmember *new_hostm;
    new_list=NULL;

    for (p=a_host->parent_hosts;p!=NULL;p=p->next){
        p2=find_host(p->host_name);
        if (is_authorized_for_host(p2,&current_authdata)==TRUE){
            new_hostm=(hostsmember *)malloc(sizeof(hostsmember));
            new_hostm->host_name=(char *)strdup(p2->name);
            new_hostm->next=NULL;
            if (new_list==NULL)
                new_list=new_hostm;
            else
                new_list->next=new_hostm;
        }else{
            if (new_list==NULL)
                new_list=good_parents(p2);
            else
                new_list->next=good_parents(p2);
        }
    }
    return new_list;
}
Don't forget this :

In display_map function, move find_eligible_hosts() just after load_background_image()

I'm open for discussion/debug/improvment.
Locked