Last Folder created

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
rambertnala
Posts: 70
Joined: Fri Feb 26, 2016 7:15 am

Last Folder created

Post by rambertnala »

hi friends.

I will try to explain.

I have a folder on which every day must be created a folder named with date format Year-month-day (2016-04-11 for today)

So i am able to check if this folder is or not created https://support.nagios.com/forum/viewto ... =7&t=34056

But i would like to get which is the last folder, that was created if folder for today have not been created.

In my example I suppose that last folder is 2016-04-08, and i get via nrpe that 2016-04-11 not exist. How can i get via nrpe last folder was created???

Is possible to do all in only one check. So at the same time get last folder created and that exist or not folder for today????

Thanks in advance

I wanna do it with check_files included in NSClient 0.4.3
Last edited by rambertnala on Mon Apr 11, 2016 9:54 am, edited 2 times in total.
Bidouille
Posts: 6
Joined: Mon Apr 11, 2016 9:00 am

Re: Last Folder created

Post by Bidouille »

What you means by "last"? You knows its name?

Edit: don't modify your first message but post a message behind mine with new info
If not, the logic of this thread is lost
rambertnala
Posts: 70
Joined: Fri Feb 26, 2016 7:15 am

Re: Last Folder created

Post by rambertnala »

Hi friend. Ok.

Let's take for example today's date

Well, i have a folder X:\<path_to_folder>\ where every day must be created a new folder which name is this format `date +%Y-%m-%d` so today must be created a folder 2016-04-11

I can get via nrpe if folder has been created or not following this thread
https://support.nagios.com/forum/viewto ... =7&t=34056
This thread helped me a lot.

But now i need to get name of last folder was created if i get CRITICAL for today's folder

I don't know if i am explaining it correctly.

In my case last folder created in X:\<path_to_folder>\ was 2016-04-08 and today, after weekend( I am out of the office), I get critical for today's folder 2016-04-11, which means than folders 2016-04-09 and 2016-04-10 have not been created during Saturday and Sunday

So how can i get via nrpe last folder created??? Im my case i need to get 2016-04-08 via nrpe.

If it is possible, there would be possible get both cases in one check??? let me explain it, If today's folder has not been created, I get critical via nrpe , can I get at the same time name of last folder created???

Thanks
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Last Folder created

Post by rkennedy »

You would need to create a wrapper script, that had some logic built to it to understand that if check A fails, run check B for 2 days previously. There isn't a way for a check to do this logic out of the box, but with a combination of a wrapper script you should be able to accomplish this.
Former Nagios Employee
Locked