March 14, 2008

logrotate/apache and web hosting

Filed under:organization,technology — ryan @ 5:52 pm

Logrotate is a simple program that can perform simple but much-needed features, such as keeping log files from growing to 5gb. Heh. Anyhow, usually, it’s a simple matter of pointing it to the files and letting it do it’s thing.

What if you are a hosting company and you like to allow each user/domain you host access to their own logfiles in their own log directory? Well, without rotation, it’s possible that their logs can grow to gargantuan proportions, for a variety of reasons.

Manually adding and deleting the four or five line entries for each domain could get cumbersome, if your users add/delete domains as often as ours do. This shell script I wrote yesterday helps. It’s got a static section for the ‘main’ apache logs (like most non-hosting apache server setups), and then it dynamically generates the rest given a listing of directories in the main ‘www’ directory. This is not foolproof, and picks up some directories that do not correspond to domains, but there’s also a flag that tells logrotate not to bitch if it encounters them.

#!/usr/bin/sh
#
# ask ryan how this works
# or blame him if it’s broken
#
# if this script is to be cron’d
# just comment out the 3 lines with # SILENT after them
# so the script doesn’t spit out crap

# various variables, only edit the one beginning with ‘file’
file=/www/test2.txt                         # edit this to match logrotate file
backup=/tmp/test2-bak                        
short=`basename $file`
wwwdir=`ls -Ap /www/ | grep "/"`

# backup old logrotate file, create new one
mv $file $backup
touch $file

echo "—– populating $short —–"  # SILENT

# add static header information
# this is constant between updates
echo "### Apache Access Log" >> $file
echo " " >> $file
echo "/www/logs/*log {" >> $file
echo "    missingok" >> $file
echo "    postrotate" >> $file
echo "        /usr/bin/killall -HUP httpd 2> /dev/null || true" >> $file
echo "    endscript" >> $file
echo "}" >> $file
echo " " >> $file
echo " " >> $file
echo "### WebSite Access Logs" >> $file

# now to read all the apparent directories in
# /www/ and treat them like domains, add them
# to the list!  note to ryan: further filter later
for domain in $wwwdir
do
    echo " " >> $file
    echo "/www/"$domain"logs/access_log {" >> $file
    echo "  missingok" >> $file
    echo "  postrotate" >> $file
    echo "      /usr/bin/killall -HUP httpd 2> /dev/null || true" >> $file
    echo "  endscript" >> $file
    echo "}" >> $file
    echo "  `basename $0`: Added ‘$domain‘ to log rotation!" # SILENT
done                                                             

rm -f $backup
echo "—– all done! —–"  # SILENT

Where I work, after we were satisfied that it was doing it’s job when we ran it manually, it was added to cron.weekly.

November 26, 2006

1st annual naked guitar hero party

was a success and now i am so drunk so i just want to say. thankst ot all particilpants it was great.

if you are not friends with my myspace you missed the awesome flyer so here it is

balls

next time make the flight

holy dubvkfuck

October 30, 2006

i don’t blog enough

Filed under:lifestyle,music,organization — ryan @ 1:46 am

and people probably hate me for it.

Nah, that is not what I mean. I mean, if you don’t blog often enough, people will not work your blog into their daily routine and will eventually never come back. That, in turn, depresses you and makes you forget about your blog. Or, at least you consider it a useless outlet.

I’m just going to give you a straight up list for now. I can go into the details later.

It’s going to be like a game, I will only give 2 sentence descriptions of everything. If you want to hear more you have to post the number of the thing you want to hear more about in the comments. If no one votes I will fade into obscurity and stick to myspace quizzes and webcam/mirror shots. Go!

  1. My ex got really drunk and attacked me FOR REAL. It’s been a long fucking time since we broke up so it’s super silly of her but makes for a great story.
  2. I was asked to move to NYC again, but this time in a much more serious manner. I’m considering it but need to start over, kinda.
  3. I’m entering a song contest, and have to write, record, and master three songs by Nov. 15th. I’m really giddy, as the prizes are very worthwhile.
  4. I got a silkscreen kit for fabric. I have no clue what I am doing (don’t vote for this, there is no story)
  5. I installed an imageboard on this server but I am debating handing the link out to just anyone. I think the server could handle it, though.

