Outils pour utilisateurs

Outils du site


blog

Notes Systemd udev

Source https://askubuntu.com/questions/25071/how-to-run-a-script-when-a-specific-flash-drive-is-mounted

Voir :

Exemples :

lsusb

0a81:0101

/etc/udev/rules.d/100-mount-videos.rules

ACTION=="add", ATTRS{idVendor}=="0a81", ATTRS{idProduct}=="0101", RUN+="/home/your_username/bin/mount_videos.sh"

Exemple :

lsusb |grep -i touch
Bus 001 Device 009: ID 04e7:00c0 Elo TouchSystems

/etc/udev/rules.d/100-touchscreen-calibr.rules

ACTION=="add", ATTRS{idVendor}=="04e7", ATTRS{idProduct}=="00c0", RUN+="/bin/bash -c 'echo /usr/local/bin/touchscreencfg.sh |at now'"

Je ruse en uilisant at car l'appel directe au script ne fonctionne pas ( le xinput list ne fionctione pas)

/usr/local/bin/touchscreencfg.sh

#! /bin/bash
 
export DISPLAY=:0
 
NAME=$(xinput list  --name-only |grep -i touch | grep -iv ' pen')
ID=$(xinput list --id-only "$NAME")
SCREEN=$(xrandr 2>&1 |grep ' connected primary' |awk '{print $1}')
/usr/bin/xinput --map-to-output $ID $SCREEN
( sleep 5 ; /usr/bin/xinput --map-to-output $ID $SCREEN ) &

Pb

Pb 1
Solution

Utiliser at

2025/03/24 15:06

Notes sysstat sar

Install

apt-get update
apt-get install sysstat

/etc/default/sysstat

ENABLED="true"
# service sysstat restart
Starting the system activity data collector: sadc.

Utilisation

$ dpkg -L sysstat |grep 'bin/'
/usr/bin/nfsiostat
/usr/bin/pidstat
/usr/bin/sadf
/usr/bin/iostat
/usr/bin/mpstat
/usr/bin/sar.sysstat
/usr/bin/cifsiostat

Report CPU utilization

sar -u ALL

Report per-processor CPU utilization

sar -P ALL

Display all CPU utilization per 2 seconds 3 times

mpstat -P ALL 2 3
 
# mpstat -A 1

Report memory utilization

sar -r ALL

Report swap space utilization

sar -S

Report hugepages utilization

sar -H

Report paging statistics

sar -B

Report swapping statistics

sar -W

Report I/O and transfer rate statistics

sar -b

Report block device activity

sar -d

Report process creation and system switching activity

sar -w

Report queue length and load averages

sar -q

Display I/O disk with Mega bytes per 2 seconds

iostat -mx -d 2 

Report network utilization

sar -n ALL

Display I/O and network per 2 seconds 5 times

sar -b -n DEV 2 5

Display data in human readable way

sar -r -h

Display memory utilization of specific process per a second 3 times

pidstat -r -p 21090 1 3 

Charge sur une période donnée

sar -q -f /var/log/sa/sa27 -s 16:00:00 -e 17:00:00
sar -A -f /var/log/sa/sa27 -s 16:00:00 -e 17:00:00

Un peu de couleurs

env S_COLORS=always sar -A | less -R -S
env S_COLORS=always sar -n DEV | grep --color=never eth0

Voir aussi :

  • dircolors
Autres

Réseaux

sar -n ALL
sar -n DEV
sar -n TCP
sar -n ETCP
sar -n IP
sar -n EIP

Disques

iostat -p -x

Configuration

Timer
# systemctl edit --full sysstat-collect.timer
 
systemctl cat sysstat-collect.timer

/usr/lib/systemd/system/sysstat-collect.timer

# /usr/lib/systemd/system/sysstat-collect.timer
# (C) 2014 Tomasz Torcz <tomek@pipebreaker.pl>
#
# sysstat-11.7.3 systemd unit file:
#        Activates activity collector every 10 minutes
 
[Unit]
Description=Run system activity accounting tool every 10 minutes
 
[Timer]
OnCalendar=*:00/10
 
[Install]
WantedBy=sysstat.service
systemctl edit sysstat-collect.timer

/etc/systemd/system/sysstat-collect.timer.d/override.conf

[Unit]
Description=Run system activity accounting tool every 5 minutes
 
[Timer]
OnCalendar=
OnCalendar=*:5/5

Pb

# sar -n TCP
Requested activities not available in file /var/log/sa/sa31

/etc/sysconfig/sysstat

# Parameters for the system activity data collector (see sadc(8) manual page)
# which are used for the generation of log files.
# By default contains the `-S DISK' option responsible for generating disk
# statisitcs. Use `-S XALL' to collect all available statistics.
SADC_OPTIONS="-S XALL"

