DWService
# check that name is a valid variable name:
# note: this code does not support variable_name[index]
shopt -s globasciiranges
[[ "$name" == [a-zA-Z_]*([a-zA-Z_0-9]) ]] || exit
value='babibab'
eval "$name"='$value' # carefully escape the right-hand side!
echo "$var_37" # outputs “babibab”
Detect virtualized platform
systemd-detect-virt
hostnamectl
lshw -class system
dmidecode -s system-product-name
Pour avoir la description d'une méthode version bytecode :
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.util.concurrent.ThreadPoolExecutor;
public class ByteCodeDescriptor {
public static void main(String... args) {
Class clazz = ThreadPoolExecutor.class;
String result= ByteCodeDescriptor.getDescriptorForClass(clazz);
System.out.println("class = " + result);
for (Method m : ThreadPoolExecutor.class.getMethods()) {
String resultM= ByteCodeDescriptor.getDescriptor(m);
System.out.println("method = " + m);
System.out.println("method result = " + m.getName() + resultM);
}
for (Constructor c : ThreadPoolExecutor.class.getConstructors()) {
String resultM= ByteCodeDescriptor.getDescriptor(c);
System.out.println("constructor = " + c);
System.out.println("constructor result = " + resultM);
}
}
static String getDescriptorForClass(final Class c)
{
if(c.isPrimitive())
{
if(c==byte.class)
return "B";
if(c==char.class)
return "C";
if(c==double.class)
return "D";
if(c==float.class)
return "F";
if(c==int.class)
return "I";
if(c==long.class)
return "J";
if(c==short.class)
return "S";
if(c==boolean.class)
return "Z";
if(c==void.class)
return "V";
throw new RuntimeException("Unrecognized primitive "+c);
}
if(c.isArray()) return c.getName().replace('.', '/');
return ('L'+c.getName()+';').replace('.', '/');
}
static String getDescriptor(Executable e) {
String s = "(";
for (final Class c : e.getParameterTypes())
s += getDescriptorForClass(c);
s += ')';
if (e instanceof Method) {
Method m = (Method) e;
return m.getName() + s + getDescriptorForClass(m.getReturnType());
} else if (e instanceof Constructor) {
Constructor c = (Constructor) e;
return "<init>" + s + getDescriptorForClass(void.class);
}
throw new RuntimeException("Unrecognized primitive "+e);
}
}
Reminder
python3 -m http.server 5051
File extensions can be (very) loosely seen as a type system.
.pem
stands for PEM, Privacy Enhanced Mail; it simply indicates a base64 encoding with header and footer lines. The contents of the PEM are detailed in the header and footer line - .pem itself doesn't specify a data
.key
can be any kind of key, but usually it is the private key - OpenSSL can wrap private keys for all algorithms (RSA, DSA, EC) in a generic and standard PKCS#8 structure, but it also supports a separate 'legacy' structure for each algorithm, and both are still widely used even though the documentation has marked PKCS#8 as superior for almost 20 years; both can be stored as DER (binary) or PEM encoded, and both PEM and PKCS#8 DER can protect the key with password-based encryption or be left unencrypted;
.csr or .req or sometimes .p10
stands for Certificate Signing Request as defined in PKCS#10; it contains information such as the public key and common name required by a Certificate Authority to create and sign a certificate for the requester, the encoding could be PEM or DER (which is a binary encoding of an ASN.1 specified structure);
.crt or .cer
stands simply for certificate, usually an X509v3 certificate, again the encoding could be PEM or DER; a certificate contains the public key, but it contains much more information (most importantly the signature by the Certificate Authority over the data and public key, of course).
.p12 or .pfx
is a PKCS#12 defined key store, commonly password protected. It can contain trusted certificates, private key(s) and their certificate chain(s), but also other information such as secret keys and (very uncommonly) other personal information; .p12 is usually binary / DER encoded. PKCS#12 has lots of options plus extensions (i.e. attribute OIDs) with varying support, so it is not safe to assume that every P12 file will work in anything that uses (some) P12 files.
.crl
is a Certificate Revocation List which is defined within the X.509v3 certificate specifications, and this is usually DER encoded as well.
Si on n'a pas d'outils de monitoring (ou pas accès) :
#!/bin/bash
echo "To kill : cat *.pid | xargs kill"
cp top.output.hexagon top.output.hexagon.old 2>&1 > /dev/null ; rm -f top.output.hexagon
cp vmstat.output.hexagon vmstat.output.hexagon.old 2>&1 > /dev/null ; rm -f vmstat.output.hexagon
(vmstat 30 & echo $! > vmstat.pid) | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush() }' 2>&1 > vmstat.output.hexagon &
echo $$ > monitor.pid
while :
do
top -b -n 1 | grep -v "0.0 0.0" 2>&1 | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush() }' 2>&1 >> top.output.hexagon
sleep 30
done
Specify a custom private key :
Add a specific configuration for your host in ssh config
Host myname.gitlab.com
Hostname gitlab.com
IdentityFile /home/myuser/.ssh/keys.d/id_rsa_git
IdentitiesOnly yes
Test SSH :
ssh -Tvvv git@myname.gitlab.com
Git command :
git clone git@myname.gitlab.com:yourrepo.git
depannageLeliondumatinDeRienmerci
La vraie taille des pays
Dumping des informations mémoires.
Une JVM configuré pour 7Go en prend 13G en mémoire.
Ajout du flag :
-XX:NativeMemoryTracking=summary
Attention impact un peu les performances.
Résultat, la différence était dans "Symbol" : Here is the NMT report about the symbol allocations, such as the string table and constant pool.
Et en effet cette JVM manipule beaucoup de chaines qu'elle garde en mémoire qui pourrait être interned
https://stackoverflow.com/questions/10578984/what-is-java-string-interning
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#intern()
Basically doing String.intern() on a series of strings will ensure that all strings having same contents share same memory. So if you have list of names where 'john' appears 1000 times, by interning you ensure only one 'john' is actually allocated memory.
Heap dump pour la suite.
All in one backup : to restore from a local server file.
Put the .wpress file in :
<wp_home>/wp-content/ai1wm-backups
Check cpu speed in realtime (to check boost speed)
watch -n.1 "grep \"^[c]pu MHz\" /proc/cpuinfo"
Microsoft à fond pour le support Linux :) :)
Thread per user
ps -u calrisk -o nlwp= | awk '{ num_threads += $1 } END { print num_threads }'
ps --no-headers auxwwwm | awk '$2 == "-" { print $1 }' | sort | uniq -c | sort -n
# 4th parameter number = number of thread
cat /proc/loadavg
# Also with
ps -eLf | wc -l
Raise limits in /etc/security/limits.conf
calrisk - nofile 8192
calrisk - nproc unlimited
And system parameters if needed :
echo 120000 > /proc/sys/kernel/threads-max
echo 600000 > /proc/sys/vm/max_map_count
echo 99999 > /proc/sys/kernel/pid_max
find the latest modified files recursively :
find . -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Do you want to accept these changes and continue updating from this repository? [y/N]
A simple fix for this is to either:
Run the following and manually answer y when asked to confirm the relevant changes
Note: this is NOT apt-get, but rather just standalone apt
sudo apt update
Run apt-get update with the --allow-releaseinfo-change flag to automatically confirm the changes for you:
sudo apt-get update --allow-releaseinfo-change
Dans un remote debugger :
this.getClass().getResource('/' + String.class.getName().replace('.', '/') + ".class")
Et j'ajouterai même que si le passage à PHP 8 est si compliqué c'est que les 78% du Web utilise des socles communs développés en partie en opensource par (au final) un petit nombre de développeurs.
Du coup, la maintenance de tout ça est compliqué.
Et puis, tant que ça marche.... pourquoi changer ? :) la sécurité ?
-XX:NativeMemoryTracking=summary
which produces an overview of the memory usage by the components of the JVM. It actually gives a pretty good picture of the "cost" of having a JVM.
Enabling detailed native memory tracking (NMT) causes a 5% to 10% performance overhead. The summary mode merely has an impact in memory usage as shown below and is usually enough.
It is necessary to note that while the above command indicate a scale in KB for the JVM it really means KiB.
JVM native memory tracking report
$ jcmd $(pidof java) VM.native_memory
Example of output :
Native Memory Tracking:
Total: reserved=7168324KB, committed=5380868KB
- Java Heap (reserved=4456448KB, committed=4456448KB)
(mmap: reserved=4456448KB, committed=4456448KB)
- Class (reserved=1195628KB, committed=165788KB)
(classes #28431)
( instance classes #26792, array classes #1639)
(malloc=5740KB #87822)
(mmap: reserved=1189888KB, committed=160048KB)
( Metadata: )
( reserved=141312KB, committed=139876KB)
( used=135945KB)
( free=3931KB)
( waste=0KB =0.00%)
( Class space:)
( reserved=1048576KB, committed=20172KB)
( used=17864KB)
....