Categories
SysOps

How to automatically set up external monitor

Recently I was wondering how to automatically set up an external monitor without using desktop utilities as I don’t like to configure it each time. This question provided me a lot of fun as it opens a couple of interesting possibilities.

Categories
SysOps

How to monitor battery capacity

Recently battery in my notebook started to behave erratically. It will charge only to 70-80% of its maximum capacity. I suspect that it is probably slowly dying, so I will have to replace it soon, but at first, I will look at several utilities to monitor battery capacity.

Categories
SysOps

Simple shell script to backup MySQL databases

Simple shell script to backup MySQL databases.

Categories
SysOps

How to change RRD data source name

To change the data source name, you need to check its current value and then issue single rrdtool command.

Categories
SysOps

How to get disk UUID

I recently needed to know the UUID (universally unique identifier) of my bootable USB root partition. It is a better way to distinguish storage devices because device names can change depending on the connection order.

Categories
SysOps

Boot to RAM notes

This post contains notes on this topic in the form of a concise guide.

Categories
SysOps

How to check the progress of the dd process

Check the progress of the dd process.

Categories
SysOps

Ubuntu and recent problems related to PHP

Recently I run into small problems related to PHP.

Problem A – sqlite.so

The first one was a PHP warning:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/sqlite.so' - /usr/lib/php5/20090626/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0

PHP tried to load sqlite.so from /etc/php5/conf.d/sqlite.ini (php5-sqlite package).

$ dpkg -L php5-sqlite
/.
/etc
/etc/php5
/etc/php5/conf.d
/etc/php5/conf.d/sqlite3.ini
/etc/php5/conf.d/pdo_sqlite.ini
/etc/php5/conf.d/sqlite.ini
/usr
/usr/share
/usr/share/doc
/usr/lib
/usr/lib/php5
/usr/lib/php5/20090626
/usr/lib/php5/20090626/pdo_sqlite.so
/usr/lib/php5/20090626/sqlite3.so
/usr/share/doc/php5-sqlite

As suspected there was sqlite3.so file.

$ ls /usr/lib/php5/20090626/
curl.so  gd.so  mysqli.so  mysql.so  pdo_mysql.so  pdo.so  pdo_sqlite.so  sqlite3.so

Delete the /etc/php5/conf.d/sqlite.ini file to solve this problem.

$ sudo rm /etc/php5/conf.d/sqlite.ini

Problem B – fuser process

The second problem was more serious, thousands of fuser zombie processes and high CPU usage.

Hopefully, there is a bug report #876387, so for a solution look at the fourth comment. Don’t forget to identify and kill already running find processes.

In short, this problem can be quickly recognized by thousands of fuser zombie processes:

$ ps ax | awk '{if ($3=="Z" && $5~/fuser/) s++}; END {print s}'
21613

It was created by php cron job /etc/cron.d/php5 (php5-common package):

$ dpkg -S /etc/cron.d/php5
php5-common: /etc/cron.d/php5

Source of this problem in /etc/cron.d/php5 file:

09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete

To solve it replace this line with one given below:

09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete

Don’t forget to kill running find processes:

# ps ax | grep "find /var/lib/php" | grep fuser | awk '{print $1}' | xargs kill
Categories
SecOps SysOps

How to check established TCP connections

Display established TCP connections inside the terminal.

Categories
SysOps

ODIN – Free Disk Imager

From time to time I need to backup/restore OS on the CF card using Windows machine.