Guides‎ > ‎Tricks‎ > ‎

Finding Objects

Finding A Specific Host Object in objects.cache

The file objects.cache (usually located in /usr/local/nagios/var/) contains all the Nagios objects that are defined in all of the cfg files. The special thing about objects.cache is that it shows the FINAL object after all templates have been taken into account. It's a great way to see what settings are applying when troubleshooting an issue.

Here's a one line command that searches this file and finds the host object called "vCenter".


Command:
cat /usr/local/nagios/var/objects.cache | sed -rn "/define host \{/{:a;N;/}/{/.host_name.vCenter/p;d};ba}"


Output:
define host {

    host_name    vCenter
    alias    vCenter
    address    vcenter.box293.local
    check_period    24x7
    check_command    check-host-alive
    contact_groups    admins
    notification_period    workhours
    initial_state    o
    importance    0
    check_interval    5.000000
    retry_interval    1.000000
    max_check_attempts    10
    active_checks_enabled    1
    passive_checks_enabled    1
    obsess    1
    event_handler_enabled    1
    low_flap_threshold    0.000000
    high_flap_threshold    0.000000
    flap_detection_enabled    1
    flap_detection_options    a
    freshness_threshold    0
    check_freshness    0
    notification_options    r,d,u
    notifications_enabled    1
    notification_interval    120.000000
    first_notification_delay    0.000000
    stalking_options    n
    process_perf_data    1
    action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
    retain_status_information    1
    retain_nonstatus_information    1
    }