Nagios Syntax Highlighting



Enabling Nagios syntax highlighting in vim


The Problem:

  • Nagios Object definitions and other configuration is well-known to be cumbersome and error-prone
  • Nagios Config files often consist of 100s of thousands of lines, and editing often requires changes in the middle of a file
  • For years people have Nagios throw errors at them on start because of tiny spelling mistakes

The Answer:

  • Vi IMproved (vim) lets you use self defined syntax highlighting to avoid common mistakes like missing braces
  • Pot meet kettle!

vim Config

Create a .vim directory and subdirectories

mkdir -p .vim .vim/ftdetect .vim/syntax


Define .cfg to be a Nagios config file

echo 'au BufRead,BufNewFile *.cfg set filetype=nagios' > .vim/ftdetect/nagios.vim


The Syntax file

Download the Nagios syntax highlighting support

wget -O.vim/syntax/nagios.vim \




Now enjoy a more helpful Nagios config:

...Unless you hate syntax highlighting, like me


What about Check_MK?

Check_MK Configurations are all-python so they do not need any of this.

VIM has automatic syntax highlighting for Check_MK built-in

..I use :syn off to turn it off




  • No labels