Outils pour utilisateurs

Outils du site


blog

Notes crontab

Voir aussi :

/etc/cron.d/plop
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
#
CRON_TZ=Europe/Paris

30 2 * * * root find /opt/plop/ -type f -name '*.old' -type f -mtime +20 -delete

Ici nous avons root en 6em position. Ce champs n'est présent uniquement pour les fichiers crontab dans /etc/cron.d

    (1) valeur comprise entre 0 et 59
    (2) valeur comprise entre 0 et 23
    (3) valeur comprise entre 1 et 31
    (4) valeur comprise entre 1 et 12
    (5) valeur comprise entre 0 et 7 (Dimanche étant le 0 ou le 7) ou alors les abréviations correspondant aux jours de la semaine en Anglais: sun,mon,tue,wed,thur,fri,sat
    (6) uniquement pour les fichiers crontab du système dans /etc/cron.d
    (7) commande à effectuer

Sur RedHat 7 / CentOS 7
il suffit d'ajouter le fichier dans /etc/cron.d/ rien à faire (pas de redémarrage)

at

2025/03/24 15:06

Notes CouchDB

Voir aussi :

Voir :

Code :

docker run -d --name my-couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password couchdb:3.2.1

WebUI Fauxton Futon

Ping

curl http://admin:password@127.0.0.1:5984

Pour Supervision

curl http://localhost:5984/_up

Show databases

curl http://admin:password@localhost:5984/_all_dbs

Create database

curl -X PUT http://127.0.0.1:5984/testdb

Show all docs

curl http://admin:password@localhost:5984/testdb/_all_docs
curl http://admin:password@localhost:5984/testdb/_all_docs?include_docs=true

Upload binary file

curl -X PUT http://127.0.0.1:5984/albums/6e1295ed6c29495e54cc05947f18c8af/ artwork.jpg?rev=2-2739352689 --data-binary @artwork.jpg -H "Content-Type: image/jpg"

Opérandes de comparaison

https://guide.couchdb.org/draft/tour.html

https://dev.to/yenyih/query-in-apache-couchdb-mango-query-lfd

{
    "selector": {
        "status": { "$eq": "draft" }
    },
    "fields": ["_id", "_rev", "title", "content", "date", "author"],
    "sort": [],
    "limit": 10,
    "skip": 0,
    "execution_stats": true
}

Bases

Insert - Post

curl -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test -d '{"type": "user", "username": "jean", "application": "app1"}'
 
curl -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test -d '{"type": "host", "hostname": "srv1", "application": "app1"}'

Select - Get

curl -d '{"keys":["73ab9c8c5dad9442ae91e6e1920088a5"]}' -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_all_docs?include_docs=true |jq .
 
curl -d '
{
   "selector": {
      "username": "jean"
   },
   "fields": [
      "application"
   ]
}
'  -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_find |jq .docs
 
curl -d '
{
   "selector": {
      "hostname": "srv1",
      "application": {
      "$in": ["app1","app2"]
      }
   },
   "fields": [
      "application"
   ]
}
'  -H 'Content-Type: application/json' -X POST http://admin:password@127.0.0.1:5984/test/_find |jq .docs
 
curl -X PUT http://admin:password@127.0.0.1:5984/db/_design/my_ddoc
     -d '{"views":{"my_filter":{"map":
         "function(doc) { if(doc.date && doc.title) { emit(doc.date, doc.title); }}"}}}'
function(doc){
    emit(doc.table.id, null);
}
 
 
{
  "views": {
    "all": {
      "map": "function(doc) { emit(doc.title, doc) }",
    }
  }
}

Programmation - db drivers

Obsolète ?

pip install -U celery-with-couchdb
pip install -U celery[couchdb]

https://couchdb-python.readthedocs.io/en/latest/getting-started.html https://readthedocs.org/projects/couchdb-python/downloads/pdf/latest/

https://pythonhosted.org/Flask-CouchDB/

pip install Flask-CouchDB
import couchdb
couch = couchdb.Server('localhost:5984/')
 
db = couch['newtweets']
count = 0
for docid in db.view('_all_docs'):
    i = docid['id']

Voir

  • cloudant
  • cloudant-python-sdk
pip install --upgrade "ibmcloudant>=0.0.42"

Outils tiers

CouchBackup

Source : https://blog.cloudant.com/2020/10/09/Automated-Daily-Backups.html

The couchbackup utility is a command-line tool that allows a Cloudant database to be turned a text file.

Turn our “animals” database into a text file

couchbackup --db animals > animals.txt

It comes with a matching utility which does the reverse: restores a text file back to a Cloudant database.

Restore our animals backup to a new database

cat animals.txt | couchrestore --db animals2

All we need to do is trigger couchbackup periodically to perform a backup.

2025/03/24 15:06

CORS - Cross-origin resource sharing

Err Cannot load M3U8: Crossdomain access denied

Cannot load M3U8: Crossdomain access denied
Solution sous Firefox

Faite [F12] / Network puis [F5] pour trouver “CORS Missing Allow Origin” dans la colone “Transferred”
Noter le ou les domaines concernés
Installer l'extention “Cross Domain - CORS”
Dans “Apply URL (regex)” saisir la (ou les) domaine
Cliquer sur “Save”
Le bouton “Cross Doamin” doit être Enable et vert. Cliquer sur “Save”

C'est mieux à présent j'ai un “403 Forbidden” mais c'est une autre histoire

2025/03/24 15:06

Notes CORBA

CORBA naming service

Paquets Debian

Voir aussi :

omniorb

  • /usr/bin/catior
  • /usr/bin/convertior
  • /usr/bin/genior
  • /usr/bin/nameclt
  • /usr/bin/omniMapper

omniorb-nameserver (omniORB naming service)

  • /usr/bin/omniNames

