Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Email alert when client in blacklist joins network Post 302971611 by Don Cragun on Friday 22nd of April 2016 10:12:50 AM
Old 04-22-2016
Quote:
Originally Posted by lowmaster
I have a textfile with a list of strings I want to monitor in my network.

alertlist:
Code:
hans
franz
tanz

So it can output for me whenever the a strings it matched:
Code:
#!/bin/sh
while : ; do
    testfile="/var/media/ftp/alertlist.txt"
  [[ -f "$testfile" ]] && echo "${testfile##*/} exists." ||  echo "${testfile##*/} does not exist."
  while /var/media/ftp/look.sh active | grep -i -f  /var/media/ftp/alertlist.txt
  do
???
        sleep 4 
    done
    sleep 4
done&

Now what I want is eh a notification, whenever the state changes, example, hans joins, franz leaves franz and tanz joins etc.

not when found or nor, only when the situation changes

how can I do this while keepin the I/O to the flashdrives to a minimum?
If you want to keep I/O to a flashdrive to a minimum, why are you accessing that flashdrive at least four times every 4 seconds?

If you have a list of strings to search for, why do you have to test every four seconds whether or not your list exists? Does this list change frequently while you're running your script?

If you have a program you want to run every 4 seconds and you want to minimize accesses to a flashdrive, why is the program you want to run on a flashdrive?

What does /var/media/ftp/look.sh do? Does it invoke any other software that is located on that flashdrive? Does it access any other files that are located on that flashdrive?

Why are any of these files on a flashdrive if you don't want to access the flashdrive?

What output does /var/media/ftp/look.sh produce? Is the output just strings exactly matching the format of the strings in /var/media/ftp/alertlist.txt, or do lines in the output contain additional text that needs to be stripped away as part of your output?

Can a string in /var/media/ftp/alertlist.txt appear in the output from /var/media/ftp/look.sh more than once? If so, does the output from your script need to notice differences in the number of times a string is found? Or, does it just need to notice when the number of times a given string string appears changes from zero to non-zero and from non-zero to zero?

Does you output just need to give a list of the strings that changed status? Or does the output need to report strings that appeared and strings that disappeared, or the number of times a string appeared in the latest time through the loop?

If these strings are people's names or login IDs, do you really need case insensitive matches? Are UserName and username to be treated as different strings or as a single string?
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email alert script

I need to code a script, which will run via cron, every 30 minutes. The script will read a file containing a date&time and number (which represents disk space). The file gets appended to every 30 minutes. Here's a sample of the file: CPU 1:04/25/02 1:00 am:1972554 CPU 1:04/25/02 1:30... (1 Reply)
Discussion started by: moon
1 Replies

2. Programming

HELP broadcasting client IDs to network in C

I am trying to write a client server chat program in C and am unsure as to how I would broadcast all the users IDs over the network. At the moment I have the usernames stored in a array clientsock.cl_id, I am able to output this information to the server but am unsure how to transmit this... (1 Reply)
Discussion started by: dooker
1 Replies

3. IP Networking

Squid and email client

Hi All, We plan to use squid has a proxy so my question is if I use squid then is this support email clients like outlook express or microsoft outlook at client side and is any option in the squid to block few of the unwanted URL's Thanks, Bachegowda (7 Replies)
Discussion started by: bache_gowda
7 Replies

4. Shell Programming and Scripting

email Alert

Hello, I want a script that will scan the file /etc/httpd/conf/httpd.conf and the folder /etc/httpd/libexec/ -bash-2.05b# grep mod_r /etc/httpd/conf/httpd.conf LoadModule rewrite_module libexec/mod_rewrite.so AddModule mod_rewrite.c -bash-2.05b# -bash-2.05b# find... (4 Replies)
Discussion started by: fed.linuxgossip
4 Replies

5. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

6. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

7. UNIX for Beginners Questions & Answers

Email Alert in UNIX

Hi There I have to wrote a script where I am able to echo a result of an SQL script, however I want to be able to send an email to myself when it is more than 0 (so whenever a value is returned) is this possible? I tried one way from looking on the web but this didn't work, I have added my... (8 Replies)
Discussion started by: simpsa27
8 Replies

8. Shell Programming and Scripting

Email alert after termination

I am running the gaussian program on UNIX with bash and I want to form a script that will email me once the output life terminates either "normal termination" or "false" I just started learning this last week so could you let me know how to go about this.:b: (13 Replies)
Discussion started by: Jade_Michael
13 Replies
All times are GMT -4. The time now is 10:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy