Tuesday, July 31, 2012

munin 2.0.x on centos 6 ( rhel 6 ) nginx

As there's no munin 2.0.x rpm package available for centos, I've to compile it from source.
I've used nginx as the web server and here is the procedure :

yum groupinstall 'development tools' -y
yum remove munin munin-node -y
mv /etc/munin /etc/munin-old
yum-builddep munin
yum install perl-CGI perl-FCGI perl-File-Copy-Recursive perl-Module-Build perl-Cache-Cache git -y
cd /usr/src
wget http://sourceforge.net/projects/munin/files/stable/2.0.4/munin-2.0.17.tar.gz
tar -zxf munin-2.0.17.tar.gz
cd munin-2.0.17
cd dists/redhat
git clone git://pkgs.fedoraproject.org/munin.git


sed -i Makefile -e 's,CONFIG = Makefile.config,CONFIG = dists/redhat/munin/Makefile.config-dist,g'
chown -R nobody /usr/src
sudo -u nobody make
make install
cp dists/redhat/munin/munin-node.rc /etc/init.d/munin-node
chmod a+x /etc/init.d/munin-node
cp dists/redhat/munin/munin.cron.d /etc/cron.d
service crond restart
service munin-node restart
chkconfig munin-node on
chown -R munin /var/www/html/munin/cgi
chown -R munin /var/lib/munin/cgi-tmp
chown -R munin /var/lib/munin/spool
chown -R nobody /var/lib/munin/plugin-state
chmod 775 /var/lib/munin/plugin-state
chmod 666 /var/log/munin/munin-cgi-graph.log
chmod 666 /var/log/munin/munin-cgi-html.log
groupadd munin
useradd munin -g munin -s /sbin/nologin -d /var/www/html/munin

You might test all enabled plugins using the following commads :

cd /etc/munin/plugins
files=`ls -l  | awk '{print $9}'`;for file in $files; do echo -e "**********\n$file :\n"; munin-run $file;done &> ../result


#########################
## nginx configuration ##
#########################
yum install spawn-fcgi -y
cd /etc/init.d
wget http://files.julienschmidt.com/public/cfg/munin/spawn-fcgi-munin-html
wget http://files.julienschmidt.com/public/cfg/munin/spawn-fcgi-munin-graph
sed -i spawn-fcgi-munin-graph -e 's,www-data,apache,g'
sed -i spawn-fcgi-munin-html -e 's,www-data,apache,g'
sed -i spawn-fcgi-munin-graph -e 's,/usr/lib/cgi-bin/munin-cgi-graph,/var/www/html/munin/cgi/munin-cgi-graph,g'
sed -i spawn-fcgi-munin-html -e 's,/usr/lib/cgi-bin/munin-cgi-html,/var/www/html/munin/cgi/munin-cgi-html,g'
chmod a+x spawn-fcgi-munin-html
chmod a+x spawn-fcgi-munin-graph
########
### Before starting the service, try to fix permission errors reported in the munin check
########
munin-check
service spawn-fcgi-munin-html start
service spawn-fcgi-munin-html status
chkconfig spawn-fcgi-munin-html on
service spawn-fcgi-munin-graph start
service spawn-fcgi-munin-graph status
chkconfig spawn-fcgi-munin-graph on
########
## configure /etc/munin/munin.conf
## graph_strategy cgi
## html_strategy cgi
## enable plugins
## cd /etc/munin/plugins
## ln -s /usr/share/munin/plugins/load
########
### nginx rewrites
########
        location ^~ /cgi-bin/munin-cgi-graph/ {
                access_log off;
                fastcgi_split_path_info ^(/cgi-bin/munin-cgi-graph)(.*);
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass unix:/var/run/munin/fcgi-graph.sock;
        }

        location /munin/static/ {
                alias /etc/munin/static/;
        }

        location /munin/ {
                fastcgi_split_path_info ^(/munin)(.*);
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass unix:/var/run/munin/fcgi-html.sock;
        }
#######
### run the cron and test the stack
#######
sudo -u munin munin-cron

Sunday, July 8, 2012

IKEv2 VPN between NATed linux client and the linux server

Finally, I've done running an IKEv2 VPN between Ubuntu on my home pc as the client and Centos on my ded server as the server using strongswan 4.6.4, the client is NATed ( router : dsl modem ! ).

Here's the configuration :

server's ipsec.conf :
conn win7
        left=SERVER.IP.ADD.RESS
        leftcert=server.cert
        leftid=@server.domain.com
        leftsubnet=0.0.0.0/0
        right=%any
        rightsourceip=10.10.3.0/24
        keyexchange=ikev2
        auto=add
        leftfirewall=yes


client's ipsec.conf:
conn ike
        left=%defaultroute
        leftsourceip=%config
        leftcert=client.cert
        leftid=@client.domain.com
        leftfirewall=yes
        right=SERVER.IP.ADD.RESS
        rightsubnet=0.0.0.0/0
        rightid=@server.domain.com
        auto=add

Establish the connection using the following command :

ipsec up ike

Tuesday, July 3, 2012

solution to postfix saslauthd problem

If you're using sasluath daemon to authentice postfix users and receive always a user & pass error, first check /var/log/maillog to see if the solution applies to. Mine was:

warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory

I've fixed that by adding the following option to /etc/sysconfig/saslauthd :

FLAGS="-r -m /var/spool/postfix/var/run/saslauthd"



then running the following commands :


mkdir -p /var/spool/postfix/var/run/saslauthd
service saslauthd restart

UPDATE 12 July 2012 : With the above commands the saslauthd problem get fixed but I've got another problem : Mails never send through the server with the following errors :
postfix/qmgr: from=<root@domain.com>, size=421, nrcpt=1 (queue active)
postfix/smtp: fatal: unknown service: smtp/tcp
postfix/qmgr: warning: private/smtp socket: malformed response
postfix/qmgr: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
postfix/master: warning: process /usr/libexec/postfix/smtp pid 29443 exit status 1
postfix/master: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling
postfix/error: to=<someemail@gmail.com>, relay=none, delay=1.1, delays=0.1/1/0/0.03, dsn=4.3.0, status=deferred (unknown mail transport error)

I've checked the /etc/postfix/master.cf , one process was chrooted !
smtp      unix  -       -       -       -       -       smtp

I've changed it to :
smtp      unix  -       -       n       -       -       smtp

then restarted postfix and saslauthd and now everything is working fine !

stack : centos 6.2 + virtualmin

How to disable Debian 12 sleep on production servers

 Debian 12 has power saver enabled by default which causes your server to go to sleep if there is no mouse / keyboard interaction. To resolv...