DevOps by Default Blog

Yum downgrade packages

5 Sep 2016 (847 words) - If you upgrade RPMs with yum upgrade and then later wish you hadn’t done, then it is pretty simple to downgrade them using yum downgrade. Consider our example below, upgrading systemd: [vagrant@localhost ~]$ sudo yum upgrade systemd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ukfast.co.uk * extras: repo.bigstepcloud.com * updates: www.mirrorservice.org Resolving Dependencies --> Running transaction check ---> Package systemd.x86_64 0:219-19.el7_2.7 will be updated --> Processing Dependency: systemd = 219-19.el7_2.7 for package: systemd-sysv-219-19.el7_2.7.x86_64 ---> Package systemd.x86_64 0:219-19.el7_2.12 will be an update --> Processing Dependency: systemd-libs = 219-19.el7_2.12 for package: systemd-219-19.el7_2.12.x86_64 --> Running transaction check ---> Package... read more

Finding number of connections from hosts using netstat

16 Jul 2016 (82 words) - Perhaps you’re trying to find out where all your incoming connections are coming from to a server. If for example, it’s a MySQL database then you may be interested in connections on TCP port 3306. netstat -n | grep :3306 | awk '{ print $5 }' | cut -d':' -f1 | sort -n | uniq -c read more

Manually extending hard disk space

14 Jul 2016 (337 words) - (on SkyScape/UKCloud) Perhaps an instance is running low on disk space and you’d like to extend it? Unfortunately on Skyscape there doesn’t seem to be a way to do this via terraform at present, but it can be achieved manually by: Skyscape Portal Login to the SkyScape’s portal Locate the vApp in question, then locate the VM contained within it. Right click and select ‘properties’ Under the hardware tab, click ‘+’ under the exsiting hard drive and add another on the next bus. Type the size required for the new disk, eg. 146G Click OK and wait until the changes... read more

Prompt for input in Windows CMD batch script

15 Nov 2015 (120 words) - Occasionally you may be writing a DOS Windows CMD batch program and want input from the user at run time. For just such an occasion, you can use the set /p command. In this example below, we ask the user to enter an IP address, then we use the captured input to set the next hop for each of the routes. There is no validation in this example, its just quick and dirty. @echo off set /p NEXTHOP="Enter the next hop for these few static routes: " %=% route -p add 10.10.10.111 mask 255.255.255.255 %NEXTHOP% metric 1 route -p add... read more

Create a gem repo

31 Jan 2015 (3697 words) - Create a Gem Repo Creating your own gem repo is easy. Install ruby and rubygems packages Install the builder gem Run gem generate_index to create the repo metadata Publish the directory with indexing using your favourite web server In this example, we do the first 3 steps on Centos7 although the concept is the same regardless of platform. To start off with, we have an arbitary directory with a few example gems kicking around inside it. [vagrant@localhost internal.gems]$ ls -lart total 288 drwxr-xr-x. 3 vagrant vagrant 4096 Sep 5 17:11 .. -rw-r--r--. 1 vagrant vagrant 182272 Sep 5 17:14 net-ssh-3.0.2.gem... read more

Find all files larger than X on Linux

29 Mar 2011 (180 words) - Find all files larger that X on Linux This example is for larger than 1GB… find /home -size +1000000k -exec du -sh {} \; if they are logs, you might want to truncate them… /usr/local/bin/trunc_our_app_logs.sh #!/bin/bash # NG20110329 - To trunc those pesky logs # ... trailing slashes are best as they work with symlinks find /opt/our_app/logs/ -name "*log.*" -mtime +7 -exec rm {} \; find /opt/our_app/logs/ -size +1000000k -exec cp -f /dev/null {} \; find /etc/httpd/logs/ -size +500000k -exec cp -f /dev/null {} \; server101:/home/ec2-user> crontab -e # Remove/trunk old/large logs. Added by NG20110329. 0 13 * * *... read more