On 14 Aug 2009, at 04:50, James Whittington wrote:

We have been playing around with different ideas on how to link Site Nagvis Maps to Site hostgroups and I have stumbled across something that almost does what I am looking for.
We currently use the management url feature of a host template to create dummy sitemap hosts to link to the correct nagvis map but knowing to click on the managed by link of the sitemap host isn’t very intuitive.
One of my co-workers said it would be really cool if we just added a new menu item on the arrow submenu in the hostgroup hierarchy area.
 
I haven’t really tried to learn the catalyst web framework before  but quickly found when the hostgroup menu items were populated so I started playing with it a bit.
The following is the modified hostgroup menu page with a new “Map for” option that would try to link to a nagvis map with the hostgroup name.
It works only if your map and hostgroup name are the same..
 
[%
PROCESS object_info_base;
opsview_hostgroup = c.model("OpsviewDB::Hostgroup").retrieve(object.id);
'<a href=""detail"); '" class="action">Detail for '; object.name; '</a><br />';
'<a href="" class="action">Map for '; object.name; '</a><br />';
IF object.can_be_changed_by(c.user);
  '<a href=""downtime"); '" class="action">Schedule downtime</a><br />';
END;
info_status(opsview_hostgroup);
%]
 
My question is can I conditionally display the menu item based on the existence of the map?
I could either scan the nagvis maps on the filesystem or build a table of maps but I wasn’t sure what my options were with the opsview framework.

Yes, you could amend the template something like (this is untested)

[% PERL %]
if( -f '/usr/local/nagios/nagvis/etc/maps/'.$stash->get('object.name').'.cfg') {
  print PERLOUT '<a href="" class="action">Map for '.$stash->get('object.name').'</a><br />'.$/;
}
[% END %]

I have recorded it (https://secure.opsera.com/jira/browse/OPS-575) so we can look into doing it 'properly' at some point in the future (or sooner with a sponsor)

There are some more details on TT here: http://template-toolkit.org/docs/manual/Directives.html#section_PERL (I used perl here to get the file test operators which TT doesn't otherwise have that I know about)

  Duncs
 
-- 
Duncan Ferguson
Senior Developer



Opsera Limited | Unit 69 Suttons Business Park
Reading | Berkshire | RG6 1AZ | UK

Phone:   
+44 (0) 845 057 7887
Mobile
:   +44 (0) 7968 148 748
Skype:   duncan_j_ferguson     Email:   
[email protected]
www.opsera.com

Opsera Limited is registered in the UK under Company Number 5396532. Our registered office is Gorse View, Horsell Rise, Woking, SurreyGU21 4RB.

_______________________________________________
Opsview-users mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-users

Reply via email to