omniorb-idl (omniORB CORBA services idl files) \ omniorb-doc

Notes

Voir :

Naming_service -m 1 pour multicast
alors qu'en fait il fallait plutot faire un lancement
Naming_service -o ns.ior
et au lancement du serveur
serveur - -ORBInitRef NameService=file://ns.ior
Python
2025/03/24 15:06

Notes audit

Liens :

Note :

  • Penser à vérifier le NTP / l'heure des serveurs
  • Penser à vérifier le SMTP des fax, scanners, imprimantes

Quelques commande pour Audit système

Disques

lsblk

Réseaux

nft list ruleset
iptables -vnxL
ip6tables -vnxL
ip -s macsec show
ss -peaonmi
resolvectl status
resolvectl statistics
Fichier de conf

Debian DEB Voir audit_debian_differences_de_version_entre_un_fichier_d_origine_et_le_fichier_actuelle

dpkg -l
LANG=C find /etc -type f -exec dpkg -S {} 2>&1 \; |grep -e '^dpkg-query:' |tee jb_dpkg-S.txt
LANG=C debsums -as 2>&1 |tee jb_debsums.txt

Pour RedHat/CentOS RPM

rpm -Va

Exemple

rpm -V -a |egrep -v -e '^missing|/var/run|/var/log|\.jar$' |sed -e 's% c %   %' |awk '{print $2}' |grep -v -e '/$' |cpio -ov --format=ustar |pigz > /tmp/plop/fic-${HOSTNAME}.tar.gz
Matos
Drivers
for MODULE in $(lsmod |sed 1d |awk '{print $1}') ; 
do 
    modinfo $MODULE |grep -e '^filename:' |awk '{print $2}'| xargs dpkg -S || echo -e "\t ERR IN $MODULE";
done 2>&1 |tee  jb_modules.txt

Voir DKMS /var/lib/dkms/megaraid-sas

# LANG=C dpkg -S /var/lib/dkms/megaraid-sas
dpkg-query: no path found matching pattern /var/lib/dkms/megaraid-sas

# dpkg -S /usr/share/dkms/modules_to_force_install/megaraid-sas.force
megaraid-sas-dkms: /usr/share/dkms/modules_to_force_install/megaraid-sas.force
/usr/share/dkms/modules_to_force_install/megaraid-sas.force
megaraid-sas
sudoers
for user in $(awk -F':' '{print $1}' /etc/passwd) ; do sudo -U $user -l |sed -n -e '/^User /,/$$/p' |sed -e 1d |egrep -q -i '(root|all).*ALL' && echo "$user" ; done

Est-ce que cela fonctionne avec les groupes ? Les netgroups ? etc….

Ne liste pas les utilisateurs ayant des droits sur sh, bash, perl, python etc…

Config

Flux réseaux :

tcpdump tcp -p -qtn -i eth0 and not host 192.168.1.11 

Config Apache

apache2ctl -S 
cat /usr/local/apache/conf/httpd.conf   |sed -n -e '/\<VirtualHost/,/\<\/VirtualHost/p' |egrep -i -e "DocumentRoot|ServerName|ServerAlias|^$" |grep -v -e '^#' |tr -d '\n' | sed -e 's/DocumentRoot/\n/g' | sed -e 's/ServerName/|/g' | sed -e 's/ServerAlias/|ServerAlias/g' |sed -e 's/DocumentRoot/\nDocumentRoot/g' | grep -v -e "^$"  | sed -e 's/[[:space:]]//g' 

Comptes système

# uid0
cat /etc/passwd |awk -F':' '{print $3":"$1}' |grep -e '^0:'
 
# list active account
for compte in $(cat /etc/shadow |awk -F':' '{print $2":"$1}' |egrep -v -e "^\*|^\!" |awk -F ':' '{print $2}')
    do grep -e "^$compte:" /etc/passwd
done > /tmp/ftp1.txt
 
#cat ftp1.txt  |awk -F':'  '{print "| "$1" || || JJ/MM/AAAA || "$6" || "}' |perl -pe 's/\n/\n|-\n/' > ftp.txt 

Réseaux. Serveur

netstat -tapen |grep LISTEN |grep -v '127\.0\.0\.1' |awk '{print "| " $4 " || " $9}' 

Comptes système. Clefs SSH

for hom in $(cut -d':' -f 6 /etc/passwd) ; do ls $hom/$(grep AuthorizedKeysFile /etc/ssh/sshd_config |awk '{print $2}'  |sed -e 's#^%h/##' ) 2>/dev/null ;done 
perl -a -F':' -ne '$HOMEUSER=$F[5] ; $CHAINE="$HOMEUSER/.ssh/authorized_keys\n" ; $CHAINE=~s|//|/| ; print $CHAINE unless /false$/ or /nologin$/' /etc/passwd

Zones DNS

for zone in $(cat /etc/bind/named.conf |grep ^zone |egrep -v 'zone "." IN {|zone "localhost" IN {|zone "127.in-addr.arpa" IN {' |awk '{print $2}'| tr -d '"' |sort);  do dig -t AXFR @127.0.0.1 $zone > /tmp/dns_${HOSTNAME}_${zone}.txt ; done 

MySQL

mysql -u root -p < <(echo "select host, user from mysql.user;") > /tmp/mysql_user.txt 
mysql -u root -p < <(echo "show databases;") > /tmp/mysql_databases.txt 

Logs

à un jour et une heure précise

journalctl --since "2019-10-16 06:00" --until "2019-10-16 10:00" 
 
touch -t 1910160600 fic1
touch -t 1910161000 fic2
find / -newer fic1 -not -newer fic2
 
atop -r 20191016
 
sar -A -f /var/log/sa/sa18
 
last
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