Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Processing missing files

Partha18
Level 3
Level 3

Hi,

I am working on file collector activity. If there is no files in the directory for 2 days, then i need to get alert.

How can i make this possible?

In file collector, I will check 'process missing file'. And then alert activity. But in between my file collector and alert activity what i need to do?

Important Note: In file collector activity, we scheduled for each 2 hours daily. So per day it will check the directory for 12 times. And so 24 times for 2 days. After this check, if no file is there in my directory, i need to notified.

Please help me with this!

Thanks and Regards,

Partha.

1 Accepted Solution
Jonathon_wodnicki
Correct answer by
Community Advisor
Community Advisor

Hi,

If you're on Linux: make a new js activity and paste this in, put after scheduler activity or anywhere really:

var DIR = '/absolute/path/to/collector/dir';

var DAYS_UNTIL_THINGS_START_LOOKING_SUSPICIOUS = 2;

var modified = new Date();

modified.setTime(execCommand('stat -c %Y ' + DIR)[1] * 1000);

if((new Date() - modified) / (86400 * 1000) > DAYS_UNTIL_THINGS_START_LOOKING_SUSPICIOUS)

  logError('Error: Collector directory last updated too long ago: ' + modified);

Thanks,

-Jon

View solution in original post

3 Replies
Jonathon_wodnicki
Correct answer by
Community Advisor
Community Advisor

Hi,

If you're on Linux: make a new js activity and paste this in, put after scheduler activity or anywhere really:

var DIR = '/absolute/path/to/collector/dir';

var DAYS_UNTIL_THINGS_START_LOOKING_SUSPICIOUS = 2;

var modified = new Date();

modified.setTime(execCommand('stat -c %Y ' + DIR)[1] * 1000);

if((new Date() - modified) / (86400 * 1000) > DAYS_UNTIL_THINGS_START_LOOKING_SUSPICIOUS)

  logError('Error: Collector directory last updated too long ago: ' + modified);

Thanks,

-Jon

View solution in original post

Partha18
Level 3
Level 3

Hi,

I am not using Linux.

In my case, A file will generate for every 1 hour in SFTP. So i need to notify when there is no file for 2 days. My file name is like eg: abcd* (abcd_followed by 6 digit random number. so i gave abcd* in file collector).

I have created a option "myOption" (type integer; value 0)

Below is my workflow:

1842529_pastedImage_2.png

i have 2 questions. My questions are,

1) In test activity, I have given vars.recCount > 0, then enable 'True'.

As i don't know my exact file name, i have given vars.recCount > 0. Will this work?

2) If file exist, i will make option value as 0. But for every 1 hour, if file is not there, then i need to do increment. How can i increment my option value. Either like SetOption('myOption',myOption+1) or someother thing?

Please help me with this!

Thanks and regards,

ParthaSarathy.

Jyoti_Yadav
Community Advisor
Community Advisor

Hi Partha,

Answer to your two questions are:

1) Yes, vars.recCount works if there's any fie, it will give you value greater than zero.

2) You can set option value using:

var myOption=GetOption("myOption");

setOption("myOption",myOption+1);

Thanks,

Jyoti