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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...