Log or database entry for host changing host group?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Log or database entry for host changing host group?

Post by peter.zanetti »

We frequently have hosts that change host groups to receive different types of monitoring, is there anywhere we can see when a host was moved from one host group to another?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Log or database entry for host changing host group?

Post by mcapra »

If I remove the host "alice" from the hostgroup "mediocre-servers" and add it to the hostgroup "cool-servers", the following entry is added to nagiosxi.xi_auditlog.message:

Code: Select all

Host modified: alice
So not exactly as specific as you would like.

You could probably do this on a cron job by querying the nagiosql.tbl_host table and storing the entries id, host_name, and hostgroups fields and using them as a reference for the next time the cron job gets run. Some pseudocode:

Code: Select all

$old = previous query result;
$current = SELECT id, host_name, hostgroups FROM nagiosql.tbl_host;
if(!($old.hostgroups == $current.hostgroups)) {
    //changes were made, figure them out and report to a file
}
Former Nagios employee
https://www.mcapra.com/
Locked