Minimizing Nagios write?

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Minimizing Nagios write?

Postby t3dus » Mon Feb 12, 2018 9:44 pm

I put Nagios Core 4.3.4 back on my Raspberry PI but and set the logs to write to memory.

My question is how do I prevent Nagios from writing to the drive constantly? I see that /usr/local/nagios/bin/nagios -d /user/local/nagios/etc/nagios.cfg is writing every 5 seconds or so.

I'm trying to maximize my SD card life. Last time my SD card only lasted 3 months cuz nagios killed it off.

Btw I'm using a Class 10 32gb Sandisk Ultra 95mb/s card so they aren't exactly super cheap.
Attachments
nagios.PNG
nagios.PNG (5.43 KiB) Viewed 70 times
User avatar
t3dus
 
Posts: 102
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA

Re: Minimizing Nagios write?

Postby mcapra » Tue Feb 13, 2018 10:33 am

Short list of possible ways to alleviate this depending on specifically what is causing the frequent "disk" writes, in order of "difficulty":
  • Fiddle with the status_update_interval setting to write status.dat out less frequently.
  • Use a ramdisk for status.dat and the checkresults file.
  • Pipe logs to /dev/null, leverage the use_syslog directive to ship all Nagios logs to a syslog aggregator (this will require some rsyslog/syslog-ng knowledge). Share the resulting syslog aggregator paths as a netshare and mount to /usr/local/nagios/var/archives on the Pis. Or just don't persist logs at all and pipe everything to /dev/null (this breaks historical reporting). Or stuff them in memory as you have and not have persistence if the Pi dies.

There's a handful of places in the main nagios.cfg file to adjust what gets written and to where:

Code: Select all
# CHECK RESULT PATH
# This is directory where Nagios stores the results of host and
# service checks that have not yet been processed.
#
# Note: Make sure that only one instance of Nagios has access
# to this directory!

check_result_path=/usr/local/nagios/var/spool/checkresults



# STATUS FILE
# This is where the current status of all monitored services and
# hosts is stored.  Its contents are read and processed by the CGIs.
# The contents of the status file are deleted every time Nagios
#  restarts.

status_file=/usr/local/nagios/var/status.dat



# STATUS FILE UPDATE INTERVAL
# This option determines the frequency (in seconds) that
# Nagios will periodically dump program, host, and
# service status data.

status_update_interval=10



# DEBUG VERBOSITY
# This option determines how verbose the debug log out will be.
# Values: 0 = Brief output
#         1 = More detailed
#         2 = Very detailed

debug_verbosity=1



# DEBUG FILE
# This option determines where Nagios should write debugging information.

debug_file=/usr/local/nagios/var/nagios.debug


# LOG ARCHIVE PATH
# This is the directory where archived (rotated) log files should be
# placed (assuming you've chosen to do log rotation).

log_archive_path=/usr/local/nagios/var/archives



# LOGGING OPTIONS
# If you want messages logged to the syslog facility, as well as the
# Nagios log file set this option to 1.  If not, set it to 0.

use_syslog=1


I think you could get Nagios Core to keep *almost* everything in memory with clever use of a ramdisk. This can make startup a bit of a PITA, but if your only issues around stability is the cards dying I think this is a fair trade.
Former Nagios employee
http://www.mcapra.com/
User avatar
mcapra
 
Posts: 3077
Joined: Thu May 05, 2016 3:54 pm

Re: Minimizing Nagios write?

Postby t3dus » Tue Feb 13, 2018 10:46 am

I have no problem manually starting services when the PI boots. The PI is on a UPS so it will rarely if ever be turned off. I'd prefer to write as much as I can to memory. I don't need historical data, this is more of a "in the now current state" monitoring that I care about.

Reason for using a PI vs one of my servers that are currently collecting dust is because I'm a cheap skate. Trying to save power and the PI is super cheap to run.
User avatar
t3dus
 
Posts: 102
Joined: Thu Feb 04, 2016 3:46 pm
Location: IA

Re: Minimizing Nagios write?

Postby cdienger » Wed Feb 14, 2018 12:24 pm

Thanks for the excellent post @mcapra!
User avatar
cdienger
Support Tech
 
Posts: 919
Joined: Tue Feb 07, 2017 11:26 am


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 27 guests