[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Basic question about LuaSocket and sleeping
- From: mchalkley@...
- Date: Sat, 22 Sep 2012 11:52:48 -0400
All,
I'm using Lua (and just Lua) to write a system monitoring/maintenance
program to run on Windows & Linux servers. One of the things that I
need to do is provide the ability for the programs running on multiple
machines to talk to one another (to begin with, just a simple
replication of either Echo or something like that is fine). I've got
the program sending SMTP and SMS notifications when Echos fail, when
disk space, cpu utilization, or memory usage becomes a problem, etc.
I've also finished the scheduling mechanism, so it can run commands
relevant to all that stuff, copy & delete files, etc. based on
intervals, dates, days of the week, time of day, all that stuff. But
now, I'm getting down to some more nitty gritty stuff involving
communication between machines.
I bought the PiL book and one of its many wonderful examples seems to
be exactly what I'm looking for, longer term, because being able to
ftp between them would be great, too.
What I'm really wondering, though, is how socket reads take place. For
example, I'm trying to keep my program from using any more system
resources than possible because it's a monitoring tool, so it "sleeps"
most of the time. How does LuaSocket handle reading sockets if I have
it sleeping for 10-15 seconds between iterations (checking the
schedule to see if there's anything to do). Does a packet that's
received on a socket the program is listening to interrupt the sleep
cycle, or what? This is such a basic question, I suppose, that it must
be addressed in the documentation somewhere, but I can't find it...
Maybe I'm just obsessing over something that's "automagic", but one of
the reasons I'm learning Lua instead of using Perl or Python, which I
already knew, is because of the speed and compactness of Lua. It's
pretty cool to see something like what I've got right now run in less
than 3 mb of memory (most of the time), and take about 5 seconds of
cpu time every 24 hours....
Thanks,
Mark