Use action url to "Force immediate check"

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
frankwijers
Posts: 22
Joined: Fri Apr 09, 2021 6:22 am

Use action url to "Force immediate check"

Post by frankwijers »

Hello all,

is it possible to configure the action url to have the command "Force an immediate check" under it?
Would be really helpful to click the little arrows in the overview in stead of opening them all and going to the advanced tab.

Thanks for your help.
Frank
User avatar
Rfferrao13
Posts: 12
Joined: Tue Aug 09, 2016 3:56 pm

Re: Use action url to "Force immediate check"

Post by Rfferrao13 »

Just so you know, there is an option to force en masse:
Mass Immediate Check

https://IP/nagiosxi/includes/components ... /index.php
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Use action url to "Force immediate check"

Post by ssax »

While not currently a part of the XI feature-set you could do it with the CALLBACK_CUSTOM_TABLE_ICONS callback, see Help > Callback Reference in the web interface for details.

Here's an example that does what you want:

Code: Select all

mkdir /usr/local/nagiosxi/html/includes/components/nagiosxicallbacks
Put this in /usr/local/nagiosxi/html/includes/components/nagiosxicallbacks/nagiosxicallbacks.inc.php:

Code: Select all

<?php

// include the XI component helper
require_once(dirname(__FILE__) . '/../componenthelper.inc.php');

// define/call our component initialize function
nagiosxicallbacks_component_init();
function nagiosxicallbacks_component_init()
{

    // information to pass to XI about our component
    $args = array(
        COMPONENT_NAME =>           "nagiosxicallbacks",
        COMPONENT_VERSION =>        "1.0",
        COMPONENT_AUTHOR =>         "Nagios Enterprises, LLC",
        COMPONENT_DESCRIPTION =>    "Demonstrate Nagios XI Callbacks inside of Custom Components",
        COMPONENT_TITLE =>          "Nagios XI Callbacks Demonstration"
        );

    // register with XI
    if (register_component("nagiosxicallbacks", $args)) {

        // register a function to be called when CALLBACK_CUSTOM_TABLE_ICONS is executed
        register_callback(CALLBACK_CUSTOM_TABLE_ICONS, 'nagiosxicallbacks_custom_table_icons');

    }
}

function nagiosxicallbacks_custom_table_icons($callback_type, &$args) {

    // make sure we are in the right callback
    if ($callback_type == CALLBACK_CUSTOM_TABLE_ICONS) {
        // Initialze some stuff we'll use a few times...
        $cmd = array(
            "command" => COMMAND_NAGIOSCORE_SUBMITCOMMAND,
        );

        $cmd["command_args"] = array(
            "host_name" => $args['host_name'],
            "service_name" => $args['service_description']
        );

        // Forced immediate check
        if ($args['objecttype'] == OBJECTTYPE_HOST) {
            $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_SCHEDULE_FORCED_HOST_CHECK;
            $cmd["command_args"]["start_time"] = time();
            $icondata = get_host_detail_command_link($cmd, "arrow_refresh.png", '');
        } else {
            $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_SCHEDULE_FORCED_SVC_CHECK;
            $cmd["command_args"]["start_time"] = time();
            $icondata = get_service_detail_command_link($cmd, "arrow_refresh.png", '');
        }

        $args['icons'][] = $icondata;
    }
}
?>
Run this command to adjust owner/group:

Code: Select all

chown -R nagios.nagios /usr/local/nagiosxi/html/includes/components/nagiosxicallbacks
Then refresh the page and see if that shows a new link for you.

If you have issues, delete the component:

Code: Select all

rm -rf /usr/local/nagiosxi/html/includes/components/nagiosxicallbacks
NOTE: This change will add additional load time to the display of those pages as it constructs the links but it should be minimal
Locked