Chaps, I need to count number of files in a remote directory from Linux (FreeBSD) as if 10 trace files (log files) been generated within 5min of time. So this is the script then I can setup a monitoring.
I came across with ls -1 \ip\d:\Logs | wc -l but then what else requires to check time stamp, maybe I should use if ...then
Chaps, I need to count number of files in a remote directory from Linux (FreeBSD) as if 10 trace files (log files) been generated within 5min of time.
I may be a bit slow, but i don't get what you want to do: get the log files of the last 5 minutes? Get the last 10 logfiles?
And this:
Quote:
Originally Posted by samwijekoon
is similarly mysterious to me: first, this is not a script, it more (or less, in fact: rather the latter) looks like a single command (syntax errors notwithstanding). You can execute - if it is meant as a command - that only locally, so: do you want to execute it remotely or locally or what? Second, the "path" looks suspiciously like a Windoze path, not a UNIX path. Is this a Windows system and, if yes, what is the FreeBSD system you spoke about earlier? Third: what do you mean by "monitoring"? Should this repeated many times over? And, if yes, what exactly are you supposed to monitor: number of files, size of files, size of all files, size/number of files created since last run of script? Something different?
I may be a bit slow, but i don't get what you want to do: get the log files of the last 5 minutes? Get the last 10 logfiles?
And this:
is similarly mysterious to me: first, this is not a script, it more (or less, in fact: rather the latter) looks like a single command (syntax errors notwithstanding). You can execute - if it is meant as a command - that only locally, so: do you want to execute it remotely or locally or what? Second, the "path" looks suspiciously like a Windoze path, not a UNIX path. Is this a Windows system and, if yes, what is the FreeBSD system you spoke about earlier? Third: what do you mean by "monitoring"? Should this repeated many times over? And, if yes, what exactly are you supposed to monitor: number of files, size of files, size of all files, size/number of files created since last run of script? Something different?
bakunin
Let me to explain, a Windows server generating trace files. F5 load balancer wants to monitor those files. F5 big-ip runs on Linux freebsd. So I try to run a script on F5 when the condition match it will take the Windows server out of availability pool based on monitoring condition.
Here is the condition to trigger:
If 10 files are created within last 5 minutes then monitor takes server offline. I can include this script in the F5 device. Size of trace decide by end server which is a Windows. Hope that little bit clearer
Last edited by samwijekoon; 12-08-2016 at 02:43 AM..
Let me to explain, a Windows server generating trace files. F5 load balancer wants to monitor those files. F5 big-ip runs on Linux freebsd. So I try to run a script on F5 when the condition match it will take the Windows server out of availability pool based on monitoring condition.
Here is the condition to trigger:
If 10 files are created within last 5 minutes then monitor takes server offline. I can include this script in the F5 device. Size of trace decide by end server which is a Windows. Hope that little bit clearer
OK, this makes it a bit clearer. In this case you only need to plug your monitor "sensor" into the file sending process, like this (pseudo-code, just to demonstrate the logic):
Great, is this the code I should try or do I need modification on this
Honestly: i don't know. You gave a roundabout description of your requirement and i wrote a roundabout solution. To really implement this you will need to specify in much more detail what your requirement is.
For instance (one of the things needing clarification): what should happen after taking the server offfline? Wait for some time and put it online again? (If yes: how long would be "some time"?) Do nothing and leave it offline?
Another detail needing clarification: what is meant by "send file(s)"? Transfer it with scp/rcp/rsync/ftp/sftp/or the likes? Socket communication? Anything else?
In any case: what i wrote was pseudo-code, which just shows a possible logic and control flow of a program which has to be implemented. To actually implement it you need to select a programming language first which you want to use (i.e. "bash" or "Korn Shell" or "perl" or "ruby" or "python" or "whatever else you might want to use, version 3.141596", etc..
Ideally need bash, to check whether 10 files within 5min been created. If that's true then F5 big-ip actions to bring server out of the pool. Script should only check the condition. F5 will setup how frequent to check (every 5 sec) and take the action.
Actual files are generating on the Windows web server, itself location E:\logs
Hope that helps to help me further
Thanks
Last edited by samwijekoon; 12-09-2016 at 11:07 PM..
I'm writing a script for searching substring in file content and then moving found files. So far I've wrote script shown below
grep -lir 'stringtofind' $1 | xargs mv -t $2
How can i count number of files moved? (4 Replies)
Hi All!
I need to have a script that counts the number of files arriving in a landing directory, them some app pick these files to be processed and load to a DB. But this process is so fast that I am not able to count all the files arriving on a landing directory.
Please can you help?
My... (6 Replies)
hi I am trying to write a script to count the number of files, with slightly different subset name, in a directory
for example, in directory /data, there are a subset of files that are name as follow
/data/data_1_(1to however many).txt
/data/data_2_(1 to however many).txt... (12 Replies)
Hi!
I just want to count number of files in a directory, and write to new text file, with number of files and their name
output should look like this,,
assume that below one is a new file created by script
Number of files in directory = 25
1. a.txt
2. abc.txt
3. asd.dat... (20 Replies)
Hi there
I have a .ksh script that I am using on an AIX ( Actual Level 5.3.10.0, Maintenance Level 5.3.0.0) where I am logging into a windows box, doing a file count on that server and returning the output to the UNIX session.
I would like to exit the script at this point in time if the... (10 Replies)
1) I need a shell code to count the number of files ( without directories or sub-directories ) in a directory given as arguments I tried this code but it didn't work , maybe I tried the wrong one:
numOfFiles=`find $1 -type f -maxdepth 1 | wc -l`
I found it in another thread in this site..
... (17 Replies)
Hi,
Please let me know how to find out number of files in a directory excluding existing files..The existing file format will be unknown..each time..
Thanks (3 Replies)
Hello,
I am new to unix and would like to have a count of all the files in the current directory as well as all the files in a subdirectory.
The command I used was ls -R | wc -l
but the number returned wasn't correct. Can someone please help?
Thanks (2 Replies)