How to parse nagios status.dat file?

前端 未结 7 1141
一生所求
一生所求 2020-12-21 02:06

I\'d like to parse status.dat file for nagios3 and output as xml with a python script. The xml part is the easy one but how do I go about parsing the file? Use multi line re

7条回答
  •  悲&欢浪女
    2020-12-21 02:45

    Don't know nagios and its config file, but the structure seems pretty simple:

    # comment
    identifier {
      attribute=
      attribute=value
    }
    

    which can simply be translated to

    
        attribute-value
    
    

    all contained inside a root-level tag.

    I don't see line breaks in the values. Does nagios have multi-line values?

    You need to take care of equal signs within attribute values, so set your regex to non-greedy.

提交回复
热议问题