Web page load speed monitoring with Munin

Here’s an example of the configuration:

[http_loadtime]
     env.target https://pydelion.com

Enabling:

ln -s /usr/share/munin/plugins/http_loadtime /etc/munin/plugins/http_loadtime

Test run:

[root@node1 ~]# sudo munin-run http_loadtime
loadtime.value 1.04
[root@node1 ~]#

Munin restart:

[root@node1 ~]# service  munin-node restart
Stopping Munin Node agents:                                [  OK  ]
Starting Munin Node:                                       [  OK  ]
[root@node1 ~]#

If you need external check you can use pingdom tools, for instance.

How to get number of registered users in WordPress databases (if you have a lot of databases)

Task

There are a lot of WordPress based websites (as well as not WordPress) databases on your box.  It’s necessary to get  number of registered users in WordPress databases only.

Solution

Collecting WordPress databases:

mysql -Bse " use information_schema; select TABLE_SCHEMA from TABLES where table_name like 'wp_users';" > wp_users.txt

Getting the numbers:

for i in $(cat wp_users.txt ) ; do echo -n $i " "; mysql -Bse "use $i ; select count(id) from wp_users " ; echo ; done | sort -rnk2 | less

How to send a message over Jabber from Python

Sending a message over Jabber from Python is a simple task. Let’s install Python Jabber/XMPP implementation called pyxmpp2:

python-pip install pyxmpp2

Now download client example:

wget https://raw.github.com/Jajcus/pyxmpp2/master/examples/send_message_client.py

And run:

python send_message_client.py

After you enter all data a message will be sent.

Why WordPress is great

  1. It’s the most popular blogging CMS nowadays.
  2. WordPress is easy to install (minutes), maintain (automatic updates feature from the box) and use (just give it a try).
  3. It’s has thousands of useful plugins for almost all requirement you might need.
  4. It also has really a lot of themes (both free of charge and commercial).
  5. It’s famous for its helpful community.
  6. You can host your WordPress blog for free on wordpress.com.
  7. You don’t need to have special skills to share you knowledges.

How to run a script as another user (without password) on Linux

Probably, it’s one of the most common tasks: running some scripts as another user and not being root. Here’s a solution.

1. Run visudo. If you don’t have it make sure you have sudo installed.

2. Add next line:

myuser ALL=(anotheruser) NOPASSWD: /home/anotheruser/bin/script.py

3. Run:

sudo -u anotheruser /home/anotheruser/bin/script.py