Convert RAID superblock from 0.9 to 1.0

1 08 2017

The kernel wiki have a section with some documentation about this process, but it’s a bit outdated. If you have mdadm-3.3 or newer (usually yes), is it possible to change the superblock in two steps. First get the devices information:

mdadm --detail /dev/md0

And do it:

mdadm --stop /dev/md0
mdadm --assemble /dev/md0 --update=metadata ...list.of.devices...

http://www.spinics.net/lists/raid/msg48367.html
https://raid.wiki.kernel.org/index.php/RAID_superblock_formats

Advertisements




Install Prometheus and Grafana

31 07 2017

These are the steps to install Prometheus and Grafana in a standalone Linux Debian box for monitor their system with a nice dashboard.

Install the package server and exporter from the repo:

apt-get install prometheus prometheus-node-exporter

Change Prometheus to listen only in localhost and the sync strategy (if you want to save battery) /etc/default/prometheus:

ARGS="-web.listen-address=localhost:9090 -storage.local.series-sync-strategy 'never'"

Assure that there is a target in /etc/prometheus/prometheus.yml:

- job_name: node
# If prometheus-node-exporter is installed, grab stats about the local
# machine by default.
static_configs:
- targets: ['localhost:9100']

Restart it and enable in systemd:

systemctl restart prometheus
systemctl enable prometheus

Change the listen address too in the node exporter /etc/default/prometheus-node-exporter:

ARGS="-collector.diskstats.ignored-devices=^(ram|loop|fd)\d+$ \
-collector.filesystem.ignored-mount-points=^/(sys|proc|dev|run)($|/) \
-collector.textfile.directory=/var/lib/prometheus/node-exporter -web.listen-address=127.0.0.1:9100"

Restart it and enable in systemd:

systemctl restart prometheus-node-exporter
systemctl enable prometheus-node-exporter

Download Grafana from their website and install it:

mkdir /opt/grafana
cd /opt/grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_4.4.1_amd64.deb
dpkg -i grafana_4.4.1_amd64.deb

Enable and start it in systemd:

systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-server

Use the browser and enter this address (user/password: admin/admin):

http://localhost:3000

Add the Prometheus datasource as in the image:

Add a new dashboard following this path in the menu:

Type the id “1860” inside “Grafana.com Dashboard”. It automatically get it:

Confirm the import fetching the values from localhost:


Enjoy.





Change tab size in xfce 4

8 07 2017

If you use Debian 9 in a small screen with xfce 4, maybe you suffer the big tab size of some desktop elements.

For fix that, create a file under ~/.config/gtk-3.0/gtk.css with the following content:

/* reduce padding of tabs */
notebook tab {
min-height: 0;
padding-top: 1px;
padding-bottom: 2px;
}
/* reduce padding of buttons */
notebook tab button {
min-height: 0;
min-width: 0;
padding: 1px;
margin-top: 1px;
margin-bottom: 2px;
}





Netns different outgoing source ip address

7 07 2017

Using three network interfaces, assign each one a different address as source ip address for outgoing traffic:

#!/bin/bash
ip netns add blue
ip link set eth1 netns blue
ip netns add green
ip link set eth2 netns green
ip netns exec blue dhclient eth1
ip netns exec green dhclient eth2
echo "IP eth0: "
curl ipinfo.io/ip
echo "IP eth1: "
ip netns exec blue curl ipinfo.io/ip
echo "IP eth2: "
ip netns exec green curl ipinfo.io/ip





Debian Stretch 9 issue with vim: copy and paste

20 06 2017

In Debian Stetch 9 there is a new behaviour in vim, the copy and paste with the mouse is unusual and don’t work as the previous versions did. For fix it:

Edit the file (or create it): /etc/vim/vimrc.local with the following content:
runtime! defaults.vim
let g:skip_defaults_vim = 1
set mouse=

More info: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837761#76

Old solution:

In the file /usr/share/vim/vim80/defaults.vim comment the lines:

" if has('mouse')
" set mouse=a
" endif





Delete information from one host in Prometheus

30 05 2017

If we have information in Prometheus from one node and we need to remove it, the following api request solve it:

curl -X DELETE -g 'http://IP_prometheus:9090/api/v1/series?match[]={instance="IP_node_to_remove:9100"}'





Force syn date and time

21 05 2017

apt-get install tlsdate
tlsdate -H mail.google.com