Executer quelques chose à chaque changement dans une arborescence

Written by admin on July 18, 2016 Categories: Ligne de commande, Linux, Service Tags: , ,
while inotifywait -r -e modify -e move -e create -e delete --exclude .swp .; 
do  pkill flask; 
    sleep 1; 
    flask run --host=0.0.0.0 & 
done
No Comments on Executer quelques chose à chaque changement dans une arborescence

Docker, passer des variables d’environnement au boot

Written by admin on November 17, 2015 Categories: Docker Tags: , , ,

Dockerfile

ADD start.sh start.sh
ENTRYPOINT [ "./start.sh" ]

start.sh

#!/bin/bash
echo "root:$PASS" | chpasswd
/usr/sbin/sshd -D

Docker run

docker run -d -P -p 22001:22 --name sshd001 --env PASS="password$i" sshd
No Comments on Docker, passer des variables d’environnement au boot

Limit docker ressources

Written by admin on  Categories: Docker Tags: , , ,
docker run --cpu-shares 20 --memory 300M --memory-swap -1 -d -P -p 22001:22 --name sshd001 sshd
  • –cpu-shares 20: donne 20% de ressources CPU max
  • –memory 300M: limite à 300M la mémoire
  • –memory-swap -1: swap ilimitée
No Comments on Limit docker ressources

Very simple haproxy config

Written by admin on October 5, 2015 Categories: Applicatif/MW, Service Tags: , , , , ,
global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 10000
        timeout client  10000
        timeout server  10000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http


listen appname 0.0.0.0:80
    mode http
    stats enable
    stats uri /haproxy?stats
    stats realm Strictly\ Private
    stats auth admin:stress
    balance roundrobin
    option httpclose
    option forwardfor
    server stress-web1 XX.XX.XX.XX:80 check
    server stress-web1 YY.YY.YY.YY:80 check
    server stress-web1 ZZ.ZZ.ZZ.ZZ:80 check
No Comments on Very simple haproxy config

Real IO test

Written by admin on September 22, 2015 Categories: Hardware, Linux, Stockage Tags: , , , ,
apt-get update && apt-get -y install libaio-dev libaio1 git make gcc
git clone git://git.kernel.dk/fio.git
cd fio
./configure
make
cat > examples/disk-zone-profile.fio << EOF
[global]
bs=64k
direct=1
rw=randrw
ioengine=libaio
iodepth=2
zonesize=256m
zoneskip=2g
write_bw_log=str

[/dev/vdb]
EOF
./fio examples/disk-zone-profile.fio
No Comments on Real IO test

Start an instance and connect

Written by admin on August 12, 2015 Categories: OpenStack Tags: , , , , ,
function nssh {
        arg=$@
        srv=${@: -1}
        nova delete $srv && sleep 5
        id=$(nova boot $arg | grep '|\s*id\s*|\s' | awk '{ print $4 }');
        echo "ACK from Nova, id: $id"
        while true; do
                ip=$(nova show $id | grep 'Ext-Net network' | grep '[0-9]*.[0-9]*.[0-9]*.[0-9]*' |awk '{ print $5 '});
                if [ "-$ip-" != "--" ]; then
                        echo "IP found, ip: $ip"
                        break;
                else
                        sleep 3;
                fi;
        done;
        while true; do
                op=$(nmap -p22 -PN -PS22 $ip | grep '22/tcp\s*open\s*ssh');
                if [ "-$op-" != "--" ]; then
                        echo "SSH available, connecting..."
                        ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $ip
                        break
                else
                        sleep 1;
                fi;
        done;
 };

 

 

No Comments on Start an instance and connect

1 command to install apt-file and find a file

Written by admin on August 10, 2015 Categories: Ligne de commande Tags: , ,
apt-get update && apt-get -y install apt-file && apt-file update && apt-file search my_file
No Comments on 1 command to install apt-file and find a file

Debug python code

Written by admin on July 31, 2015 Categories: Dev Tags: , ,

Level 1

f = open('/tmp/debug','a')
f.write(variable + '\n')
f.close()

Level 2

from pprint import pprint
pprint(variable.__class__.__name__, f)
pprint(dir(variable), f)
pprint(vars(variable), f)

Level 3 (sur une exception)

import traceback
f.write(str(traceback.format_exc()))

 

No Comments on Debug python code

Problème SSL sur les clients python d’OpenStack

Written by admin on November 18, 2014 Categories: OpenStack Tags: , , ,

En cas de self-signed certificat non reconnu.

alias glance='glance --insecure'
alias nova='nova --insecure'
alias cinder='cinder --insecure'
alias keystone='keystone --insecure'
alias neutron='neutron --insecure'
No Comments on Problème SSL sur les clients python d’OpenStack

Push des modifs git

Written by admin on November 10, 2014 Categories: Uncategorized

On créé une branch et on utilise cette branch

git checkout -b mabranch

On fait les modifs, puis on les ajoute au futur commit

git add monficher

On commit avec un commentaire

git commit -m "mon commentaire de commit"

Et on push upstream

git push --set-upstream origin ...

 

No Comments on Push des modifs git