Sincronizzare una directory tra due server linux

Obiettivo vogliamo mantenere la stessa directory sincronizzata su due server linux. Questo significa che ogni aggiunta/rimozione/modifica di file in questa directory verrà automaticamente riportato sull’altro (salvo conflitti). Diamo per assunto che i due server siano raggiungibili via rete, ma per qualsiasi motivo non sia possibile collegare dello spazio disco condiviso. Implementazione Per raggiungere lo scopo, utilizzeremo il tool: csync2 su entrambi i server (che chiameremo nodo1 e nodo2), installiamo i pacchetti necessari: ...

March 20, 2015 · Andrea Manzini

A new project to learn the D Programming Language

I’ve started a new side project named D Lang Koans, it’s a simple series of exercises organized in a unit test suite. The “koans” are heavily inspired by similar projects for other languages, but I didn’t found anything similar for D. I’ll try to maintain and evolve it in the spare time, I hope you’ll find it useful.

December 7, 2014 · Andrea Manzini

monitor apache performance statistics

the Apache module mod_status is very useful for inspecting your running webserver, but it gives you only realtime informations about workers, connections, and so on. I wanted a way to keep this data and then be able to do comparison, charts and more useful reports. The first step was configuring mod_status in order to be only accessible from localhost: andrea@myserver:~$ cat /etc/apache2/mods-enabled/status.conf <IfModule mod_status.c> # # Allow server status reports generated by mod_status, # with the URL of http://servername/server-status # Uncomment and change the "192.0.2.0/24" to allow access from other hosts. # <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 ::1 # Allow from 192.0.2.0/24 </Location> # Keep track of extended status information for each request ExtendedStatus On # Determine if mod_status displays the first 63 characters of a request or # the last 63, assuming the request itself is greater than 63 chars. # Default: Off #SeeRequestTail On <IfModule mod_proxy.c> # Show Proxy LoadBalancer status in mod_status ProxyStatus On </IfModule> </IfModule>...

November 5, 2014 · Andrea Manzini

Linux: get simple I/O statistics per process

I had a trouble with a long process running and wish to know how much I/O this process is doing, so I wrote this quick and dirty python 2.x script: import time,sys,datetime def read_stat(pid): f=open("/proc/%s/io" % pid ,"r") for line in f: if line.startswith('rchar'): rchar=line.split(':')[1] continue if line.startswith('wchar'): wchar=line.split(':')[1] continue f.close() return int(rchar),int(wchar) pid=sys.argv[1] r0,w0 = read_stat(pid) while 1: time.sleep(1) r1,w1 = read_stat(pid) print "%s\t\tr=%s\t\tw=%s" % (datetime.datetime.now().time(),r1-r0,w1-w0) r0,w0=r1,w1...

August 22, 2014 · Andrea Manzini