Saturday, May 25th 2013, 7:23am UTC+2

You are not logged in.

  • Login
  • Register

thygizmo

Beginner

Posts: 23

Gender: male

Location: Darmstadt

Number of monitoring servers: 3

Nagios Version: V3.4.1

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: 20

Number of services: +400

OS: SLES 11/RED HAT Enterprise / Solaris

Plugin Version: 1.4.16

NagVis Version: 1.7b3

Other Addons: MK Livestatus, Nagvis

1

Friday, August 10th 2012, 3:21pm

Cannot access NagVis macros within my Context Menu

Hi,
I was looking at the macro defintions used in the hoover menu (/nagvis/share/userfiles/templates/default.hover.html) which looks like this when you hover one of the services:



Basically I wanted to do something really simple such as to try to output the value of the 'Summary Output' when the user clicks on the first option of the context menu (named "Start Data Flow"):



To accoumplish this, I checked the contents of the "default.hover.html" file:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<table class="hover_table">
	<tr><th colspan="2">[lang_obj_type] ([lang_last_status_refresh]: [last_status_refresh])</th></tr>
	<tr><td class="label"><label>[lang_name]</label></td><td>[obj_name][obj_alias_braces]</td></tr>
	<!-- BEGIN service -->
	<tr><td class="label"><label>[lang_service_description]</label></td><td>[service_description]</td></tr>
	<!-- END service -->
	<!-- BEGIN host -->
	<tr><td class="label label[obj_state]"><label>[lang_state]</label></td><td class="state[obj_state]">[obj_state] [obj_in_downtime][obj_acknowledged] ([obj_state_type]
 - [obj_current_check_attempt]/[obj_max_check_attempts])</td></tr>
	<tr><td class="label"><label>[lang_output]</label></td><td>[obj_output]</td></tr>
	<tr><td class="label"><label>[lang_last_check]</label></td><td>[obj_last_check]</td></tr>
	<tr><td class="label"><label>[lang_next_check]</label></td><td>[obj_next_check]</td></tr>
	<tr><td class="label"><label>[lang_last_state_change]</label></td><td>[obj_last_state_change]</td></tr>
	<!-- END host -->
	<tr><td class="label label[obj_summary_state]"><label>[lang_summary_state]</label></td><td class="state[obj_summary_state]">[obj_summary_state] [obj_summary_in_downt
ime][obj_summary_acknowledged]</td></tr>
	<tr><td class="label"><label>[lang_summary_output]</label></td><td>[obj_summary_output]</td></tr>
	<!-- BEGIN service -->
	<tr><td class="label"><label>[lang_last_check]</label></td><td>[obj_last_check]</td></tr>
	<tr><td class="label"><label>[lang_next_check]</label></td><td>[obj_next_check]</td></tr>
	<tr><td class="label"><label>[lang_last_state_change]</label></td><td>[obj_last_state_change]</td></tr>
	<!-- END service -->
	<!-- BEGIN childs -->
	<tr><td colspan="2" class=child>
    	<table class=childs width="100%">
        	<tr>
        	<!-- BEGIN servicegroup --><td class="label"><label>[lang_child_name1]</label></td><!-- END servicegroup --><td class="label"><label>[lang_child_name]</label
></td><td class="label"><label>[lang_state]</label></td><td class="label"><label>[lang_output]</label></td>
        	</tr>
        	<!-- BEGIN loop_child -->
        	<tr><!-- BEGIN servicegroup_child --><td>[obj_name1]</td><!-- END servicegroup_child --><td>[obj_name]</td><td class="state[obj_summary_state]">[obj_summary_
state][obj_summary_in_downtime][obj_summary_acknowledged]</td><td>[obj_summary_output]</td></tr>
        	<!-- END loop_child -->
    	</table>
	</td></tr>
	<!-- END childs -->
</table>


From the hover output, I am assuming that the macro name that I am looking for ('Summary Output') should be "[obj_summary_output]"

