Generate a random password in bash

Posted on June 23rd, 2008 in Coding, Work by abdallah

Here’s a quickie that Feliscimo sent me:

  1. < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8

AWStats for one or more domains

Posted on June 23rd, 2008 in Coding, Work by abdallah

The documentation is per http://awstats.sourceforge.net/docs/awstats_setup.html

Here’s quick HOWTO, where I assume you have installed awstats using apt-get or rpm:
Copy the file /etc/awstats/awstats-dist.conf to /etc/awstats/awstats.mydomain.com.conf and changed the domain name there to fit the new site.

Then run the following command:
[root@funinc ~]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=mydomain.com -update

Awstats creates a new set of files for the new site in its database.

Added the following line to your crontab file:
12 00 * * * perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=mydomain.com

basically this will tell awstats to generate a new set of reports for the mydomain.com site daily (at 12 noon!)

Basically that’s it, go to http://mydomain.com/awstats/awstats.pl?config=mydomain.com

  • Comments Off

Grooming

Posted on June 21st, 2008 in Blogging, Cat, Mood by abdallah

It’s just so funny to watch

Cleaning up!

Email to user@ip address

Posted on June 13th, 2008 in Tools, Work by abdallah

And I found the answer in this post:
http://www.irbs.net/internet/postfix/0406/2819.html

Basically it says:
To mail to IP address, use IP literals, such as user@[72.249.191.48]

You might also what to look at the following post for related info as well:
http://www.cyberciti.biz/faq/postfix-receive-mail-on-specific-network-interfaces/

The perfect bed

Posted on June 13th, 2008 in Cat by abdallah

The boss chose a new bed today. A pile of my shirts waiting for laundry

Hierarchy in SQL

Posted on June 7th, 2008 in Coding, Work by abdallah

from this blog post

  1. CREATE TABLE Tree (
  2. Node int NOT NULL IDENTITY(100, 1),
  3. ParentNode int,
  4. EmployeeID int NOT NULL,
  5. Depth tinyint,
  6. Lineage varchar(255) )
  1. UPDATE Tree SET Lineage=‘/’, Depth=0 WHERE ParentNode IS NULL
  1. WHILE EXISTS (SELECT * FROM Tree WHERE Depth IS NULL)
  2.    UPDATE T SET T.depth = P.Depth + 1,
  3.    T.Lineage = P.Lineage + Ltrim(Str(T.ParentNode,6,0)) + ‘/’
  4.    FROM Tree AS T
  5.    INNER JOIN Tree AS P ON (T.ParentNode=P.Node)
  6.    WHERE P.Depth>=0
  7.    AND P.Lineage IS NOT NULL
  8.    AND T.Depth IS NULL
  1. SELECT Space(T.Depth*2) + E.Name AS Name
  2. FROM Employees E
  3. INNER JOIN Tree T ON E.EmployeeID=T.EmployeeID
  4. ORDER BY T.Lineage + Ltrim(Str(T.Node,6,0))

Apt-get update hangs on RHEL

Posted on June 7th, 2008 in Tools, Work by abdallah

If you’re using apt to manage your software installations on a redhat based machine, especially to make use of the rpmforge repository and tools, you might get this error.

Description:

I start apt-get update.  After a while, it gets to the apt.sw.be and hangs at a certain %. You cannot stop it as it hogs the CPU. (hint. login using console and kill it?)

The problem seems to be related to the /etc/apt/sources.list.d/rpmforge.list file. Simply comment out the repomd line and let it use the rpm line as follows:
rpm http://apt.sw.be redhat/el$(VERSION)/en/$(ARCH) dag
#repomd http://apt.sw.be redhat/el$(VERSION)/en/$(ARCH)/dag

This seems to affect rhel4/fedora servers.

MySQL Tuning

Posted on June 4th, 2008 in Work by abdallah

I’ve always felt it was a hassle to gather the data needed for tuning mysql, let alone interpret it. Here’s a great tool to do just that: the MySQL Performance Tuning Primer Script. From the page:

Currently it handles recomendations for the following:

  • Slow Query Log
  • Max Connections
  • Worker Threads
  • Key Buffer
  • Query Cache
  • Sort Buffer
  • Joins
  • Temp Tables
  • Table (Open & Definition) Cache
  • Table Locking
  • Table Scans (read_buffer)
  • Innodb Status
  • Php5.2 on RHEL4

    Posted on June 3rd, 2008 in Work by abdallah

    Setting up the latest (as of June 2008) php on a RHEL4 server (the same would work on RHEL5 or CentOS as well):