integrate Nagiosgraph in thruk

101 views
Skip to first unread message

Stefan Rudat

unread,
Oct 22, 2022, 6:27:46 AM10/22/22
to Thruk

Hello 

We are running Thruk  Version 2.48 and doe to historical reason we still using Nagiosgraph. I get the error message “nagiosgraph.js is not installed or wrong version.”In our installation the file is located /usr/local/nagiosgraph/share/nagiosgraph.js   "var VERSION = 1.7;"

Is there a simple way to ingrate  nagiosgraph link in thruk ? 

 Best regard

            Stefan 

 

 

Sven Nierlein

unread,
Oct 24, 2022, 8:52:47 AM10/24/22
to th...@googlegroups.com, Stefan Rudat
Hi,

Please check if nagiosgraph works at all. The error message sounds like it has a general issue not related to Thruk.

Integration then should possible with the generic 3rd party graph integration:
http://thruk.org/documentation/graphing.html#_other-3rd-party-grapher
Although i haven't seen that in use for a long time. Guess most people are using either PNP or Grafana nowadays.

Regards,
Sven
> --
> You received this message because you are subscribed to the Google Groups "Thruk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thruk+un...@googlegroups.com <mailto:thruk+un...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/thruk/ff523d8a-70ff-45b0-9066-efb2e9405156n%40googlegroups.com <https://groups.google.com/d/msgid/thruk/ff523d8a-70ff-45b0-9066-efb2e9405156n%40googlegroups.com?utm_medium=email&utm_source=footer>.

OpenPGP_signature

Stefan Rudat

unread,
Oct 25, 2022, 9:06:06 AM10/25/22
to Thruk
Hi Sven,

yes nagiosgraph works  using the Link 

I think I found the source of the problem ,  other colleagues still using the Nagios web interface , and they defined the Mouse over for Nagios. 
Without this definition thruk works perfekt together with  nagiosgraph .  I will swap over to thruk  not only  because on the reporting  tool! 

Either I have now a battle wit my colleagues or I will find a way how to  cut everything after "onMouseOver"  defined in thruk_local.conf  graph_replace  

 define service {
        name withgraphs-service
        use                             generic-service         
       # action_url                      /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
        action_url                      /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver="showGraphPopup(this)" onMouseOut="hideGraphPopup()" rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
        register 0
}

I thought  graph_replace = s/onMouseOver *//  could do the  job , but  I failed :-( 

Bye
  Stefan 


Sven Nierlein

unread,
Oct 25, 2022, 10:15:05 AM10/25/22
to th...@googlegroups.com, Stefan Rudat
How about:

graph_replace = s/ onMouseOver.*$//
OpenPGP_signature
Message has been deleted
Message has been deleted

Anand Sampatsing

unread,
Dec 12, 2022, 10:18:14 AM12/12/22
to th...@googlegroups.com
Hi

We've added an action_menu to each host eg.:

Item "Edit notes" should not show for readonly users.

In thruk v2 we had this solved with action_menu_items and  some js in status-header.ssi. However this does not seem to work with thruk v3.
So I tried it with this (in thruk_local.conf): action_name = "file://...../action_menus/js_edit_notes_menu.js" and the 2 items do show up.

My question is how to hide/remove "Edit notes" for readonly users?

Thanks
Anand

Sven Nierlein

unread,
Dec 12, 2022, 10:27:28 AM12/12/22
to th...@googlegroups.com, Anand Sampatsing
Hi,

How did you solve this in Thruk 2?
You could always query the rest api for the current user at /r/thruk/whoami. This contains the current roles and the `can_submit_commands` attribute
which indivates the readonly status. Then there is a "remote_groups" js variable set for the current user, but this contains the naemon contact groups
for the current user and might not be a big help.
But it might make sense to make such user information easier available.

Cheers,
Sven


On 12.12.22 16:18, Anand Sampatsing wrote:
> Hi
>
> We've added an action_menu to each host eg.:
>
> Item "Edit notes" should not show for readonly users.
>
> In thruk v2 we had this solved with action_menu_items and  some js in status-header.ssi. However this does not seem to work with thruk v3.
> So I tried it with this (in thruk_local.conf): action_name = "file://...../action_menus/js_edit_notes_menu.js" and the 2 items do show up.
>
> My question is how to hide/remove "Edit notes" for readonly users?
>
> Thanks
> Anand
>
> --
> You received this message because you are subscribed to the Google Groups "Thruk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to thruk+un...@googlegroups.com <mailto:thruk+un...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/thruk/292be088-6d18-4b8e-5261-532b3d29dfbd%40gmail.com <https://groups.google.com/d/msgid/thruk/292be088-6d18-4b8e-5261-532b3d29dfbd%40gmail.com?utm_medium=email&utm_source=footer>.

Sven Nierlein

unread,
Dec 13, 2022, 4:32:36 AM12/13/22
to Anand Sampatsing, Thruk
Hi,

i just added a new "hidden" attribute to make such things easier. I also added a new "thruk_user" variable which
makes the additional rest api call unnecessary.
See
https://github.com/sni/Thruk/commit/501c7524eb92dabc9130c7908b4d1edac71053e7
There is also an example.

Cheers,
Sven


