I need a check for the first 2 lines of the 5 last xml files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
shlelieveld
Posts: 4
Joined: Thu Nov 14, 2013 5:24 am

I need a check for the first 2 lines of the 5 last xml files

Post by shlelieveld »

Hello all,

I'm looking for a nagios XI check plugin that displays the first 2 lines of the last 5 xml files in a folder that might contain hundreds of xml files. I could check the file age and count if they are cleaned daily, but unfortunately they aren't cleaned daily.

In the xml files a time stamp of the schedule xml file is displayed but in that folder ALL xml files remain in that folder. So over a few years hundreds of files will remain in that folder.

I'm not a script-er so I really don't know where to begin. And after looking and searching through the exchange library I couldn't find a suitable plugin.
Is there someone that needed something similar? Or is someone very handy to alter an existing, or create a simple new one?

Thank you so much.
BT-IT-Specialist Viacom Amsterdam
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: I need a check for the first 2 lines of the 5 last xml f

Post by tmcdonald »

Since this is such a specific requirement I would highly doubt there is a plugin made to do just that. You could probably get away with using grep in a bash script, once for the date and once for the lines you seek.
Former Nagios employee
Locked