Yeah, whatever..I can’t think of any more…my head hurts.

September 26, 2006

to be hip,

Filed under:organization,photos — ryan @ 3:04 am

I am updating my theme. It totally screws up my image posting but I will work on that.

At least now you get to pick a cool wallpaper that will get you into the right mood to read my shitty shit! Unless of course you just use a feed reader. If that is the case, you totally are missing out on pictures of a man in a rubber horse mask drinking a can of gasoline.

September 18, 2006

i’m gay in outer space. for you.

Filed under:lifestyle,music,organization,photos,technology — ryan @ 2:04 am

Here is a pic of me. Someone photographed me today but this wasn’t it. That pic was taken a few weeks ago, when Will and I went to go biking at markham park but almost immediately after we loaded our bikes onto the truck and left, weather began to fight us tooth and nail. big lightning. big. and when this happens in south florida, old people drive like it’s the apocalypse and they don’t know where to go (hell) or how to get there (die already), so they best just drive slowly with their four way flashers and hi-beams on. Also, my friend informs me that … oh boy, we don’t really know how to get there after all. So we begin to turn around after being 95% of the way there. My reasoning was: if we head away from where we think we are going, we at least know where we are heading. It makes no sense now that I type it out.

By the time we get back to my house, it’s not so bad out. It’s still raining like a complete son of a beast but there’s not too much lightning….so as the sun sets we decide to get drenched and bike at the park near my home. That’s where the photo comes from. We were talking about the idea of ‘terror twilight‘, how things are always so weird, epic, and magical during sunset and sunrise, and how presidential addresses traditionally are around these times to make the president seem statuesque, intense, god-like, awe-inspiring (guess televised addresses under artificial light pale in comparison these days)… so hey, why not snap some pics to test the theory.

I’ve been really nocturnal and lazy aside from work lately, and that’s crappy. I don’t possess the self-confidence to become a hermit but some people are really bugging me lately. Not many. But some. So I’ve decided that I should work on that. I like to go and do things with friends…adventures, take photos, ride bikes, make music, drink, climb trees, blah blah. I should be able to do some of these things by myself and still enjoy them (hopefully not the alcohol part). Some of these things I do alone (music, these days) but don’t always want to. I guess the music thing is more like schoolwork for me right now.

p.s. I got the drum machine sampler. eeeeh hehehehe. here is a little taste of me learning on it, the first day. definitely not music, but kinda funny.

June 30, 2006

hold your ashtray tight!

Filed under:lifestyle,organization — ryan @ 10:24 am

Yes, another friday post. I know I have been slacking on the photoblog aspect of things, but I am privy to information that leads one to believe that there will be tons of pictures here soon, of abandoned and amazing places and people.

Dear Readers! All four of you! I have a question…assuming that one tries to stick to the moral straight-and-narrow, how does one differentiate between ‘what is right’ and ‘what is right for ME’? I know, I know, they should be one and the same if one is truly moral. But what if you might have a vested interest in the outcome of the situation? If you do, isn’t it hard to make that decision?

Is any of this making any sense or am I just very very hung-over?

PROMISE TO YOU: the next post will contain photos. plural.

June 2, 2006

rules for drunken blogging

Filed under:lifestyle,organization — ryan @ 2:49 am

1. drink so much that you start to look at your glass as an evil alien that’s trying to hurt you. but drink it anyway.

2. smoke a WHOLE PACK of cigarettes in a matter of 3-4 hours.

3. eat at ihop even though you aren’t hungry

4. get home at 3:30am….no earlier, no excuses

5. realize you’re too drunk and tired to post anything funny or insightful so rely on one stupid pic that you think is funny

6. leave ibuprofen next to your bed to combat the evil morning sun

7. realize you have to be at work in 5 hours

8. ???

9. hahaha