On 12.12.22 17:36, Anand Sampatsing wrote:
> Hi Sven,
>
> Thanks for your super fast reply.
> In Thruk 2 the action_menus were added "onload" after that (if i'm correct) status-header.ssi was loaded/run.
> My js in status-header.ssi checked if there is a onmouseover in the (host)statusTable.tr . if not, this must be a ro user.
> Because action menu items were already present onload my js would find all "Edit notes" and remove it.
>
> Thruk3 loads action menus dynamically (is my understanding), the menus are not present onload but only become available onclick of the dropdown icon.
> Any suggestions on how to tell js not to show "Edit notes" if ro user.
> Perhaps something with html raw
>       { "icon":"uil-document-info",
>         "html":......
>       },
>
> Not sure if "action_menu_apply" could be used here.
>
> Many thanks,
> Anand
OpenPGP_signature

Anand

unread,
Dec 13, 2022, 5:43:43 PM12/13/22
to Sven Nierlein, Thruk
Hi Sven,

Testing the "hidden" attribute.
Eventhough selected read-only, config tool still thinks user can submit commands: "Can Submit Commands   Yes".



This way the hidden attribute will always result in false. Hence all menu items will still be visible to all users.
What am I doing wrong...?

Thanks
Anand

Sven Nierlein

unread,
Dec 14, 2022, 3:40:50 AM12/14/22
to Anand, Thruk
Hi,

thanks. This has been miscalculated in the config tool. I just fixed it. Should be fine with tomorrows daily.

Cheers,
Sven


On 13.12.22 23:43, Anand wrote:
> Hi Sven,
>
> Testing the "hidden" attribute.
> Eventhough selected read-only, config tool still thinks user can submit commands: "Can Submit Commands   Yes".
>
>
>
OpenPGP_signature

Anand

unread,
Dec 14, 2022, 2:34:22 PM12/14/22
to Sven Nierlein, Thruk
Hi Sven,

This is what I found.

User privs and roles:
Can Submit Commands     No    reason: authorized_for_read_only role  <--- works
Effective Roles    
authorized_for_all_hosts     (from cgi.cfg)
authorized_for_all_services  (from cgi.cfg)
authorized_for_read_only     (from cgi.cfg)


A simple verification of var using ssi/status-header.ssi:
<script>
console.log('name: '                + thruk_user["name"]);
console.log('readonly: '            + thruk_user["readonly"]);
console.log('can_submit_commands: ' + thruk_user["can_submit_commands"]);
</script>


As expected results in:
name: demo
readonly: true
can_submit_commands: false


thruk_local.conf:
<action_menu_items>
  hostactions = \
  { "icon":"../themes/{{theme}}/images/dropdown.png",\
    "menu":[\
      {"label":"Metrics",\
        "action":"../../utilapp/extinfo?d=$HOSTNAME$!ping"\
      },\
      { "label":"Edit notes",\
        "action":"../../utilapp/tinymce?h=$HOSTNAME$",\
        "hidden":thruk_user["readonly"]\           <-----------
      }\
    ]\
 }
</action_menu_items>


Results in:
On mouseover, where the action_icon (drop-down) should be:
<i class="uil uil-exclamation round yellow" title="'true' expected, at character offset 208 (before &quot;thruk_user[&quot;readonly...&quot;) at /..../thruk/lib/Thruk/Utils/Filter.pm line 581."></i>


Again thruk_local.conf but going to call js_edit_notes.js:
<action_menu_items>
  hostactions = "file://....../action_menus/js_edit_notes.js"
</action_menu_items>


And action_menus/js_edit_notes.js
function js_menu(d) {
  return({
    "icon":"../themes/{{theme}}/images/dropdown.png",
    "menu":[
      {"label":"Metrics",
        "action":"../../utilapp/extinfo?d=$HOSTNAME$!ping"
      },
      { "icon":"uil-document-info",
        "html":"<div id=qqq class='flexrow gap-1 flex-nowrap'>"
              +"<b>test</b>"
              +"<input type='text'>"
              +"<button onclick=alert('hello')>ok</button>"
              +"</div>"
      },
      { "label":thruk_user["name"],                        <--- just to test..., it works
        "action":"../../utilapp/tinymce?h=$HOSTNAME$",
        "hidden":thruk_user["readonly"]
      },
    ]
  });
}


Results in:



Notice label name "demo" is correct however demo should not show because hidden/readonly is true.


HTH
Anand

Sven Nierlein

unread,
Dec 15, 2022, 4:27:41 AM12/15/22
to Anand, Thruk
Hi,

answers inline...

On 14.12.22 20:34, Anand wrote:
> thruk_local.conf:
> <action_menu_items>
>   hostactions = \
>   { "icon":"../themes/{{theme}}/images/dropdown.png",\
>     "menu":[\
>       {"label":"Metrics",\
>         "action":"../../utilapp/extinfo?d=$HOSTNAME$!ping"\
>       },\
>       { "label":"Edit notes",\
>         "action":"../../utilapp/tinymce?h=$HOSTNAME$",\
>         "hidden":thruk_user["readonly"]\           <-----------
>       }\
>     ]\
>  }
> </action_menu_items>
>
> Results in:
> On mouseover, where the action_icon (drop-down) should be:
> <i class="uil uil-exclamation round yellow" title="'*true' expected*, at character offset 208 (before &quot;thruk_user[&quot;readonly...&quot;) at /..../thruk/lib/Thruk/Utils/Filter.pm line 581."></i>

Thats because inline action menus are not javascript, it's static json. It's equivalent to putting the same text into a action_menu/hostaction.json file.
There is no javascript involved here.


> Again thruk_local.conf but going to call js_edit_notes.js:
...
> Results in:
>
>
>
> Notice label name "demo" is correct however demo should not show because hidden/readonly is true.

This i cannot reproduce. Works as expected here.

Cheers,
Sven

Reply all
Reply to author
Forward
0 new messages