Outils pour utilisateurs

Outils du site


blog

Robotic Process Automation (RPA)

Voir aussi :

  • Process Mining

Logiciels :

<https://fr.wikipedia.org/wiki/AutoHotkey|AutoHotkey (windows)>

  • OpenRPA

Logiciels privateurs :

  • uipath (Process Mining)
2025/03/24 15:06

Script de test STONITH fencing cluster

Voir :

Voir aussi :

Source :

Ce script permet d'émuler le “fencing” via SSH, à des fins de test. Compatible cman, pacemaker et pcs

/usr/sbin/fence_ssh

#!/bin/sh
 
# A fence agent for cman and pacemaker, using ssh.
# The only required argument is nodename.
# Author:
#        klwang (http://klwang.info)
# Note:
#        authorized_keys configuration are required
#        just for test, enjoy it!
# Source : https://github.com/wklxd/misc/blob/master/fence_ssh
 
 
SSH_COMMAND="/usr/bin/ssh -q -x -o PasswordAuthentication=no -o StrictHostKeyChecking=no -n -l root"
#REBOOT_COMMAND="echo '/sbin/reboot -nf' | SHELL=/bin/sh at now >/dev/null 2>&1"
REBOOT_COMMAND="shutdown -r now >/dev/null 2>&1"
nodename=
action=reboot
 
usage () {
    /bin/echo "Usage: $0 -n NAME [-o ACTION]"
    /bin/echo
    /bin/echo " -n NODENAME"
    /bin/echo "   The name of the node to be fenced."
    /bin/echo "   In case it contains spaces, use double quotes."
    /bin/echo " -o ACTION"
    /bin/echo "   What to do; on|off|list|monitor|reboot(default)."
    /bin/echo
    exit 0
}
 
arg_cmd() {
    while getopts ":n:p:o:h" opt; do
        case "$opt" in
        n|p)
            nodename=$OPTARG
            ;;
        o)
            action=$OPTARG
            ;;
        h)
            action="usage"
            ;;
        *)
            usage
            ;;
        esac
    done
}
 
arg_stdin() {
    eval $(cat -)
    if [ "x$nodename" = "x" -a "x$port" != "x" ]; then
        nodename=$port         # pacemaker only use port
    fi
}
 
metadata() {
 
cat <<EOF
<?xml version="1.0" ?>
<resource-agent name="fence_ssh" shortdesc="ssh fence agent, work both for cman and pacemaker">
<longdesc>
The style come from fence_pcmk, http://www.clusterlabs.org
Some functions references external/ssh agent
</longdesc>
<vendor-url> http://klwang.info </vendor-url>
<parameters>
        <parameter name="action" unique="1">
                <getopt mixed="-o" />
                <content type="string" default="reboot" />
                <shortdesc lang="en">Fencing Action</shortdesc>
        </parameter>
        <parameter name="nodename" unique="1">
                <getopt mixed="-n" />
                <content type="string"  />
                <shortdesc lang="en">Name of machine</shortdesc>
        </parameter>
        <parameter name="port" unique="1">
                <getopt mixed="-p" />
                <content type="string"  />
                <shortdesc lang="en">Name of machine, equal to nodename</shortdesc>
        </parameter>
        <parameter name="help" unique="1">
                <getopt mixed="-h" />
                <content type="string"  />
                <shortdesc lang="en">Display help and exit</shortdesc>
        </parameter>
</parameters>
<actions>
        <action name="reboot" />
        <action name="on" />
        <action name="off" />
        <action name="list" />
        <action name="status" />
        <action name="metadata" />
</actions>
</resource-agent>
EOF
 
    exit 0
}
 
get_usable_ip() {
 
    for ip in `/usr/bin/getent hosts $1 | cut -d" " -f1`; do
        if ping -w1 -c1 $ip > /dev/null 2>&1
        then
            echo $ip
            return 0
        fi
    done
    return 1
 
}
 
is_host_up() {
 
    for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
        if
            ping -w1 -c1 "$1" >/dev/null 2>&1
        then
            sleep 1
        else
            return 1
        fi
    done
    return 0
 
}
 
reboot() {
 
    local node=$1
    ip=`get_usable_ip $node`
    if [ $? -ne 0 ];then
        /bin/echo "Error: can not get a usable ip, is nodename($node) alive!"
        exit 0                       # in case power lose
    fi
 
    if ! ping -c1 -w1 $ip >/dev/null 2>&1; then
        exit 0                       # in case the node have been fenced
    fi
 
    $SSH_COMMAND $ip "echo $(date +'%Y-%m-%d %H:%M') FENC_FROM_SSH \$SSH_CLIENT >> /var/log/fenc.log"
    $SSH_COMMAND $ip "$REBOOT_COMMAND"
 
    if `is_host_up $ip`; then
        exit 1
    else
        exit 0
    fi
 
}
 
#main
 