Important note: The activities (including optional ones) saved in an existing data file prevail over those selected with option -S. As a consequence, appending data to an existing data file will result in option -S being ignored.

2025/03/24 15:06

Notes Syncthing

Voir :

Voir aussi :

  • rclone bisync
  • Ksync qui utilise Syncthing pour synchroniser les containers (containers ou k8s)
apt-get update
apt-get install syncthing
 
adduser --group --system syncthing --home /usr/local/var/lib/syncthing

Sur A

syncthing --device-id

Sur B

syncthing --device-id

Sur A

syncthing cli config devices add --device-id $DEVICE_ID_B

Sur B

syncthing cli config devices add --device-id $DEVICE_ID_A
#syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_B

Sur A

mkdir ~/DATA_SYNCALL
 
fid=$(uuidgen)
fid=${fid%%-*}
# syncthing cli config folders add --id $fid --label "DATA_SYNCALL" --path /data/syncall/
syncthing cli config folders add --id $fid --label "DATA_SYNCALL" --path ~/DATA_SYNCALL
 
syncthing cli config folders $fid devices add --device-id $DEVICE_ID_B
 
syncthing cli config folders list

Sur B

syncthing cli config folders list
#syncthing cli config devices $DEVICE_ID_A auto-accept-folders set true
 
syncthing cli show pending folders
##syncthing cli config folders add --label DATA_SYNCALL  devices add --device-id $DEVICE_ID_A
 
syncthing cli config folders $FOLDER_ID devices add --device-id $DEVICE_ID_A

Service

Service SystemD Lingering

Source : https://github.com/syncthing/syncthing/blob/main/etc/linux-systemd/user/syncthing.service

~/.config/systemd/user/syncthing.service

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
StartLimitIntervalSec=60
StartLimitBurst=4
 
[Service]
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
 
# Hardening
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true
 
# Elevated permissions to sync ownership (disabled by default),
# see https://docs.syncthing.net/advanced/folder-sync-ownership
#AmbientCapabilities=CAP_CHOWN CAP_FOWNER
 
[Install]
WantedBy=default.target

Autres

[ZUPOI] 13:18:34 INFO: TCP listener ([::]:22000) starting
2024/10/01 13:18:34 connection doesn't allow setting of receive buffer size. Not a *net.UDPConn?. See https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size for details.
[ZUPOI] 13:18:34 INFO: QUIC listener ([::]:22000) starting

/etc/sysctl.d/80-net-core-xmem_max.conf

# Bump maximum receive buffer size to roughly 7.5 MB for Syncthing - as per
# https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size
net.core.rmem_max=7500000
net.core.wmem_max=7500000
 
#fs.inotify.max_user_watches=409600

Activer inotify

curl –s http://ipduserveur:port/rest/system | json_pp
{
"alloc": 32147752, # allocated memory, in use "cpuPercent": 0.669829340548344,
"extAnnounceOK": true, # true if we are registered with the global announce server, false on failure, absent if disabled "goroutines": 34,
"myID": "P56IOI7MZJNU2IQGDREYDM2MGTMGL3BXNPQ6W5BTBBZ4TJXZWICQ",
"sys": 66463976 # allocated memory, total
}

Source : https://www.it-connect.fr/installation-et-configuration-de-syncthing/

Dans la web UI (127.0.0.1:8384) → menu Actions → Configuration → Connexions → décocher “Découverte globale” et cocher “Découverte locale”

Ensuite, pour chaque appareil, vérifier dans → Gérer → Avancé → Adresses = “dynamic”

~/.config/syncthing/config.xml and find relaysEnabled. Set its value false.

<!-- Changer à false -->
<relaysEnabled>false</relaysEnabled>
<globalAnnounceEnabled>false</globalAnnounceEnabled>
<crashReportingEnabled>false</crashReportingEnabled>
<crashReportingEnabled>false</crashReportingEnabled>
<startBrowser>false</startBrowser>
<natEnabled>false</natEnabled>
 
<!-- Supprimer -->
<urURL>https://data.syncthing.net/newdata</urURL>
<releasesURL>https://upgrades.syncthing.net/meta.json</releasesURL>
<crashReportingURL>https://crash.syncthing.net/newcrash</crashReportingURL>
 
<!-- Changer partout "10" à "1" -->
fsWatcherDelayS="1"
 
<!-- Changer gui enabled à "false" -->
<gui enabled="false" tls="false" debugging="false">
env GOMAXPROCS=2 syncthing -no-browser
find /path/to/folder/to/force/sync -type f -print0 | xargs -0 -n1 touch

Ignore

.stignore

.git/
2025/03/24 15:06

Notes swap mémoire

Voir :

Voir aussi :

systemctl --type swap
cat /proc/swaps
cat /proc/vmstat
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

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
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
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki