What directory PHP is busy with

The file “cwd” under /proc/pid is a symbolic link to the “current working directory”:

for i in `ps -ef | awk ‘/php/{print $2}’`
do
ls -l /proc/${i}/cwd
done

The result is:

lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/11544/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/11764/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/12574/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:40 /proc/13081/cwd -> /home/alekz/public_html/alekz.net
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:45 /proc/15053/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:45 /proc/15056/cwd -> /home/alekz/public_html/blog/wp
lrwxrwxrwx 1 alekz alekz 0 Янв 25 02:49 /proc/15696/cwd -> /home/alekz/public_html/blog/wp/wp-content/plugins/si-captcha-for-wordpress/captcha-secureimage

Of course, you can use any other process name instead of php.

And here’s a “dynamic” version:
Continue reading “What directory PHP is busy with”

dcpumon and dcpumonview

Found another cPanel application which you can safely turn off in order to safe some bytes and cycles.

By default dcpumon runs every 5 min to log CPU usage (“top” output) :

# crontab -l | fgrep cpu
*/5 * * * * /usr/local/cpanel/bin/dcpumon >/dev/null 2>&1
#

and stores the data into /var/log/dcpumon

You can view the report with dcpumonview command:

# /usr/local/cpanel/bin/dcpumonview
———————————————————–
|User |Domain |CPU%|MEM%|MySQL#|
———————————————————–
|alekz |alekz.net |17.72|37.07|0.3 |
| Top Process | 27.8 | /usr/bin/php |
| Top Process | 14.2 | /usr/bin/php |
| Top Process | 12.3 | /usr/bin/php |
|mysql | |11.47|3.05|0.0 |
| Top Process | 11.7 | /usr/sbin/mysqld –basedir/ –datadir/var/lib/mysql –usermysql –pid-file/var/lib/mysql/alekz.pid –skip-external-locking |

Firefox and places.sqlite tricks

Sometimes you need to remotely get your bookmarks, history or check the top-10 sites, etc. Here’s some neat tricks to get the info from the Firefox Places file called places.sqlite, which is an SQLite database with the following tables (see also the picture):
Continue reading “Firefox and places.sqlite tricks”

MAC for UNIX

MAC (Monkey’s Audio Converter) for Windows can be downloaded from http://www.monkeysaudio.com. But what about a UNIX version? Two years ago v3.99 Update 4 Build 5 was released but then the development stopped because of some contradictory licensing reasons. That means that MAC for UNIX is not maintained anymore. Fortunately, the old version still works. I compiled it under Solaris 11 x86 and use it for SqueezeCenter.

The source tar file is attached to the post: mac-399-u4-b5.tgz (MD5)

Some notes.

  • To check the MD5 digest:
    % md5sum -c mac-3.99-u4-b5.tgz.md5
    mac-3.99-u4-b5.tgz: OK
  • Always use –prefix=/usr/local (or any other directory in which you keep non-standard files) configuration parameter, because by default the prefix is set to /usr. You might overwrite Solaris file /usr/bin/mac (message authentication code):
    % ./configure –prefix=/usr/local
  • If you are going to use –enable-assembly=yes option (you need yasm to compile assembler code) under Solaris change “sh” to “bash” in src/MACLib/Assembly/Makefile in the following line (line 214 in my case):
    STRIP_FPIC = sh $(top_srcdir)/strip_fPIC.sh

    This is what the line should look like:

    STRIP_FPIC = bash $(top_srcdir)/strip_fPIC.sh
  • There is already a program /bin/mac (see above). If you don’t want to use the full path to the MAC, simply rename the latter:
    # mv /usr/local/bin/mac /usr/local/bin/MAC