How to send OPTIONS request with curl
curl -X OPTIONS --verbose example.com
curl -X OPTIONS --verbose example.com
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.
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.
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
By default ProFTPd server on Centos 5.9 tries to resolve current hostname to get IP address to bind. So if it fails if you hostname doesn’t resolve. To make it listen the socket on your IP add this line to your configuration file:
DefaultAddress 192.168.1.1
It will do the trick. Just change it to your actual IP.
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.
To enable “Screen Options” for all user one might need to install Adminimize plugin which significantly extends permissions management for the users in WordPress.
To add Google Analytics code to Sinatra application there’s a need to install gem rack-google-analytics.
gem install rack-google-analytics
Add this to your app.rb:
require 'rack-google-analytics' use Rack::GoogleAnalytics, :tracker => 'UA-XXXXXXXX-X'
And restart the app.
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
[root@bender ~]# yum search openjdk Loaded plugins: security, show-leaves ============================= N/S Matched: openjdk ============================= java-1.7.0-openjdk.i686 : OpenJDK Runtime Environment java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle thermostat.x86_64 : A monitoring and serviceability tool for OpenJDK Name and summary matches only, use "search all" for everything.
[root@bender ~]# yum install java-1.7.0-openjdk.x86_64
This is it.
To remove empty lines run:
sed '/^$/d' /home/dandelion/itsfile.txt
To remove lines matching the pattern:
sed '/patter/d' /home/dandelion/itsfile.txt
Add -i option to remove in a file itself, instead of printing the output to stdout.