With that in mind, I created a copy of this default file and also of the associated css file and ended up with:
- pfc4ears.context.css (which is just a copy of the default.context.css file)
- pfc4ears.context.html with the following content:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<ul>
	<!-- BEGIN automap_not_root -->
	<li><a href="javascript:window.location='index.php?mod=Map&act=view&show=[map_name]&'+getViewParams({'root':'[name]'});">[lang_make_root]</a></li>
	<!-- END automap_not_root -->

	<!-- BEGIN stateful -->
	<li><a href="#" onClick="refreshMapObject(event, '[obj_id]'); contextHide();return false">[lang_refresh_status]</a></li>
	<!-- END stateful -->

	<!-- BEGIN not_automap -->
	<!-- BEGIN permitted_edit -->
	<li class="spacer"></li>
	<li><a href="#" onClick="cloneObject(event, '[obj_id]');contextHide();return false">[lang_clone]</a></li>
	<!-- BEGIN locked -->
	<li><a href="#" onClick="toggleMapObjectLock(event, '[obj_id]'); contextHide();return false">[lang_unlock]</a></li>
	<!-- END locked -->
	<!-- BEGIN unlocked -->
	<li><a href="#" onClick="toggleMapObjectLock(event, '[obj_id]'); contextHide();return false">[lang_lock]</a></li>
	<li><a href="#" onClick="showAddModifyDialog('[map_name]', '[obj_id]');contextHide();return false">[lang_modify]</a></li>
	<li><a href="#" onClick="removeMapObject('[obj_id]', '[lang_delete_confirm]');contextHide();return false">[lang_delete]</a></li>
	<!-- END unlocked -->
	<!-- END permitted_edit -->
	<!-- END not_automap -->

	<!-- BEGIN host -->
<!--
	<li class="spacer"></li>
	<li><a href="[html_cgi]/cmd.cgi?cmd_typ=55&host=[name]" target="_blank">[lang_schedule_downtime]</a></li>
	<li><a href="[html_cgi]/cmd.cgi?cmd_typ=96&host=[name]&force_check" target="_blank">[lang_reschedule_next_check]</a></li>
	<li><a href="#" onClick="showAckDialog('[map_name]', '[obj_id]');contextHide();return false">[lang_ack]</a></li>
-->
	<!-- END host -->

	<!-- BEGIN line -->
	<li class="spacer"></li>

	<li><a href="#" onClick="alert('Service Desc:[service_description], Service Output:[obj_summary_output]');">Start Data Flow</a></li>
	<li><a href="#" onClick="alert('Not implemented yet')">Stop Data Flow</a></li>
	<li><a href="#" onClick="alert('Not implemented yet')">Reset Data Flow to Default</a></li>

<!--
	<li><a href="[html_cgi]/cmd.cgi?cmd_typ=56&host=[name]&service=[service_description]" target="_blank">[lang_schedule_downtime]</a></li>
	<li><a href="[html_cgi]/cmd.cgi?cmd_typ=7&host=[name]&service=[service_description]&force_check" target="_blank">[lang_reschedule_next_check]</a></li>
	<li><a href="#" onClick="showAckDialog('[map_name]', '[obj_id]');contextHide();return false">[lang_ack]</a></li>
-->
	<!-- END line -->
</ul>


So the goal is to simply test if I can get the summary output out, via the javascript alert() function, when the user clicks on the first option named "Start Data Flow"....

However, the macro comes up empty...does anyone know, why that and other macros get expanded (replaced by the corresponding values) correctly in the hoover window, but on the Context Menu window?

I also tried with [service_description] and that one outputs fine....so I am bit puzzled...

Thanks again for all your help,
Gizmo

LaMi

Geek

Posts: 3,822

Birthday: Sep 22nd

Gender: male

Location: München

Occupation: Berater / Entwickler

Number of monitoring servers: x

Nagios Version: 3.2.x

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: x

Number of services: x

OS: SLES,CentOS,Debian

Plugin Version: x

NagVis Version: Git

NDO Version: -

IDO-Version: -

Perfparse Version: -

Other Addons: PNP, Check_MK, Livestatus, Multisite

2

Sunday, September 2nd 2012, 11:21am

You simply don't have the same set of macros in Hover- and Context-Menus. You have the macros available which are mentioned in the documentation.
It should be possible to merge both sets of macros to a general macro replacement mechanism with exactly the same sets of macros but this is not planned at the moment. I added a feature request for this.

Regards
Lars

thygizmo

Beginner

Posts: 23

Gender: male

Location: Darmstadt

Number of monitoring servers: 3

Nagios Version: V3.4.1

Distributed monitoring: Nein

Redundant monitoring: Nein

Number of hosts: 20

Number of services: +400

OS: SLES 11/RED HAT Enterprise / Solaris

Plugin Version: 1.4.16

NagVis Version: 1.7b3

Other Addons: MK Livestatus, Nagvis

3

Sunday, September 2nd 2012, 12:28pm

Thanks for the reply! :)

I actually ended up, doing a query on Nagios using plain Javascript and then processing the resulting html code in Javascript as well, so that I could extract the summary output for service which I clicked initially...:)

It's a little bit dirty, but it works fine...(at least until all macros become widely available to both hoover and context menus).

thanks again for the reply and for adding this to the list of requested features.

Cheers,
Gizmo

Similar threads