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...
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.
have multiple "Customer View" on a single map
Re: have multiple "Customer View" on a single map
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.
Re: have multiple "Customer View" on a single map
Thanks.
I'll try nagvis once I'll have time it seems to be a huge "add-on" 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.
I'll try nagvis once I'll have time it seems to be a huge "add-on" 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.
Re: have multiple "Customer View" on a single map
Now, I have replaced the function "find_eligible_hosts" by the following code (for testing purpose) :
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)
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
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,¤t_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;
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
Re: have multiple "Customer View" on a single map
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
Re: have multiple "Customer View" on a single map
hi,
DONE
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
2/ delete all hosts which we need to hide.
Before while struct in find_eligible_hosts, I add this for the step 1 :
And the code of the function "good_parents" :
Don't forget this :
In display_map function, move find_eligible_hosts() just after load_background_image()
I'm open for discussion/debug/improvment.
DONE
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
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);
}
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,¤t_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;
}
In display_map function, move find_eligible_hosts() just after load_background_image()
I'm open for discussion/debug/improvment.