Trigger / Sequence 2 x Services

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
bpg
Posts: 7
Joined: Tue Jul 20, 2021 8:46 am

Trigger / Sequence 2 x Services

Post by bpg »

Hi

I have 2 services that I'd like to run in sequence.
Is it possible to have the 1st service trigger the 2nd service?
I want this to happen regardless of what status is returned from the 1st service.

Any help greatly appreciated.
gwesterman
Posts: 268
Joined: Wed Aug 23, 2023 11:29 am

Re: Trigger / Sequence 2 x Services

Post by gwesterman »

Hi @bpg,

This can be accomplished using service dependencies. You can make service 2 dependent on service 1 and set whatever return value from service 1 you want to be considered a failure (in your case none). This will make nagios check service 1 before checking service 2 and, once service 1 returns, check service 2. Admittedly, this isn't exactly having service 1 "trigger" service 2 but it should guarantee that they run in sequence. For a true "trigger", you would probably have to set up one or more event handlers. There is a lot you can do with service dependencies and it can get pretty complicated pretty quickly.

Hope this helps!

Thank you!
bpg
Posts: 7
Joined: Tue Jul 20, 2021 8:46 am

Re: Trigger / Sequence 2 x Services

Post by bpg »

Thanks for the suggestion @gwesterman - much appreciated.

Am I right in thinking that the dependent service ('service 2') has to be active at all times for this to work?
I was hoping that 'service 2' could be left as inactive and only run when triggered by 'service 1'.
If that is the case then I think that an event handler might be the only solution to this but would appreciate your opinion.

Thanks
gwesterman
Posts: 268
Joined: Wed Aug 23, 2023 11:29 am

Re: Trigger / Sequence 2 x Services

Post by gwesterman »

I believe that you are correct, yes. Every time service 2 is run, nagios checks if it has any dependencies and runs those first, only running service 2 if the return code you set as success returns. So this requires service 2 to be active on its own. Event handlers do seem to be your best bet for what you're looking for.

Thank you!
Post Reply