LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-19-2013, 07:04 AM   #1
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 181

Rep: Reputation: 18
Squid run script on access_denied event


Hi people, I was searching on squid monitoring events and run a script but no real luck.

Do you have any ideas how to solve this?

For example, I need a script that will run when event acces denied occurs.

Actual script will watch that event and take IP wihch is denied and after 15 minutes it will channge ACL to allow and reconfigure squid.
 
Old 04-19-2013, 07:28 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

One approach to deal particularly with "access denied" events might be to use SquidGuard for the filtering / ACLs, and in particular use it's redirect feature to send the user to a CGI/PHP error page. Within that page you can then trigger the necessary logic to do what you want.

Good luck!
 
Old 04-19-2013, 09:28 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,613

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by markotitel View Post
Hi people, I was searching on squid monitoring events and run a script but no real luck.
Do you have any ideas how to solve this?

For example, I need a script that will run when event acces denied occurs. Actual script will watch that event and take IP wihch is denied and after 15 minutes it will channge ACL to allow and reconfigure squid.
Ok, so what have you done/tried to write this script?? Bear in mind this is not squid specific...what you're looking for is something that watches a log file, and does something when it sees a pattern. There are ample examples you can find on Google...a very simple one would be:
Code:
tail -f some-logfile | awk '/some-pattern/ {system("run-some-command")}'
...which will look for a pattern in a log file, and run a single command when it sees it. More complex:
Code:
tail -fn0 logfile | \
while read line ; do
        echo "$line" | grep "pattern"
        if [ $? = 0 ]
        then
                ... do something ...
                ... do something else...
                ... do something else...
        fi
done
 
Old 04-19-2013, 03:24 PM   #4
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 181

Original Poster
Rep: Reputation: 18
Ah thank you for your ideas. Yes I was first trying to search for squid specific , then it came to my mind that Im dealing with TXT file not with squid . Also SquidGuard is interesting approach, Ill let you know when Im done with script. Im slow but will make it work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to capture gnome-screensaver event doesn't work if run as root bubuntu Linux - General 3 01-22-2013 04:48 AM
Run a script on switch-user event Ubuntu 9.10 bwilhite Programming 6 02-20-2010 07:44 AM
How to make the right mouse button run a script (event trigger) xmrkite Linux - Hardware 5 10-17-2006 01:29 PM
run script at hotplug event AAnarchYY Linux - Hardware 1 07-21-2006 09:19 AM
how to run script on event ppp0 interface going down ? qwijibow Linux - Networking 4 02-24-2004 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration