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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...