Table des matières
- 2026:
- 2025:
4 billet(s) pour juillet 2026
| Procédure simple augmentation de la SWAP | 2026/07/17 15:49 | Jean-Baptiste |
| Exemple git clone avec Ansible | 2026/07/16 14:47 | Jean-Baptiste |
| Windows exe - Comparaison de fichiers binaires | 2026/07/16 10:25 | Jean-Baptiste |
| Pb git | 2026/07/01 17:36 | Jean-Baptiste |
Prometheus windows_export i386 compilation go lang
Brouillon
Nous avons besoin de récupérer le maximum de métriques sur un OS XP 32bits.
Une solution est d'utiliser windows_export (ancienement wmi_exporter) de Prometheus, cependant nous n'avons pas de version 32 bits compilée fournie par le projet.
Source : https://github.com/prometheus-community/windows_exporter
Ca ne marche pas en compilant
Go 1.10 is the last release to support Windows Vista or below
Voir :
La dernière version compatible Win32 :
Usage
C:\Program Files\windows_exporter\
Command line Usage
--config.file=CONFIG.FILE --collectors.enabled="cpu,cs,memory,logical_disk,physical_disk,net,os,service,system" --collector.tcp.enabled="metrics,connections_state" --collector.performancecounter.objects="" --collector.netframework.enabled="clrexceptions,clrinterop,clrjit,clrloading,clrlocksandthreads,clrmemory,clrremoting,clrsecurity" --collector.process.include=".+" --collector.scheduled_task.include=".+ --collector.service.include=".+" --collector.net.enabled="metrics,nic_addresses" --collector.net.nic-include=".+" --collector.time.enabled="system_time,ntp"
Usage old version wmi_exporter-0.9.0
msiexec /i wmi_exporter-0.9.0-386.msi ENABLED_COLLECTORS=cpu,cs,logical_disk,logon,memory,net,os,process,service,system,tcp,vmware
On test : http://localhost:9182
Other
https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
time=2025-04-03T11:27:26.836Z level=WARN source=cs.go:75 msg="The cs collector is deprecated and will be removed in a future release. Logical processors has been moved to cpu_info collector. Physical memory has been moved to memory collector. Hostname has been moved to os collector." time=2025-04-03T11:27:26.836Z level=WARN source=os.go:108 msg="The os collect holds a number of deprecated metrics and will be removed mid 2025. See https://github.com/prometheus-community/windows_exporter/pull/1596 for more information." collector=os
Old
Compile sur Windows
set http_proxy=http://192.168.1.221:3128 set https_proxy=http://192.168.1.221:3128 go install github.com/prometheus/promu@latest set GOARCH=386 go install github.com/prometheus-community/windows_exporter@latest cd $env:GOPATH/src/github.com/prometheus-community/windows_exporter promu build -v
Compiled on GNU+Linux WSL
sudo apt-get install gcc-multilib sudo apt-get install gcc-mingw-w64 go install github.com/prometheus/promu@latest export http_proxy=http://192.168.1.221:3128 export https_proxy=http://192.168.1.221:3128 GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64-mingw32-gcc export GOOS GOARCH CGO_ENABLED CXX CC go install github.com/prometheus-community/windows_exporter@latest cd ~/go/pkg/mod/github.com/prometheus-community/windows_exporter promu build -v
go: downloading github.com/containerd/typeurl/v2 v2.2.3 go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb go: downloading github.com/gogo/protobuf v1.3.2 github.com/prometheus-community/windows_exporter/cmd/windows_exporter: go build github.com/prometheus-community/windows_exporter/cmd/windows_exporter: copying /tmp/go-build2685928784/b001/exe/a.out.exe: open windows_exporter.exe: permission denied !! command failed: build -o windows_exporter.exe -ldflags -X github.com/prometheus/common/version.Version= -X github.com/prometheus/common/version.Revision=non-git -X github.com/prometheus/common/version.Branch=non-git -X github.com/prometheus/common/version.BuildUser=management@vlbvmdevadm01 -X github.com/prometheus/common/version.BuildDate=20250403-08:47:02 -extldflags '-static' -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter: exit status 1
Solution : remplacer build -o windows_exporter.exe par build -o /tmp/windows_exporter.exe
go build -o /tmp/windows_exporter.exe -tags trimpath github.com/prometheus-community/windows_exporter/cmd/windows_exporter
Err windows_exporter.exe is not a valid Win32 application
Voir https://learn.microsoft.com/en-us/windows/win32/debug/pe-format
$ file windows_exporter* windows_exporter.exe: PE32 executable (console) Intel 80386, for MS Windows, 13 sections windows_exporter_CompiledOnOuindoze.exe: PE32 executable (console) Intel 80386, for MS Windows, 13 section
Notes xonsh - le shell Python
Le shell Python
IPython dans sa partie shell interractive vise le même objectif.
Voir : iPython
xonfig wizard # Run the configuration wizard to create ~/.xonshrc
xonfig tutorial # Open the xonsh tutorial in the browser
# XONSH WIZARD START
source-foreign "echo loading xonsh foreign shell"
xontrib load coreutils
# XONSH WIZARD END
Notes Podman
Voir aussi :
- Apptainer/Singularity
Voir :
/etc/containers/
Rootless : https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md
Volumes / Stockage / Storage :
Installez slirp4netns (va être remplacé par pasta à partir de Podman 5)
apt-get install slirp4netns
Ensuite, configurez une quantité d'espaces de noms réseau définis par l'utilisateur :
echo "user.max_user_namespaces=28633" > /etc/sysctl.d/userns.conf sysctl -p /etc/sysctl.d/userns.conf
Cette commande permet d'utiliser les espaces de noms réseau sans être root.
Démarrage automatique
systemctl --user enable --now podman-restart
Conf registry
/etc/containers/registries.conf
[registries.search] registries = ['docker.io', 'quay.io', 'ghcr.io'] [registries.insecure] registries = []
Exemple
podman build -t jibe/dokuwiki --build-arg http_proxy="$http_proxy" --build-arg https_proxy="$https_proxy" -f Containerfile . podman run -a stdout --rm --name=dokuwiki1 -v $PWD/tmp/dokuwiki/data/:/var/www/wiki/www/data -v $PWD/tmp/dokuwiki/conf/:/var/www/wiki/www/conf -m 512m -p 8082:8080 jibe/dokuwiki
Contener - entrypoint
$ podman run --entrypoint /usr/bin/echo -ti --rm debian -e 'Test1\nTest2' Test1 Test2
#podman generate systemd --restart-policy=always -t 1 dokuwiki1 #podman generate systemd --restart=always -t 1 dokuwiki1 # podman generate systemd --new --files --name httpd # quadlet ?
Autre
echo 1 > /proc/sys/kernel/unprivileged_userns_clone
Conf UIDMAP
Voir /proc/sys/user/max_user_namespaces
| Colonne | Description |
|---|---|
| 1 | Nom de l'utilisateur système sur le hôte |
| 2 | Numéro d'UID sur le hôte correspondant à l'UID 0 du NS |
| 3 | Plage; notre d'UID à l'intérieur du NS |
sudo usermod --add-subuids 10000-75535 USERNAME sudo usermod --add-subgids 10000-75535 USERNAME
/etc/subuid
jean:100000:65536 test:165536:65536 plop:231072:65536 k8s:296608:65536
/etc/subgid
jean:100000:65536 test:165536:65536 plop:231072:65536 k8s:296608:65536
Commandes utiles
Afficher tous les mappages de ports de conteneur utilisés
podman port -a
Pour un container particulier
podman port ctn-app1
Réseau
Podman prend en charge 2 réseaux backend pour les conteneurs : Netavark et CNI.
Pour vérifier quel backend réseau est utilisé :
$ podman info --format {{.Host.NetworkBackend}}
netavark
Pour modifier le backend réseau, définissez la configuration dans /usr/share/containers/containers.conf :
[network] [...] # Network backend determines what network driver will be used to set up and tear down container networks. # Valid values are "cni" and "netavark". network_backend = "netavark"
La commande podman network create créer un réseau compatible DNS.
Création d’un réseau appelé db_network en spécifiant le sous-réseau 10.87.0.0/24 et la passerelle 10.87.0.1 :
podman network create --gateway 10.87.0.1 --subnet 10.87.0.0/24 db_network
La commande podman network inspect affiche les informations sur un réseau spécifique
La commande podman run --network permet d’ajouter le réseau DNS db_network à un nouveau conteneur
Re appliquer les règles réseau Podman
podman network reload
Avant cette commande il faillait faire un restart des containers.
A common problem is that reloading the firewall deletes the netavark iptables rules resulting in a loss of network connectivity for rootful containers.
Ultra fast reboot
Technique pas recommandé
Voir
Source article complet :
echo 1 > /proc/sys/kernel/sysrq echo b > /proc/sysrq-trigger
Ultra fast shutdown
echo 1 > /proc/sys/kernel/sysrq echo o > /proc/sysrq-trigger
Autres
last | head root pts/0 192.168.3.81 Thu May 11 09:19 still logged in reboot system boot 3.10.0-327.el7.x Thu May 11 09:17 - 09:24 (00:07) process pts/0 192.168.3.81 Wed May 10 16:42 - down (00:00) root pts/0 192.168.3.81 Wed May 10 16:34 - 16:42 (00:07) reboot system boot 3.10.0-327.el7.x Wed May 10 16:31 - 16:42 (00:10) process pts/0 192.168.3.81 Wed May 10 16:30 - 16:30 (00:00) root pts/0 192.168.3.81 Wed May 10 16:28 - 16:29 (00:01) reboot system boot 3.10.0-327.el7.x Wed May 10 16:27 - 16:42 (00:15) root pts/0 192.168.3.81 Wed May 10 16:19 - crash (00:08) reboot system boot 3.10.0-327.el7.x Wed May 10 16:15 - 16:42 (00:26)
last -x shutdown shutdown system down 3.10.0-327.el7.x Wed May 10 16:42 - 09:17 (16:34) shutdown system down 3.10.0-327.el7.x Fri May 5 18:17 - 09:04 (3+14:46) shutdown system down 3.10.0-327.el7.x Wed Apr 5 16:09 - 15:07 (29+22:58)
systemctl mask sleep.target suspend.target uptime ps -p 1 -o stime lastb chmod +s /sbin/halt chmod +s /sbin/reboot
Autres
exec /sbin/init
ulimit
Voir aussi :
- prlimit
Depuis Redhat 6 nous avons :
/etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 1024 root soft nproc unlimited www-data soft nproc unlimited
Options ulimit :
- -H : Hard
- -S : Soft
- -a : All
- -u : Nombre maximal de processus utilisateurs
ulimit -a -H ulimit -a -S
help ulimit
Voir http://fr.wikipedia.org/wiki/Fork_bomb
:(){ :|:& };:
En cas de dépassement : comment le sait-on ?
Grsecurity propose un audit des dépassements des “ulimit”
Message d'erreur ?
Pourquoi ne pas utiliser les cgroups ?
Core dump
Désactiver les cores dumps (Redhat)
/etc/profile
# No core files by default ulimit -S -c 0 > /dev/null 2>&1
Activer les cores dumps (Redhat)
su - ulimit -c unlimited
Notes
/bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/local/bin/plop
Temps réel
However, for systems with a Linux kernel 2.6.13 or newer, it is possible to allow processes without root privileges to set the real-time scheduling policy. When the Linux PAM module is installed (which is normally the case) you can control the maximum real-time priority for non-privileged processes on a per user or group basis via the /etc/security/limits.conf file.
For example, adding the line
* - rtprio 99
Outils
Appliquez les modifications directement à un processus en cours d'exécution avec prlimit
Python
import resource print(resource.getrlimit(resource.RLIMIT_NOFILE)[1])
