Alerting

Raise an alert if a directory doesn't contain n number of files

adityapavan18
Contributor

Hi

I need to monitor a directory and by end of the day i want to check if there are n number of files. if numbers files is greater/less than n in that directory i need to raise an alert. Can this be done in splunk. Can anyone help me?

Tags (1)
0 Karma
1 Solution

gfuente
Motivator

Hello

You could use an scripted input.For example, in linux, you shoud create a .sh file, with something like:

ls -lart /thepath/youwant/tomonitor | wc -l

Then the output of this script will be a number, thats the number of files in that directory. So you need to create a inputs.conf in your UF, with an script stanza calling to the .sh file at the schedule you need.

Once you have the data indexed, you only need to setup the alerts you want monitoring the values of the files.

Regards

View solution in original post

gfuente
Motivator

Hello

You could use an scripted input.For example, in linux, you shoud create a .sh file, with something like:

ls -lart /thepath/youwant/tomonitor | wc -l

Then the output of this script will be a number, thats the number of files in that directory. So you need to create a inputs.conf in your UF, with an script stanza calling to the .sh file at the schedule you need.

Once you have the data indexed, you only need to setup the alerts you want monitoring the values of the files.

Regards

mic1024
Path Finder

That is an interesting approach. What if I'd like to compare the result to a previous day's result, alert if the number is smaller (I'm missing files) and list the missing files?

Thanks,

0 Karma

adityapavan18
Contributor

Thnx. Need to check and learn scripted inputs..

0 Karma
Get Updates on the Splunk Community!

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

Stay Connected: Your Guide to July and August Tech Talks, Office Hours, and Webinars!

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...