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!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...