Limit band with in Linux

To limit for interface

sudo apt-get install wondershaper

In terminal find out what is the name of the interface connected to your internet by using ifconfig. Could be eth0, eth1, eth2, etc... In my case is eth1. So, I would do this:

sudo wondershaper [interface] [dowload limit] [upload limit] 
eg : sudo wondershaper eth1 1024 256
If you want to reset that do this sudo wondershaper clear eth1

NOTE : This will limit entire speed of ysytem becasue , the limit applied to interface.

To limit the speed by application, we use below 
sudo apt-get install trickle
sudo trickle -d [download limit] -u [upload limit] [application name]
eg : sudo trickle -d 120 -u 32 firefox

NOTe : Without application name it will apply to over all system.

Advertisements

how to move elasticsearch data from one server to another

npm install -g elasticdump elasticdump --input=http://mysrc.com:9200/my_index --output=http://mydest.com:9200/my_index --type=mapping elasticdump --input=http://mysrc.com:9200/my_index --output=http://mydest.com:9200/my_index --type=data

More details over at:

https://www.npmjs.com/package/elasticdump


Jenkins on Ubuntu

Before we can install Jenkins, we have to add the key and source list to apt. This is done in 2 steps, first we’ll add the key.

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -

Secondly, we’ll create a sources list for Jenkins.

echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
apt-get update
apt-get install jenkins

Now that Jenkins is running, go to ci.company.net:8080. You’ll be welcomed by the default Jenkins screen.

CURL request on a self-signed SSL certificate API

When we are using cURL to retrieve a HTTPS site that is not using a CA-signed certificate, the following problem occurs.

SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html
To overcome this issue, follow the below steps

You might like to backup /etc/ssl/certs before executing the command.

 

Check ssl path in OS

:~# openssl version -d
 OPENSSLDIR: "/usr/lib/ssl" 

:~# cd /usr/lib/ssl && ls -al

:~# /usr/lib/ssl# cd certs

Change to /usr/share/ca-certificates directory and add you self-signed certificate there, (ex: your.cert.name.crt)

:~# cd /usr/share/ca-certificates cp or create the crt/pem file here Change to /etc directory and edit the file ca-certificates.conf.

:~# cd /etc 
:~# nano ca-certificates.conf 

Add your.cert.name.crt to the file (ca-certificates.conf) and save it.

Execute the program update-ca-certificates --fresh.

:~# update-ca-certificates --fresh
you would have something like below
 Clearing symlinks in /etc/ssl/certs...done. Updating certificates in /etc/ssl/certs....done. Running hooks in /etc/ca-certificates/update.d....done.

Test with curl on your target HTTPS site and it should work now.

AWS SDK V3 – S3 signed url – Laravel

$s3Client = \App::make(‘aws’)->createClient(‘s3’);
$bucket =[bucket name];
$key = [file name];
$command = $s3Client->getCommand(‘GetObject’, array(
‘Bucket’ => $bucket,
‘Key’ => $key,
‘ResponseContentDisposition’ => ‘attachment; filename="’.$key.’"’,
));
$request = $s3Client->createPresignedRequest($command, ‘+10 minutes’);
$signedUrlCannedPolicy = (string) $request->getUri();
echo "singed s3 url =>".$signedUrlCannedPolicy;

Note : you should have configured the s3 access key and secret key in config/aws.php