Monday 14 July 2008

Awstats full year view error

Error will be look like in following way: Full year view has not been allowed from a browser Setu
p ('/home/domain/etc/awstats/awstats.domain.com.conf' file, web server or permissions) may be wron
g. Check config file, permissions and AWStats documentation (in 'docs' directory).
1. Edit "AllowFullYearView" option in the /home/domain/etc/awstats/awstats.domain.com.conf
2. To view the full year, the option should be "AllowFullYearView=3".

Saturday 12 July 2008

Space full on device

Whenever you start Apache, it keeps crashing with error “semget: No space left on device”.

# tail /etc/httpd/logs/error_log
semget: No space left on device
semget: No space left on device
[Wed Sep 12 10:54:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:56:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 10:58:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device
[Wed Sep 12 11:00:27 2007] [warn] pid file /usr/local/apache/logs/httpd.pid overwritten
– Unclean shutdown of previous Apache run? semget: No space left on device

If you have similar problem as mine above + if your disk space is nowhere near/above 100% + /var/messages and /usr/local/apache/logs/error_log shows no clue about this problem + any files in /etc/httpd/logs/ and /etc/httpd/domlogs nowhere near/above 2GB in size, its most probably semaphore problem. Use the following script to cure your Apache.

#!/bin/bash

ipcs -s | grep nobody | perl -e ‘while () {
@a=split(/s+/); print `ipcrm sem $a[1]`}’

/scripts/restartsrv httpd

Script how to:
- SSH as root to your CPanel server
- Go to root dir

# cd /root

- Create a httpdsemclean.sh blank file

# pico httpdsemclean.sh

- Write above script
- Save

Ctrl + O

- Exit pico

Ctrl + X

- Chmod httpdsemclean.sh to 777

# chmod 777 httpdsemclean.sh

- Execute the script

./httpdsemclean.sh

If all goes fine, you’ll see something like this:


resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
resource(s) deleted
Waiting for httpd to restart…………..finished.

httpd started ok

Do this at your own risk, we do not guarantee this will work on all CPanel servers

Thursday 10 July 2008

How to find the PostgreSQL database size




PostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.
If you want to find the size of a database, in our example the sqview database, please tape:

sqview-# SELECT pg_database_size(’sqview’);
pg_database_size
——————
111415944
(1 ligne)

The result in octal, for a pretty print we will use the pg_size_pretty function which converts the size in bytes to human understandable format.
sqview-# SELECT pg_size_pretty(pg_database_size(’sqview’));
pg_size_pretty
—————-
106 MB
(1 ligne)

Well if we need to get the size of all databases
sqview-# SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;
datname | size
———–+———
postgres | 3537 kB
template1 | 3537 kB
template0 | 3480 kB
freedom | 25 MB
anakeen | 6081 kB
sqview | 106 MB
rt | 8201 kB
(7 lignes)

PostgreSQL can also give the size of a table ‘users’ like this

sqview-# SELECT pg_size_pretty(pg_relation_size(‘users’));
pg_size_pretty
—————-
64 kB
(1 ligne)

This value exclude indexes and some auxiliary data.
If you want to include them use pg_total_relation_size instead of pg_relation_size as shown below.
sqview-# SELECT pg_size_pretty(pg_total_relation_size(‘users’));
pg_size_pretty
—————-
152 kB
(1 ligne)

to find the largest table in the postgreSQL database.
sqview-# SELECT relname, relpages FROM pg_class ORDER BY relpages DESC limit 1;
relname | relpages
———+———-
sqview | 9666
(1 ligne)