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 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.
nagios.PNG (5.43 KiB) Viewed 189 times
User avatar
Posts: 109
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
# 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!


# 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.


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


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


# This option determines where Nagios should write debugging information.


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


# 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.


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
User avatar
Posts: 3290
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
Posts: 109
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!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
Support Tech
Posts: 1419
Joined: Tue Feb 07, 2017 11:26 am

Return to Nagios Core

Who is online

Users browsing this forum: Bing [Bot] and 17 guests