if [ $# -gt 0 ]; then
    arg_cmd $*
else
    arg_stdin
fi
 
 
case "$action" in
 
    metadata)
        metadata
        ;;
    usage)
        usage
        ;;
    on|off)
        exit 0        # ssh can not turn on a node
                      # so avoiding turn it down
        ;;
    reset|reboot)
        reboot $nodename
        ;;
    monitor)
        exit 0        # just for pacemaker
        ;;
    help)
        usage
        ;;
    *)
        /bin/echo "Unkonw options"
        exit 1
        ;;
esac

Configuration

pcs stonith create fencessh_node1 fence_ssh nodename=node1 pcmk_host_list=node1
pcs stonith create fencessh_node2 fence_ssh nodename=node2 pcmk_host_list=node2
pcs stonith level add 1 node1 fencessh_node1
pcs stonith level add 1 node2 fencessh_node2
 
# Interdire le fence de soi-même
pcs constraint location fencessh_node1 avoids node1
pcs constraint location fencessh_node2 avoids node2

Test

pcs stonith fence node2

Autres

Lister

pcs stonith list
stonith_admin -I
2025/03/24 15:06

Ripper un cd audio pour le mettre en mp3 ogg flac ou autres formats

Avec sound-juicer

sudo apt-get install sound-juicer
 
sound-juicer

avec l'outil Ripit

sudo apt-get install ripit
ripit

avec l'outil abcde

sudo apt-get install abcde mkcue flac eye3d lame
 
# Exemple
env CDPARANOIAOPTS="-Z" abcde -M -o flac 8

Brouillon

Trouver le lecteur audio (/dev/sr0) cdrdao scanbus

Dump exemple

cdrdao read-cd --device /dev/sr0 NOM_DU_CD_AUDIO.toc
cdrdao read-cd --source-device 0,0,0 --driver generic-mmc --paranoia-mode 3 audiocd.toc

Un fichier data.bin est généré La table de contenu NOM_DU_CD_AUDIO.toc

rip 1

cdrdao read-cd --read-raw --driver generic-mmc-raw --with-cddb --datafile file.bin file.toc
toc2cue file.toc file.cue
flac --best --force-raw --sample-rate=44100 --channels=2 --bps=16 --endian=big --sign=signed --cuesheet=file.cue file.bin -o file.flac

rip 2

abcde -1 -M -o flac

recontruct CD

flac --decode --force-raw --endian=big --sign=signed --output-name=file.bin file.flac
cdrdao write data.toc

Pb

cdparanoia III release 10.2 (September 11, 2008)

Ripping from sector  282026 (track  8 [0:00.00])
          to sector  289583 (track  8 [1:40.57])

outputting to /home/jibe/abcde.720f1508/track8.wav

 (== PROGRESS == [         >                    | 283193 00 ] == :-) 0 ==)   scsi_read error: sector=284153 length=27 retry=0
                 Sense key: 3 ASC: 2 ASCQ: 0
                 Transport error: Medium reading data from medium
                 System error: Input/output error
scsi_read error: sector=284153 length=13 retry=1
                 Sense key: 3 ASC: 2 ASCQ: 0
                 Transport error: Medium reading data from medium
                 System error: Input/output error
 (== PROGRESS == [    +   e >                   | 284349 00 ] == :-P . ==) 
dmesg
[ 3836.507021] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 3836.507028] sr 1:0:0:0: [sr0]  
[ 3836.507032] Sense Key : Illegal Request [current] 
[ 3836.507039] Info fld=0x46ac0
[ 3836.507043] sr 1:0:0:0: [sr0]  
[ 3836.507052] Add. Sense: Illegal mode for this track
[ 3836.507057] sr 1:0:0:0: [sr0] CDB: 
[ 3836.507060] Read(10): 28 00 00 04 6a c0 00 00 20 00
[ 3836.514926] sr 1:0:0:0: [sr0]  
[ 3836.514935] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[ 3836.514938] sr 1:0:0:0: [sr0]  
[ 3836.514940] Sense Key : Illegal Request [current] 
[ 3836.514943] Info fld=0x46b00
[ 3836.514944] sr 1:0:0:0: [sr0]  
[ 3836.514950] Add. Sense: Illegal mode for this track
[ 3836.514951] sr 1:0:0:0: [sr0] CDB: 
[ 3836.514953] Read(10): 28 00 00 04 6b 00 00 00 20 00
2025/03/24 15:06

Reverse SSH tunnel - SSH comme VPN

Voir :

Putty

#ssh -R 3128:192.168.56.1:3128 user@192.168.1.20
 
plink -R 3128:192.168.56.1:3128 -pw P@ssw0rd -batch user@192.168.1.20

FIXME

2025/03/24 15:06

Reverse proxy HTTP Headers - Disable compressed response - Nginx

Voir :

Disable the compressed response

proxy_set_header Accept-Encoding "";

Context: http, server, location

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