Re: [BAD] the whole server down with a red-alert-like attack

2002-01-25 Thread Radek Hnilica

On Fri, Jan 25, 2002 at 10:28:56AM +1100, Russell Coker wrote:

 IMHO something that runs every minute should not be in cron, even something 
 that runs every 5 minutes possibly shouldn't be in cron.

:) s/should not/must not/ if I do't want problems
Yeah, I made a painful experience myself.

 A shell script that does the following should do:
 #!/bin/sh
 
 while /bin/true ; do
   /usr/local/bin/something
   sleep 60
 done

The problem with this code is that the cycle is slightly greater then
60 seconds.  This desynchronize the script very early.

As I remember I quick hack my problem with test if a previous run was
done.  If not, I simply skip this one.

 So if the script takes hardly any time to run then it runs every minute.  If 
 it takes a lot of resources then it'll run only one copy at a time, and have 
 a 1 minute break between runs (time for other programs to get some CPU time 
 etc).
 
 What would be handy would be to have a program that did all this, so I could 
 do:
 
 /usr/bin/runevery 60seconds /usr/local/bin/something
 To get the same result as the above shell script.

or as I wrote above, something like:
#!/bin/sh
if previous instance is stil running; then
report time presure
exit
fi
do some usefula data gathering and/or processing


 Then for even more protection it could have options to monitor and/or limit 
 CPU usage and log to syslog.
 
 Does this sound good?  If I get a dozen people sending me private email 
 stating that they want to use such a program then I'll write it and add it to
 my logtools package.

hmm.  doesn't such program exist yet?

Main usage for such a program/tool is (from my point of view) data
gathering on routers.  Someting like an ipac tool does.  But sometimes
man needs to made its own data gathering scripts.


Yes, there are many tools for such a case, but I always love small
simple nice handmade scripts.


Sorry for my english.  I'm not sure with some words like desynchronize.
-- 
Radek Hnilica Radek at Hnilica dot CZ
===
No matter how far down the wrong road you've gone, turn back.
Turkish proverb




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [BAD] the whole server down with a red-alert-like attack

2002-01-25 Thread Peter Billson

 IMHO something that runs every minute should not be in cron, even something
 that runs every 5 minutes possibly shouldn't be in cron.

  Could you tell me why that is so? I often run things from cron that
run every 5 mins and have never run into a problem... but then again I
often do stupid things repeatedly! :-) 

Pete
-- 
http://www.elbnet.com
ELB Internet Services, Inc.
Web Design, Computer Consulting, Internet Hosting


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [BAD] the whole server down with a red-alert-like attack

2002-01-25 Thread Radek Hnilica

On Fri, Jan 25, 2002 at 08:17:31AM -0500, Peter Billson wrote:
  IMHO something that runs every minute should not be in cron, even something
  that runs every 5 minutes possibly shouldn't be in cron.
 
   Could you tell me why that is so? I often run things from cron that
 run every 5 mins and have never run into a problem... but then again I
 often do stupid things repeatedly! :-) 

Better saying:  You can do whatever you want, but think before to not shoot yourself.

As I wrote or not:
 - I ran my script too often
 - The machine was old 486
 - unfortunately conditons has changed
   due this, the script was runing ten times slowly.

And the nighmare was born :)

-- 
Radek Hnilica Radek at Hnilica dot CZ
===
No matter how far down the wrong road you've gone, turn back.
Turkish proverb




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [BAD] the whole server down with a red-alert-like attack

2002-01-24 Thread Russell Coker

On Thu, 24 Jan 2002 22:16, Radek Hnilica wrote:
 I made the same experience with some testing script on one of my
 routers.  I run that script from cron to often.  When the conditions
 were good, the one run end before cron run the next.  But once the
[...]
 I resolved my problem with not running that script every minute but
 relax rules and run it vere five or ten munites.

IMHO something that runs every minute should not be in cron, even something 
that runs every 5 minutes possibly shouldn't be in cron.

A shell script that does the following should do:
#!/bin/sh

while /bin/true ; do
  /usr/local/bin/something
  sleep 60
done

So if the script takes hardly any time to run then it runs every minute.  If 
it takes a lot of resources then it'll run only one copy at a time, and have 
a 1 minute break between runs (time for other programs to get some CPU time 
etc).

What would be handy would be to have a program that did all this, so I could 
do:

/usr/bin/runevery 60seconds /usr/local/bin/something

To get the same result as the above shell script.

Then for even more protection it could have options to monitor and/or limit 
CPU usage and log to syslog.

Does this sound good?  If I get a dozen people sending me private email 
stating that they want to use such a program then I'll write it and add it to 
my logtools package.

-- 
http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/   Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/ My home page


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]