action_menu and action_menu_items and THRUK_ACTION_MENU

333 views
Skip to first unread message

Fabrice Le Dorze

unread,
Dec 28, 2014, 1:57:07 PM12/28/14
to th...@googlegroups.com
Hello.
Whe use Thruk with remote backends, some under our control, other in customer networks and managed bu their teams.
We plan to use action_menu and action_menu_items directives to create tickets to different ticket systems (to our system or customer's systems). I found the "action menu" feature very interesting as we can externalize new actions to our own scripts without modifiying anything in Thruk core, like this :

  <action_menu_items>

        standardmenu      = {"icon":"/naemon/themes/{{theme}}/images/add.png",\
                             "title": "Create ticket",\
                             "label":"ticket",\
                             "action":"server://create_ticket"}

    </action_menu_items>
<action_menu_actions>
    create_ticket = /opt/RmsTools/bin/create_ticket.pl "hostname:$HOSTNAME$,hostalias:$HOSTALIAS$,hostaddress:$HOSTADDRESS$,\
            hoststate:$HOSTSTATE$,lasthoststatechange:$LASTHOSTSTATECHANGE$\
            hostoutput:$HOSTOUTPUT$,longhostoutput:$LONGHOSTOUTPUT$,hostnotesurl:$HOSTNOTESURL$\
            servicedesc:$SERVICEDESC$,servicedisplayname:$SERVICEDISPLAYNAME$,\                                             
            servicestate:$SERVICESTATE$,lastservicestatechange:$LASTSERVICESTATECHANGE$,serviceoutput:$SERVICEOUTPUT$,\
            servicenotesurl:$SERVICENOTESURL$,longserviceoutput:$LONGSERVICEOUTPUT$,user:$REMOTE_USER$"
</action_menu_actions>

But in the original templates, the feature is dependant on _THRUK_ACTION_MENU existence in Nagios configuration of remote backends.
The problem is that we do no manage all configurations, some of them can be under control of customer team. That's why I had to modify the templates to be able to use these new menus in all cases.

1 - Is the right way to do this ?
What do you think to have the possibility to activate action menu by default. For example,
If _THRUK_ACTION_MENU is not set, the hostdefaultmenu or a servicedefaultmenu are printed instead if they have been defined in thruk config.

2- Of course, we would like that our ticket creation script can create an acknownledgement with a comment containing the ticket number and the user for example.
Who to do that ?
The simpliest way I see is to just do it through the Livestatus socket by using socat for example. But how can I know the IP of remote backend. Is there a internal variable to pass to our script ?

Sven Nierlein

unread,
Dec 28, 2014, 4:00:39 PM12/28/14
to th...@googlegroups.com
Hi,

On 28/12/14 19:57, Fabrice Le Dorze wrote:
> 1 - Is the right way to do this ?
> What do you think to have the possibility to activate action menu by default. For example,
> If _THRUK_ACTION_MENU is not set, the hostdefaultmenu or a servicedefaultmenu are printed instead if they have been defined in thruk config.

there are some plans to apply action menu items by patterns, for example something like
(thruk_local.conf)
<apply_action_menu>
^xyz special_menu
* standard_menu
</apply_action_menu>

This is not yet be implemented, but would solve your problem. So patches in that direction are welcome :-)


> 2- Of course, we would like that our ticket creation script can create an acknownledgement with a comment containing the ticket number and the user for example.
> Who to do that ?
> The simpliest way I see is to just do it through the Livestatus socket by using socat for example. But how can I know the IP of remote backend. Is there a internal variable to pass to our script ?

Couldn't you just use thruks cli scripts to set an acknownledgement. That way you don't need to know the backend, just the hostname/service description would do the trick and thruk decides which backend to contact.

Sven


Fabrice Le Dorze

unread,
Jan 3, 2015, 10:25:10 AM1/3/15
to th...@googlegroups.com
Hi Sven
1- I'll try to have a look but I have first to understand how Thruk is buit.
But is is already possible to have 2 different menus, one for host, one for service and modify the proper templates to use them ?
I tried to define the 2 menus below but got error : 'garbage after JSON object'.
 
  <action_menu_items>
   hostmenu = {\
   "icon":"/naemon/themes/{{theme}}/images/arrow_right.png",\
   "title": "Actions Menu",\
   "menu":[\

      {"icon":"/naemon/themes/{{theme}}/images/add.png",\
        "title": "Create ticket",\
        "label":"Create Ticket",\
        "target":"_blank",\
        "action":"http://prod1.inf.rms.loc/TicketTools"\
      },\
      {"icon":"/naemon/themes/{{theme}}/images/package_go.png",\
        "title": "See in CMDB",\
        "label":"See in CMDB",\
        "target":"_blank",\
        "action":"https://cmdb.rms.loc/$HOSTNAME$"\
      },\
      {"icon":"/naemon/themes/{{theme}}/images/json.png",\
        "title": "Connect with Connector",\
        "label":"Connect with Connector",\
        "target":"_blank",\
        "action":"https://connector.rms.loc/$HOSTNAME$"\
      }]},\
   servicemenu = {\
   "icon":"/naemon/themes/{{theme}}/images/arrow_right.png",\
   "title": "Actions Menu",\
   "menu":[\

      {"icon":"/naemon/themes/{{theme}}/images/add.png",\
        "title": "Create ticket",\
        "label":"Create Ticket",\
        "target":"_blank",\
        "action":"http://prod1.inf.rms.loc/TicketTools"\
      }]}

    </action_menu_items>

What should be the proper syntax ?

2- Concerning the external ticket tool, we initially planned to built it without dependencies to Thruk. Thats is why we are looking for a way to pass the Backend informations to it.
Anyway, I try to use the CLI examples services.sh
I'm under Naemon.
But :
export PERL5LIB=/usr/lib/naemon/perl5:/usr/share/naemon/lib ; services.sh
gives no result and execution code = 9.
Did I something wrong ?

Fabrice Le Dorze

unread,
Jan 22, 2015, 4:19:09 PM1/22/15
to th...@googlegroups.com
Hi Sven.
I was able to define several menus, I just made a typo below. Sorry about that.

But concerning or external ticketing tool, I'm still looking fot a way to create a acknowledgment one the ticket is created.

a- You mentioned we should use the Thruk CLI but my first of the CLI example listhost gave no result and execution code = 9.
b- I could use the 'thruk -l' command to get the backend list and link it to the host for which we want to create an acknowledgement with livestatus
c- but ideally, It would be fine to pass the backend info as a macro to the action. Is there a way ?

Sven Nierlein

unread,
Jan 22, 2015, 4:43:44 PM1/22/15
to th...@googlegroups.com
On 22/01/15 22:19, Fabrice Le Dorze wrote:
> c- but ideally, It would be fine to pass the backend info as a macro to the action. Is there a way ?

That should be possible. I will have a look into that.

Sven Nierlein

unread,
Jan 23, 2015, 7:22:57 AM1/23/15
to th...@googlegroups.com

Fabrice Le Dorze

unread,
Jan 24, 2015, 4:02:56 PM1/24/15
to th...@googlegroups.com
I patched with these changes.
It worked perfectly.
I added the macros $LASTSERVICESTATECHANGE$ and $LASTHOSTSTATECHANGE$ too, which were required to create tickets.
I would suggest to add all standard Naemon/Nagios macros to close definitely the debate.
What do you think ?

As I'm convinced that Thruk and Naemon are the way to go for a multi client context such ours, I'm going to try to convince my firm to make a donation.
I would like to congratulate you, and more largely the german Opensource Monitoring for the fantastic products you provide.
Thank you.
Reply all
Reply to author
Forward
0 new messages