Posts

Find Which Processes are Using Swap

I was doing s ome testing on my Virtuozzo linux VPS and wanted to find what was using the swap. The short version is that processes that have not been used in a long time will be moved into swap to free up RAM. I found the following page with a one-liner to show the running processes and the amount of swap they are using (including processes with 0 kB of swap).  https://www.cyberciti.biz/faq/linux-which-process-is-using-swap/  I modified the one-liner to only show processes using swap. for file in $(grep -El "VmSwap:\s+[1-9][[:digit:]]* kB" /proc/*/status) ; do awk '/Name:|VmSwap:/{printf $2 " " $3}END{ print "" }' $file; done | sort -k2nr php-fpm 488792 kB php-fpm 485172 kB php-fpm 475640 kB php-fpm 469504 kB php-fpm 469100 kB php-fpm 462044 kB php-fpm 439604 kB php-fpm 430868 kB php-fpm 410124 kB php-fpm 389892 kB php-fpm 381132 kB php-fpm 380136 kB php-fpm 379988 kB php-fpm 379216 kB php-fpm 316296 kB mysqld 225884 kB php-fpm 92096 kB php-fpm 91

Excel - Combine Multiple CSV Files

Open a blank workbook Select the Data menu Select Get Data -> From File -> From Folder Select "Browse..." and navigate to the folder containing the CSV files Select "OK" Select "Transform Data" Use the filter in the 3rd column (Name) to deselect any files you do not want included in the dataset Click the double arrow icon (Combine Files) on the right of the 2nd column (Content) Select "OK" Select the "Source.Name" column Select "Remove Columns" from the Ribbon Ensure the first column of data is highlighted Select Remove Rows -> Remove Blank Rows from the Ribbon Select "Close & Load" from the Ribbon You can now save the combined files as a CSV file.

YumRepo Error: All mirror URLs are not using ftp, http[s] or file

A very old server that had a service dependant on CentOS 5 Running any yum command resulted in yum check-update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile YumRepo Error: All mirror URLs are not using ftp, http[s] or file.  Eg. Invalid release/repo/arch combination/ YumRepo Error: All mirror URLs are not using ftp, http[s] or file.  Eg. Invalid release/repo/arch combination/ YumRepo Error: All mirror URLs are not using ftp, http[s] or file.  Eg. Invalid release/repo/arch combination/ The answer was that the mirrorlists needed to be updated to point at the last version of CentOS 5. Stolen from here:  https://www.linuxquestions.org/questions/centos-111/yumrepo-error-centos-5-9-a-4175604669/#post5704920 echo "http://vault.centos.org/5.11/os/x86_64/" > /var/cache/yum/base/mirrorlist.txt echo "http://vault.centos.org/5.11/extras/x86_64/" > /var/cache/yum/extras/mirrorlist.txt echo "http://vault.centos.org/5.11/updat

Plesk - Decrypt FTP Passwords

I was working on a project where Plesk user details were being imported into a database and it would help to know the password. Since Plesk 11 the Plesk Client account is hashed which makes it unrecoverable, but other passwords are encrypted with 128 bit AES encryption and a salt. If the FTP login name is the same as the client login there is a chance the customer was lazy and used the same details. To decrypt the passwords you will need the server secret key and the password string from the plesk database. The server secret key can be retrieved with the following command on a linux server: cat /etc/psa/private/secret_key | base64 Matching FTP logins (and their encrypted password) can be retrieved from the Plesk database with: SELECT REPLACE(s.home, '/var/www/vhosts/', '') AS domain, c.login, a.password FROM clients c LEFT JOIN sys_users s ON s.login = c.login LEFT JOIN accounts a on s.account_id = a.id; The results will look like: +-------------------

MySQL - Sort by IP Address

If you have a column containing ip addresses, sort the ip addresses numerically with: ORDER BY  INET_ATON(ip_address_column)

systemctl: Show running services

systemctl list-units --type service --state running

Google Maps API: Allow local files from your desktop computer

Assuming that you have already created the key... Go to https://console.developers.google.com/apis/credentials Make sure you have the right project selected from the dropdown at the top Click the API Key Under "Application restrictions" select "HTTP referrers (websites)" Under "Website restrictions" click "ADD AN ITEM" Put __file_url__//*  into the box that appears Click "SAVE"