Outils pour utilisateurs

Outils du site


blog

Notes swap mémoire

Voir :

ZRAM ZSWAP:

K8S :

Mesure / Perf :

Voir aussi :

systemctl --type swap
cat /proc/swaps
cat /proc/vmstat

Voir :

Swap is a memory management technique where idle memory pages are moved to temporary storage

Swappiness
0 → 100
Prefer RAM → Swap aggressively

Cache Pressure
0 → 100
Keep caches → Drop caches aggressively

echo 0 > /proc/sys/vm/swappiness
# cat /proc/sys/vm/vfs_cache_pressure
# sysctl -w vm.vfs_cache_pressure=50
# Allocate storage and restrict access
fallocate --length 4GiB /swapfile
chmod 600 /swapfile
 
# Format the swap space
mkswap /swapfile
 
# Activate the swap space for paging
swapon /swapfile

Analyse consommation

Consommation de la SWAP par utilisateur

smem -u -s swap

Consommation de la SWAP par process

smem -s swap

ou

echo -e "SWAP_KB\tPPID\tPID\tEXE"
 
for S_FILE in /proc/[0-9]*/ ; 
do 
  S_PPID="$(awk '/^PPid:/ { print $2}' ${S_FILE}/status)" ;
  S_PID="$(echo ${S_FILE}/status | cut -d'/' -f3)" ;  
  S_EXE="$(readlink $S_FILE/exe)" ; 
  S_SWAPKB="$(awk '/VmSwap/ { print $2}' ${S_FILE}/status)" ; 
  [ ! -z $S_SWAPKB ] && echo -e "$S_SWAPKB\t${S_PPID}\t${S_PID}\t${S_EXE}" ; 
done | sort -n

ou

for file in /proc/*/status ; do awk '/Tgid|VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | grep kB | sort -k 3 -n

dphys-swapfile

dphys-swapfile swapoff 

Recommandations SWAP

Prereq Oracle
RAM Swap Space
Between 1 GB and 2 GB 1.5 times the size of the RAM
Between 2 GB and 16 GB Equal to the size of the RAM
More than 16 GB 16GB
RAM Swap Space
Between 8 GB and 16 GB Equal to the size of the RAM
More than 16 GB 16GB
Recommandations RedHat

Source : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_storage_devices/getting-started-with-swap_managing-storage-devices

Amount of RAM in the system Recommended swap space Recommended swap space if allowing for hibernation
⩽ 2 GB 2 times the amount of RAM 3 times the amount of RAM
> 2 GB – 8 GB Equal to the amount of RAM 2 times the amount of RAM
> 8 GB – 64 GB At least 4 GB 1.5 times the amount of RAM
> 64 GB At least 4 GB Hibernation not recommended

Utilisation de SWAP alors que la RAM n'est que partiellement utilisé

En anglais sur les forums :

Voir :

Voir aussi :

  • Shared Memory
  • zramctl
cat /proc/meminfo
 
cat /proc/sys/vm/swappiness
 
# default value of vfs_cache_pressure=100
# beyond 100 may have negative performance impact.
cat /proc/sys/vm/vfs_cache_pressure
 
cat /proc/sys/vm/dirty_ratio
cat /proc/sys/vm/dirty_background_ratio
cat /proc/sys/vm/overcommit_ratio

Voir VmSwap ou VmSize

ps -eo pmem,pcpu,rss,vsize,args --sort rss
grep VmSwap /proc/*/status | sort -n -r --key=2.1 | head -5
grep Vm /proc/3593/status

Tests SWAP

Utiliser 2 giga de mémoire

stress --vm 1 --vm-bytes 2G --timeout 30

Vérif

journalctl -k | grep -i "out of memory"

Autres test

#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
 
int main()
{
    char *p;
    size_t s = 100 * 1024 * 1024;
 
    for (;;)
    {
        p = malloc(s);
        bzero(p, s);
        sleep(1);
    }
 
    /* unreached */
}

Source : https://bbs.archlinux.org/viewtopic.php?id=212750

2025/03/24 15:06

Notes SVN Subversion

Client

Voir : Svn erreur svn cannot negotiate authentication mechanism

Voir aussi : Git

svn status
svn revert plop/foo
svn rm plop/
svn commit -m "* message"

“svn unadd”

svn revert --recursive folder_name

Mode non interactif

svn --non-interactive --trust-server-cert --username toto --password 'P@ssw0rd' --no-auth-cache checkout https://srv-svn/projet

Changer les droits posix. Equivalent à chmod +x

svn propset svn:executable ON plop.sh

Revert all

svn revert -R .

Undo commit

svn update
 
# Undo range
svn merge -r UPREV:LOWREV .
 
# Undo single revision
svn merge -c -REV .

Proxy

~/.subversion/servers

