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.

Advertisements




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





Enable autologin in Debian with Systemd

19 05 2017

For allow autologin in a Debian system with systemd (very usefull with testing virtual machines):

Create dir:
mkdir /etc/systemd/system/getty@tty1.service.d/

Create file /etc/systemd/system/getty@tty1.service.d/override.conf with the following content:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM

More info:
http://forums.debian.net/viewtopic.php?f=16&t=123694





Disable time sync between host and guest in Linux VirtualBox

19 05 2017

To the following files:

/home/[your_user]/.config/VirtualBox/VirtualBox.xml
/home/[your_user]/VirtualBox\ VMs/[VM_Name]/[VM_Name].vbox

Add the line:

<ExtraDataItem name="VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" value="1"/>

More info:
https://forums.virtualbox.org/viewtopic.php?f=2&t=8535&sid=40a155aafbe83d3409b73aed8f0b96dd&start=15





Deny ssh access to one user

18 05 2017

If you want to deny the access of one user (or group) to a server via ssh, these are the steps for a Debian/Ubuntu server:

Add the user to /etc/security/access.conf
- : user1 : ALL

Assure that “/etc/ssh/sshd_config” have the following line (by default yes):
UsePAM yes

Assure that “/etc/pam.d/sshd” have uncommented the following line:
account required pam_access.so





Configure phpmyadmin for connect to RDS AWS MariaDB

30 03 2017

Ensure that “/etc/phpmyadmin/config-db.php” doesn’t haven any configured values:

$dbuser='';
$dbpass='';
$basepath='';
$dbname='';
$dbserver='';
$dbport='';
$dbtype='';

Create a new file with for your particular values in “/etc/phpmyadmin/conf.d/myconf.php”

<?phpConfigure phpmyadmin for connect to RDS AWS MariaDB
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['host'] = 'name.of.rds.amazonaws.com';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = TRUE;

Go to the phpmyadmin website and log with the administrative account.

More info: http://stackoverflow.com/questions/4402482/using-phpmyadmin-to-administer-amazon-rds