Replacing sysklogd with rsyslog

If you need to replace old sysklogd with recent rsyslog on centos, `rpm -e --nodeps sysklogd` is rather kludgy as yum will remove initscripts, upon which most of the system is dependent on. However, it is possible to install and remove via the yum shell in one go, which resolves the dependency issues.

# yum shell
> install rsyslog
> remove sysklogd
> run
> quit

How to change network card speed and duplex settings in ubuntu


If you want to change speed and duplex of your network card you have to use ethtool or mii-tool.ethtool can be used to query and change settings such as speed, auto- negotiation and checksum offload on many network devices, especially Ethernet devices.

How to Tell Your OpenVZ VPS is Swapping


So you think your OpenVZ VPS really has “guaranteed memory”? Well. Not quite. I have got an OpenVZ VPS from one of the providers listed here — 256MB guaranteed and 512MB burstable memory. When I run free it shows... 512MB total memory and 0 swap? After all I am only using 65MB of memory so well below my “guaranteed” amount. Zero swap because it is just how OpenVZ does its memory account. But is it really the case that all my processes reside in physical RAM?

Let’s dig out the good ol’ user_beancounters...

Linux cpu processor cores and threads

/proc/cpuinfo has the info you need to identify the number of processors, cores and threads.

To get the total number of processors/cpu cores:

grep -c processor /proc/cpuinfo

Total number of physical cpus:

grep "physical id" /proc/cpuinfo | sort -u | wc -l

Number of cores per cpu:

grep "cores" /proc/cpuinfo | sort -u

To check if hyperthreading is enabled:

grep "cores\|siblings" /proc/cpuinfo | sort -u

If siblings is a multiple of cores then hyperthreading is enabled.

Trac redirect loop upon password reset

Recently, I have come across the mentioned bug during a password reset of Trac:

Reference bug

This looks like an issue when set to "Force users to change passwords after a password reset?". I changed the config to not force the password change.

Also removed the session attribute in reference from the trac database:

sqlite3 yourtrac/db/trac.db \ 'DELETE FROM "session_attribute" WHERE "name" = "force__change_passwd";'

Using varnish HTTP accelerator and some gotchas


Experimenting with Varnish...
Using the varnish HTTP accelerator - Experiences so far...

Nginx location and rewrite configuration made easy


The best way to think of things is that as a request comes in, Nginx will scan through the configuration to find a “location” line that matches the request. There are TWO modes that nginx uses to scan through the configuration file: literal string matching and regular expression checks. Nginx first scans through ALL literal string location entries in the order that they occur in the configuration file, and secondly scans through ALL the regular expression location entries in the order that they occur in the configuration file. So be aware – location ordering order DOES matter...

Probing if Varnish is Alive

If you probe on varnish service status to check if it is alive, this can be setup as below. Put it in "vcl_recv" block:

  # Check if Varnish is alive
  if (req.url == "/varnish_status") {
    error 200 "OK";

Then check for http "200 OK" in the response code.

List threads with ps and top

The "H" option in both ps and top lists the threads:


ps auxwH

top H

Redirect ports inside OpenVZ containers

For port redirection to work inside OpenVZ containers, ipt_REDIRECT kernel module needs to be loaded in the host. Edit "/etc/sysconfig/vz" and add it to the IPTABLES list.

IPTABLES="ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_owner ipt_length ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp ipt_recent ipt_REDIRECT"

This should then allow to redirect ports. So if you need to proxy existing apache via nginx or lighttpd and you do not want to switch apaches' default port 80, then the below rules will do the appropriate redirection to port 81 where nginx/lighttpd server is listening, serving static content and proxying to apache for dynamic content:

# Redirect external web traffic to port 81
iptables -t nat -A PREROUTING -s ! -p tcp --dport 80 -j REDIRECT --to-ports 81

# Redirect internal port 80 to 81
iptables -t nat -A OUTPUT -s 0/0 -d -p tcp --dport 80 -j REDIRECT --to-ports 81

Where is the internal IP resolver of domain/host.

Syndicate content