Outils pour utilisateurs

Outils du site


blog

Power saver - power management - ACPI

Diag

ps -ef
lsmof

SystemD

/etc/systemd/logind.conf

HandleLidSwitch=ignore
systemctl restart systemd-logind
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager HandleLidSwitch
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager HandleLidSwitchDocked

You can use this to temporarily disable lid-switch events:

systemd-inhibit --what=handle-lid-switch sleep 1d
systemctl suspend
systemctl hibernate
systemctl hybrid-sleep
Disable
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Pour les portables /etc/systemd/logind.conf

[Login]
HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

Notes

apt-get install pm-utils laptop-mode-tools
Console

/etc/console-tools/config

BLANK_TIME=0
POWERDOWN_TIME=0

source : https://wiki.deimos.fr/D%C3%A9sactiver_la_mise_en_veille_de_l%27%C3%A9cran_sur_Debian.html

Battery

cat /sys/class/power_supply/BAT0/charge_full
cat /sys/class/power_supply/BAT0/charge_full_design
 
lspower
sudo apt install powertop
sudo powertop --calibrate
 
apt-get install tlp
sudo vim /etc/default/tlp
sudo tlp start

Voir https://linrunner.de/en/tlp/docs/tlp-configuration.html

Source : https://www.howtogeek.com/55185/how-to-maximize-the-battery-life-on-your-linux-laptop/

ACPI

apt-get install acpid
acpi_listen
cat /proc/acpi/wakeup
Device  S-state   Status   Sysfs node
acpi/interrupts

AE_NOT_FOUND infinitely on startup

Source : https://unix.stackexchange.com/questions/348806/acpi-exception-ae-not-found-infinitely-on-startup

If using sysdemd with rc.local disabled:

systemctl enable rc-local.service

Edit

sudo systemctl edit --full rc-local

Add to rc.local

echo "disable" > /sys/firmware/acpi/interrupts/gpe6F
C-STATE

Port USB

Le port USB se met en économie d’énergie. Par exemple la souris ne fonctionne plus après la sortie de la veille.

Voir https://logfile.ch/linux/2017/06/15/disable-usb-autosuspend-linux/

cat /sys/bus/usb/devices/<your device>/power/control
echo on > /sys/bus/usb/devices/<your device>/power/control

== Autres

Voir https://www.geeks3d.com/hacklab/20160108/how-to-disable-the-blank-screen-on-raspberry-pi-raspbian/

sudo apt-get install x11-xserver-utils

~/.config/lxsession/LXDE/autostart

@xset s off
@xset -dpms 
@xset s noblank

/etc/xdg/lxsession/LXDE/autostart !?

Ou

/etc/lightdm/lightdm.conf

[SeatDefaults]
xserver-command=X -s 0 -dpms
Exécution à l'entrée en veille / Exécution à la sortie de la mise en veille

Exemple

/lib/systemd/system-sleep/atop-pm

#!/bin/bash
 
PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
case "$1" in
        pre)    systemctl stop atop
                exit 0
                ;;
        post)   systemctl start atop
                exit 0
                ;;
        *)      exit 1
                ;;
esac
2025/03/24 15:06

Cloud - Serverless Framework

Voir : https://www.serverless.com

Install

npm install -g serverless
# Voir yarnpkg à la place de npm

Exemple

serverless
cd aws-python-project
serverless deploy
 
 
serverless invoke -f hello	
serverless invoke -f hello --log
 
serverless remove
2025/03/24 15:06

Ajout disque SAN Fibre Channel fiber channel - scan newly added fc luns and scsi disks

Source : https://www.learnitguide.net/2016/02/scan-newly-added-fc-luns-and-scsi-disks.html

Identifier les disques existants

LANG=C fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'

Identifier le numéro de l'adaptateur HBA

systool -c fc_host -v

Ou

# ls /sys/class/fc_host
host0

Rescan des LUNs

echo "1" > /sys/class/fc_host/host0/issue_lip
echo "- - -" > /sys/class/scsi_host/host0/scan

Il peut être nécessaire de rescaner les partitions

partprobe /dev/sdc
partprobe /dev/sdd

(ou addpart ?)

Ou avec le script rescan-scsi-bus.sh

yum install sg3_utils
rescan-scsi-bus.sh

Vérif

LANG=C fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-|type|identifier'
dmesg
lsblk
multipath -l
2025/03/24 15:06

Postgres - se connecter a une socket

ps -ef | grep postgres

Trouver le PID du process Postgres père \ Exemple : 2962

# ls -l /proc/2962/fd/ | grep socket
lrwx------. 1 postgres postgres 64 Aug  8 06:55 3 -> socket:[25104]
lrwx------. 1 postgres postgres 64 Aug  8 06:55 4 -> socket:[25106]
lrwx------. 1 postgres postgres 64 Aug  8 06:55 8 -> socket:[25118]
# #lsof -i -a -p 2962
# #find / -user postgres -type s 2>/dev/null
# #netstat -lx | egrep "25104|25106|25118"
# ss -xl | egrep "25104|25106|25118"
u_str LISTEN 0      2048                                            /tmp/.s.PGSQL.5455 25106               * 0
su - postgres
$ psql -h /tmp/.s.PGSQL.5455
psql: error: could not connect to server: Not a directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5455/.s.PGSQL.5432"?

$ psql -h /tmp
psql: error: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Solution

psql -h /tmp -p 5455

FIXME

2025/03/24 15:06

Postfix Liste blanche et liste noire

Librement traduit de http://www.linuxlasse.net/linux/howtos/Blacklist_and_Whitelist_with_Postfix

Nous pouvons jouer sur deux paramètres :

check_client_access \ Bloque par IP, plage d'IP ou nom DNS

check_sender_access \ Bloque par adresse email (champ FROM)

Il est important de définir check_client_access et check_sender_access en premier

/etc/postfix/main.cf

smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/etc/postfix/client_checks, check_sender_access hash:/etc/postfix/sender_checks

/etc/postfix/client_checks

# Restricts which clients this system accepts SMTP connections from.

mondomain.com             REJECT Fraud rejected
example.com               REJECT No spammers
.example.com              REJECT No spammers, from your subdomain
123.456.789.123           REJECT Your IP is spammer
123.456.789.0/24          REJECT Your IP range is spammer
321.987.654.321           OK
example1.com              OK

/etc/postfix/sender_checks

# Restricts sender addresses this system accepts in MAIL FROM commands.

example.com              REJECT env. from addr any@example.com rejected
.example.com             REJECT env. from addr any@sub.example.com rejected
user@example.com         REJECT We don't want your email
example2.com             OK
postmap /etc/postfix/client_checks
postmap /etc/postfix/sender_checks
postfix reload

Postfix bloquer un domain ou une IP

Source : http://arnofear.free.fr/linux/template.php?tuto=22&page=1

/etc/postfix/main.cf

# Permet de refuser la connexion SMTP pour les IP ou domaines contenus
# dans ce fichier.
smtpd_client_restrictions = check_client_access hash:/etc/postfix/blacklisted_sender

/etc/postfix/blacklisted_sender

# Domaine ou IP.
rolexreplica.com REJECT You are blacklisted
90.123.456.78 REJECT You are blacklisted
postmap /etc/postfix/blacklisted_sender
service postfix reload
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