Koozali.org: home of the SME Server

Just an Idea |-]

Alejandro

Just an Idea |-]
« on: April 05, 2001, 07:36:13 PM »
Last week I had a total system hang up of my server, and when I tryed to reboot, it didnt start again, so used the excellent reinstallation disk and backup file systems. with a total downtime of 50 minutes (not so bad ;})
Mi first thought was an attack, but when i was adding a cdrom unit to the e-smith box I discovered that the CPU cooler was malfunctioning and the cpu  was very hot so that was probably the trigger of a general corruption of my disk, who knows!

I was thinking, I was not able to recover any log file, so couldn't determine exactly the cause, I'm pretty sure it was the cpu temperature but......
So I thought it could be a good idea, having a replicant log file (maybe messages file or one specificaly related to stability or security) that could be saved in another place out of the server
where it could be permanently updated.
I dont have idea how to do it!!!
I think it could be usefull so it's time to share ideas with the forum
Alejandro.

Paul Miller

Re: Just an Idea |-]
« Reply #1 on: April 11, 2001, 01:05:08 AM »
Hi Alejandro

Alejandro wrote:
> So I thought it could be a good idea, having a replicant log
> file (maybe messages file or one specificaly related to
> stability or security) that could be saved in another place
> out of the server
> where it could be permanently updated.

The following is one way you can send message info to yourself from the command line at the end of your day.  However, there are security issues you should consider when runnning as root.
 
---
Looking at the system I tinker with I see about 500 lines a day in the messages file.

The /var/log/messages file gets continuously rotated into five separate files so that messages can gracefully 'age out' without filling up your hard disk.

Alt F2, root,           # log in as root
# I use apr10 for the filename in this sample. Since the file is included you could identify each day by the message date. If you used the following in a script you could use the same filename and subject to simplify the script. To identify, you could look at messages by subject then date.

---
# grep "Apr 10" messages* >apr10       # grab just one day of messages
# mail -s apr10 youremail@yourdomain   # mail to yourself using subject; if you use this from a script add the -I switch to force interactive mode to use the ~r option
~rapr10                                # ~reference the file to include it
"apr10" 429/40136                      # mail tells you file attached
.                                      # you signal the end of the message with a period
Cc:                                    # hit return to get past interactive prompt
# rm -f "apr10"                        # clean up file as you go
---

If I knew perl better I could finish this.  There are other mail senders that might be better because you can attach rather than include a file.

When you tire of doing this at midnight, a perl or shell script could be written and called from cron to do something similar with just a few more lines;-)

Hope this helps.  

Paul Miller

Alejandro

Re: Just an Idea |-]
« Reply #2 on: April 11, 2001, 08:06:03 PM »
Of course it helps!
You really got the point.
Now I will try to make that script to do it every n minutes/hours
Thanks a lot!

Paul Miller

Re: Just an Idea |-]
« Reply #3 on: April 12, 2001, 01:38:13 AM »
Alejandro wrote:

> Now I will try to make that script to do it every n
> minutes/hours

A scripting technique that might help follows.  This fragment is part of a script to continuously send video from a webcam to a website during daylight hours. The key for me was understanding how to execute a command from within a script.

# variable = $( command --options='parameter' +%otheroption)

sunset=2205
nowtime=$(date --date='now' +%H%M)
while [ "$nowtime" -le "$sunset" ]
do
 echo $nowtime #verify executing loop
 #do your file transfer
 sleep 1 m     #wait a minute
done

Best Regards,
Paul Miller