[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = defaultproxy.whatever.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
 
http-proxy-host = 192.168.56.1
http-proxy-port = 3128

Ou voir /etc/subversion/servers

SVN diff avec Vimdiff

~/.local/bin/svnvimdiff.sh

#!/bin/sh
 
/usr/bin/vimdiff ${6} ${7}
chmod +x ~/.local/bin/svnvimdiff.sh

Utilisation

svn diff  --diff-cmd ~/.local/bin/svnvimdiff.sh README.md 

Source : https://stackoverflow.com/questions/7866286/how-to-view-svn-diff-in-vimdiff-style-in-svn

Pb

Pb - svn demande le mot de passe à chaque commande - linux svn keeps asking for password
Solution 1

~/.subversion/config ou /etc/subversion/config

[auth]
password-stores =

Le mot de passe est enregistré en clair ici : ~/.subversion/auth/svn.simple/

Ou sinon

~/.bashrc

# gpg-agent is used by svn (svn keep asking for password if GPG_TTY is not set)
GPG_TTY=$(tty)
export GPG_TTY
Solution 2

Utiliser l'option --no-auth-cache

svn --non-interactive --trust-server-cert --username toto --password 'P@ssw0rd' --no-auth-cache checkout https://srv-svn/projet

Serveur

Install serveur Subversion

Voir : https://doc.ubuntu-fr.org/subversion

Voir aussi :

Source : https://stackoverflow.com/questions/4797242/install-subversion-on-ubuntu-with-nginx-not-apache

Si pas besion de HTTP

svnadmin create /path/to/repository

Puis Then you can check out local copies directly:

svn co /path/to/repository /path/to/my/checkout

Ou over ssh:

svn co svn+ssh://server/path/to/repository
Notes install avec Apache

Source : http://hikage.developpez.com/linux/tutoriels/subversion/?page=page_2

apt-get install subversion libapache2-mod-svn libapache2-svn apache2 apache2-utils #subversion-tools
a2enmod dav_svn
mkdir -p /var/subversion/depot/
svnadmin create /var/subversion/depot/projet1/

/etc/apache2/mods-available/dav_svn.conf

<Location /svn>
        DAV svn
        Require valid-user
        SVNParentPath /var/subversion/depot/
        AuthType Basic
        AuthName "Mon dépôt"
        AuthUserFile /var/subversion/conf/htpasswd
        AuthzSVNAccessFile /var/subversion/conf/access
</Location>
mkdir /var/subversion/conf/
htpasswd -c /var/subversion/conf/htpasswd jibe
htpasswd /var/subversion/conf/htpasswd utilisateur2

/var/subversion/conf/access

[groups]
devfoo  = jean, utilisateur2
 
[projet1:/]
@devfoo = rw
 
[projetprivejean:/]
jean = rw
* = r
 
[projetprivejean:/documentation/utilisateur]
auteurdoc = rw
chown www-data: -R /var/subversion/
mkdir /tmp/plop
cd /tmp/plop
mkdir trunk tags branches
svn import file:///var/subversion/depot/projet1 -m 'Initial project directories'
Notes install sans Apache
cd /var/
mkdir svn
svnadmin create /var/svn/projet1
#chmod o-r /var/svn/projet1/conf/authz
#chmod o-r /var/svn/projet1/conf/passwd
 
cd /var/svn/projet1
mkdir trunk tags branches
#svn import /var/svn/projet1/tags  file:///var/svn/projet1/ -m 'Initial project directories'

/var/svn/projet1/conf/svnserve.conf

[general]
anon-access = none
password-db = passwd
realm = Projet 1

/var/svn/projet1/conf/passwd

[users]
jibero = jibe
jiberw = jibe

/var/svn/projet1/conf/authz

[/plop]
jibe = rw
sudo addgroup svn --system
sudo adduser svn --system --home /var/svn --no-create-home --ingroup svn
sudo chown -R svn: /var/svn
 
su - svn  -s /bin/bash -c 'svnserve -d --foreground -T -r /var/svn/projet1 --listen-port=3690 --listen-host=localhost'
2025/03/24 15:06

Notes Supervisor

Voir Notes PID1 conteneurs

[program:plop]
directory=/home/plop/front-website/
command=/home/plop/front-website/front-website -bind=":8081"
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/plop/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/plop/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = plop
[program:gogs]
directory=/home/git/gogs/
command=/home/git/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
environment = HOME="/home/git", USER="git"
user = git
/usr/bin/supervisorctl -c /opt/etc/supervisord.conf

Si modif config

reread
update

Relacement du service supervisor

reload

Docker no logs

[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
2025/03/24 15:06

Changer le mot de passe root via script sur RedHat / CentOS

echo 'root:P@ssw0rd' | chpasswd
#echo "utilisateur:P@ssw0rd|chpasswd -cSHA512
echo "password" | passwd hacluster --stdin

Attention : ce n'est pas sécurisé.

Autres

read -s PASS
 
# Ou
set +o history
export PASS=P@ssw0rd
set -o history
2025/03/24 15:06

Notes Supervision

Ne pas dire supervision mais observabilité. Ça fait mieux.

Outils

Ex :

  • Zabbix
  • Nagios
  • Check mk / Shinken
  • Nagstamon
  • CachetHQ
  • Riemann.io (Supervision & Alerting)

Sondes

System
lsof +L1
Apache2
apachectl status || lynx localhost/server-status
Expiration certificat SSL/TLS

Voir :

Script :

openssl s_client -connect gnunet.org:443 </dev/null 2>/dev/null| openssl x509 -enddate -noout

Source : http://www.bortzmeyer.org/tester-expiration-certifs.html

check-tls.sh

#!/bin/bash
# Author: Kim Minh Kaplan, 2010.
 
set -e
 
# The $statedir/check-tls.status file should contain one line per
# server to be checked:
#
#    <server>:<port> [last-epoch [CAfile [openssl-extra-args]]]
#
# For example:
#
#    www.example.com:443
#    www.example.org:443 0 /etc/certs/my-own-ca-bundle.pem
#    www.example.net:25 0 /etc/certs/my-own-ca-bundle.pem -starttls smtp
#
# LIMITATIONS/BUGS:
#
# * Requires OpenSSL
#
# * Probably only works on a GNU system (bash, coreutils).
#
# * Only check the expiration date of the certificate. Not its purpose,
#   identity, revocation or any other validity parameters.
#
# * Only check the expiration date of the server certificate but *not*
#   the expiration date of intermediate or root certificate
#
# * Empty lines in $statedir/check-tls.status are *not* ignored and
#   induce an error message "no port defined".
 
OPENSSL="openssl"
 
# Alertes à moins de 90, 60, 30, 15, 7, 6, 5, 4, 3, 2, 1 jour.
alert=(90 60 30 15 7 6 5 4 3 2 1)
 
statedir=/var/tmp/lib/monitor
test -d "$statedir" || install -d "$statedir"
mkdir "$statedir/check-tls.lock" || exit
trap "rmdir \"$statedir/check-tls.lock\"" 0
 
nowepoch=`date +%s`
>"$statedir/check-tls.$$"
while read host_desc prevepoch ca_file openssl_args
do
    if test -z "$prevepoch"
    then
	prevepoch=0
    fi
 
    # Find expiry epoch
    tmpf=/tmp/$host_desc-$$.log
    if $OPENSSL s_client -CAfile "${ca_file:-/etc/ssl/certs/ca-certificates.crt}" $openssl_args \
	-connect $host_desc </dev/null >"$tmpf" 2>&1
    then
	if grep -q '^ *Verify return code: 0 (ok)$' "$tmpf"
	then
	    true
	else
	    echo "======================================================================" >&2
	    echo "Error verifying $host_desc" >&2
	    cat "$tmpf" >&2
	    rm -f "$tmpf"
	    echo "$host_desc $prevepoch $ca_file $openssl_args" >>"$statedir/check-tls.$$"
	    continue
	fi
	enddate=`$OPENSSL x509 -in "$tmpf" -noout -enddate | cut -f 2- -d =`
	rm -f "$tmpf"
    else
	cat "$tmpf" >&2
	rm -f "$tmpf"
	echo "$host_desc $prevepoch $ca_file $openssl_args" >>"$statedir/check-tls.$$"
	continue
    fi
    endepoch=`date -d "$enddate" +%s`
 
    if test $endepoch -le $nowepoch
    then
	echo "Alert: expired $host_desc" >&2
	prevepoch=$nowepoch
    else
	# Find the largest not yet triggered alert: it is the maximum that is still below prevspan
	prevspan=`expr \( $endepoch - $prevepoch \) / 60 / 60 / 24`
	nextalert=none
	for j in ${alert[@]}
	do
	    if test $j -lt $prevspan
	    then
		if test $nextalert = none
		then
		    nextalert=$j
		elif test $j -gt $nextalert
		then
		    nextalert=$j
		fi
	    fi
	done
	if test $nextalert = none
	then
	    echo "$host_desc $prevepoch $ca_file $openssl_args" >>"$statedir/check-tls.$$"
	    continue
	fi
 
	# Alert if necessary
	spanepoch=`expr $nextalert \* 60 \* 60 \* 24`
	if test `expr $endepoch - $nowepoch` -lt $spanepoch
	then
	    expire=`date -I -d @$endepoch`
	    echo "Alert, $host_desc expires $expire (less than $nextalert days)" >&2
	    prevepoch=$nowepoch
	fi
    fi
    echo "$host_desc $prevepoch $ca_file $openssl_args" >>"$statedir/check-tls.$$"
done <"$statedir/check-tls.status"
mv "$statedir/check-tls.$$" "$statedir/check-tls.status"
Sonde check générique à faire

Voir :

Fichiers sensibles :

  • /etc/passwd
  • /etc/shadow

RW partition. touch /.check

date / time : ntpdate ?

MAJ

Service KO

Alerte avant l'expiration des domaines

/etc/passwd uid 0

dmesg

Comptes LDAP

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki