LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Squid run script on access_denied event (https://www.linuxquestions.org/questions/linux-server-73/squid-run-script-on-access_denied-event-4175458757/)

markotitel 04-19-2013 07:04 AM

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.

cliffordw 04-19-2013 07:28 AM

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!

TB0ne 04-19-2013 09:28 AM

Quote:

Originally Posted by markotitel (Post 4934697)
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


markotitel 04-19-2013 03:24 PM

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


All times are GMT -5. The time now is 12:15 AM.