Outils pour utilisateurs

Outils du site


blog

8 billet(s) pour mars 2026

Notes conteneurs oras artifact OCI2026/03/23 21:13Jean-Baptiste
Notes podman secret2026/03/23 15:10Jean-Baptiste
Notes ansible podman2026/03/23 14:08Jean-Baptiste
Notes podman volume2026/03/23 14:00Jean-Baptiste
Find list - Trouver des fichiers à partir d'une liste2026/03/18 14:32Jean-Baptiste
AWX inventaire vault2026/03/17 18:04Jean-Baptiste
AWX - Configuration git en local (sans serveur web)2026/03/05 16:24Jean-Baptiste
OpenSMTP2026/03/03 16:58Jean-Baptiste

Notes SNMPv3

Conf serveur

Méthode 1

/var/lib/net-snmp/snmpd.conf

# rouser nagios
createUser nagios SHA NagiosP@ssw0rd AES !P@ssw0rdNagios!
systemctl restart snmpd

Après redémarrage le mot de passe est chiffré dans /var/lib/net-snmp/snmpd.conf pour CentOS/RedHat ou dans /var/lib/snmp/snmpd.conf pour Debian.

Exemple :

usmUser 1 3 0x80001f87801c283d152f784a8700000000 "nagios" "nagios" NULL .1.3.6.1.6.3.10.1.1.2 0xbb07cb9c6ab1f0237b6981639b368642 .1.3.6.1.6.3.10.1.2.2 0xbb17cc9c6ab1f1347b6981639b368653 0x
Méthode 2

Install du paquet qui contient net-snmp-config

apt install libsnmp-dev

Création du premier utilisateur

systemctl stop snmpd
# echo -e "newuser\nmy_password\n\n" | (net-snmp-config --create-snmpv3-user)
net-snmp-config --create-snmpv3-user -a 'my_password' newuser
systemctl start snmpd

Test de connexion avec l'utilisateur nouvellement crée

snmpwalk -r 2 -v 3 -a MD5 -A 'my_password' -l authNoPriv -u newuser localhost .1

Création d'un nouvelle utilisateur “nagios”

snmpusm -v 3 -u newuser -a MD5 -A 'my_password' -l authNoPriv localhost create nagios newuser

Modifier le fichier /etc/snmp/snmpd.conf et ajouter : /etc/snmp/snmpd.conf

rouser nagios auth

Redémarrer snmpd

systemctl restart snmpd

Changement du mot de passe. Par défaut l'utilisateur crée hérite du mot de passe du créateur.

snmpusm -v 3 -u nagios -a MD5 -A 'my_password' -x DES -l authNoPriv localhost passwd 'my_password' 'P@ssw0rd'

A présent il convient de remetre l'utilsateur nagios en lecture seule

/etc/snmp/snmpd.conf

rouser nagios auth
systemctl restart snmpd

Test de connexion avec l'utilisateur Nagios et le nouveau mot de passe

snmpwalk -r 2 -v 3 -a MD5 -A "P@ssw0rd" -l authNoPriv -u nagios localhost .1
UsmUser

Conf client

apt-get install snmp
man snmp.conf
mkdir ~/.snmp/
mkdir ~/.snmp/hosts/

/.snmp/snmp.conf ou /.snmp/hosts/localhost.conf

defSecurityName nagios
#defSecurityLevel authPriv
defSecurityLevel authNoPriv
defAuthType MD5
#defPrivType DES
defAuthPassphrase P@ssw0rd
#defPrivPassphrase P@ssw0rd
chmod 600 ~/.snmp/snmp.conf
chmod 600 ~/.snmp/hosts/*.conf

Test

snmpwalk -r 2 -v 3 localhost .1

Pb

Err - no encryption type specified
no encryption type specified, which I need in order to know to change the key

Cela peut se produire si oublie de l'ajout rouser nagios dans /etc/snmp/snmp.conf

2025/03/24 15:06

Notes SNMP

Serveur

RedHat
yum install net-snmp
Debian
apt-get install snmpd snmptrapd snmp-mibs-downloader
ln -s /usr/share/mibs/ /usr/share/snmp/mibs

/etc/default/snmptrapd

#export MIBS=
export MIBS=ALL
export MIBDIRS=/usr/share/mibs
 
#TRAPDRUN=no
TRAPDRUN=yes
 
#TRAPDOPTS='-Lsd -p /run/snmptrapd.pid'
TRAPDOPTS='-On -Lsd -p /run/snmptrapd.pid'

/etc/snmp/snmp.conf

#mibs :
service snmpd restart
service snmptrapd restart
Conf

/etc/snmp/snmpd.conf

#rocommunity public  localhost
rocommunity public  0.0.0.0/0

#agentAddress  udp:127.0.0.1:161
#agentAddress udp:161,udp6:[::1]:161
agentAddress udp:161

#includeAllDisks 1
skipNFSInHostResources 1
Exemple conf
Exemple 1 - Conf Debian

/etc/snmp/snmpd.conf

agentAddress udp:161,udp6:[::1]:161
view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
rocommunity public
rouser   authOnlyUser
sysLocation    Sitting on the Dock of the Bay
sysContact     Me <me@example.org>
sysServices    72
proc  mountd
proc  ntalkd    4
proc  sendmail 10 1
disk       /     10000
disk       /var  5%
includeAllDisks  10%
load   12 10 5
trapsink     localhost public
iquerySecName   internalUser
rouser          internalUser
defaultMonitors          yes
linkUpDownNotifications  yes
extend    test1   /bin/echo  Hello, world!
extend-sh test2   echo Hello, world! ; echo Hi there ; exit 35
master          agentx
smuxpeer .1.3.6.1.4.1.674.10892.1
Exemple 2 - Conf RedHat

/etc/snmp/snmpd.conf

#com2sec notConfigUser  default       public
com2sec mynetwork 192.168.0.0/24      public
group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser
view centreon included .1.3.6.1
view    systemview    included   .1.3.6.1.2.1.1
view    systemview    included   .1.3.6.1.2.1.25.1.1
access notConfigGroup "" any noauth exact centreon none none
access  notConfigGroup ""      any       noauth    exact  systemview none none
syslocation Unknown (edit /etc/snmp/snmpd.conf)
syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
dontLogTCPWrappersConnects yes
cat >> /etc/snmp/snmpd.conf <<EOF
view    systemview    included   .1.3.6.1
EOF
Exemple 3 - Debian 8

Pour éviter bug timeout, car SNMP essaye de remonter les infos sur toutes les partitions qu'il trouve

systemctl disable mnt-espace_build.automount partage_install.automount partage_librairies.automount mnt-espace_build.mount partage_install.mount partage_librairies.mount
systemctl stop mnt-espace_build.automount partage_install.automount partage_librairies.automount mnt-espace_build.mount partage_install.mount partage_librairies.mount

Install du paquet snmp-mibs-downloader et de sa dépendance smistrip

dpkg -i smistrip_0.4.8+dfsg2-10_all.deb snmp-mibs-downloader_1.1_all.deb

/etc/default/snmpd

export MIBS=ALL
SNMPDRUN=yes
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid'
export MIBDIRS=/usr/share/mibs

/etc/snmp/snmpd.conf

agentAddress udp:161,udp6:[::1]:161
rocommunity public
Exemples droit d'accès

/etc/snmp/snmpd.conf

# rouser: a SNMPv3 read-write user
#   arguments:  user [noauth|auth|priv] [restriction_oid]

rouser nagios auth

Accès en lecture et écriture à la totalité de l'arborescence : /etc/snmp/snmpd.conf

rwuser admin authpriv .1
Pb - refused smux peer: oid SNMPv2-SMI::enterprises.674.10892.1, descr Systems Management SNMP MIB Plug-in Manager

Voir :

systemctl status snmpd
● snmpd.service - Simple Network Management Protocol (SNMP) Daemon.
   Loaded: loaded (/usr/lib/systemd/system/snmpd.service; enabled; vendor preset: disabled)
   Active: active (running) since mer. 2017-06-07 11:37:03 CEST; 9s ago
 Main PID: 61127 (snmpd)
   CGroup: /system.slice/snmpd.service
           └─61127 /usr/sbin/snmpd -LS0-6d -f
 
juin 07 11:37:03 8cc-offline-1 systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
juin 07 11:37:03 8cc-offline-1 snmpd[61127]: Turning on AgentX master support.
juin 07 11:37:03 8cc-offline-1 snmpd[61127]: NET-SNMP version 5.7.2
juin 07 11:37:03 8cc-offline-1 systemd[1]: Started Simple Network Management Protocol (SNMP) Daemon..
juin 07 11:37:06 8cc-offline-1 snmpd[61127]: refused smux peer: oid SNMPv2-SMI::enterprises.674.10892.1, descr Systems Management SNMP MIB Plug-in Manager
juin 07 11:37:09 8cc-offline-1 snmpd[61127]: refused smux peer: oid SNMPv2-SMI::enterprises.674.10892.1, descr Systems Management SNMP MIB Plug-in Manager
juin 07 11:37:12 8cc-offline-1 snmpd[61127]: refused smux peer: oid SNMPv2-SMI::enterprises.674.10892.1, descr Systems Management SNMP MIB Plug-in Manager
Solution

Solution 1

#echo "smuxpeer .1.3.6.1.4.1.674.10892.1 P@ssw0rd" >> /etc/snmp/snmpd.conf
echo "smuxpeer .1.3.6.1.4.1.674.10892.1" >> /etc/snmp/snmpd.conf
systemctl restart snmpd

Solution 2

/etc/sysconfig/snmpd

# snmpd command line options
# '-f' is implicitly added by snmpd systemd unit file
# OPTIONS="-LS0-6d"
OPTIONS="-I -smux"
systemctl restart snmpd
Pleins de message "Connection from UDP" dans les logs

/var/log/syslog

Jul 18 01:08:07 plop snmpd[3232]: Connection from UDP: [192.168.15.27]:52799->[192.168.15.32]
Jul 18 01:08:34 plop snmpd[3232]: Connection from UDP: [192.168.15.22]:53386->[192.168.15.32]
Solution

Remplacer -Lsd par -LSwd

/etc/default/snmpd

#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
SNMPDOPTS='-LSwd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'

Ou

/etc/sysconfig/snmpd

#OPTIONS="-LS0-6d -Lf /dev/null -p /var/run/snmpd.pid"
OPTIONS="-LSwd -Lf /dev/null -p /var/run/snmpd.pid"

ou

/etc/snmp/snmpd.conf

dontLogTCPWrappersConnects yes

puis restart du service

Autres

usmUser a été créer après le redémarrage de SNMPd suite à la commande createUser (SNMPv3)

Voir la commande snmpusm

snmptranslate
$ snmptranslate -M+. -m +ALL  -On  HOST-RESOURCES-MIB::hrProcessorTable
.1.3.6.1.2.1.25.3.3

$ snmptranslate -Td .1.3.6.1.4.1.2021.11.52
UCD-SNMP-MIB::ssCpuRawSystem
...
    This object may sometimes be implemented as the
    combination of the 'ssCpuRawWait(54)' and
    'ssCpuRawKernel(55)' counters, so care must be
    taken when summing the overall raw counters."
HP

Ajoutez la ligne suivante dans /etc/snmp/snmpd.conf :

/etc/snmp/snmpd.conf

dlmod cmaX /usr/lib64/libcmaX64.so

Redémarrez les services suivants :

systemctl restart hp-snmp-agents
systemctl restart snmpd

Client

snmpwalk

Voir aussi :

  • snmpgetnext

Exemples :

# snmpwalk -t "$timeout" -r "$retries"
# '-Cc' Use this option to ignore number not increasing error
 
snmpwalk -v2c -c public localhost system
#snmpwalk -v <laversion> -c <lacommunaute> <adresseip> <oid>
snmpwalk -v 2c -c public 192.168.1.13 1.3.6.1.2.1.2.2.1.10
 
snmpwalk -v 3 -u usersnmp -a SHA -A 'MonMot2Passe!!' -x AES -X '!!MaPhrase2PasseAE' -l authPriv localhost

ATTENTION : ne faites JAMAIS une requête snmpwalk sur la racine de l’arbre SNMP ou sur un noeud de haut niveau. Si vous faites cela, vous allez saturer l’agent SNMP interrogé, le réseau et votre poste. Dans le passé, vous pouviez saturer certains agents SNMP et il était nécessaire de les redémarrer voire de redémarrer l’équipement. Ce pourrait être très gênant si vous deviez demander à l’équipe réseau de redémarrer un routeur.

# snmpwalk -v2c -c public 192.168.1.13

Pour debug

snmpwalk -d -DAll
snmpget
#snmpget -v <laversion> -c <lacommunaute> <adresseip> <oid>
snmpget -v 2c -c public 192.168.1.13 1.3.6.1.2.1.2.2.1.10.1
 
OID_STORAGE_DESC=.1.3.6.1.2.1.25.2.3.1.3
OID_STORAGE_SIZE=.1.3.6.1.2.1.25.2.3.1.5
OID_STORAGE_USED=.1.3.6.1.2.1.25.2.3.1.6
 
snmpget -r 2 -v 3 -a MD5 -A "$PASSWD" -l authNoPriv -u nagios -Oqv localhost $OID_STORAGE_DESC.${indice}
snmpget -r 2 -v 3 -a MD5 -A "$PASSWD" -l authNoPriv -u nagios -Oqv localhost $OID_STORAGE_SIZE.${indice}
snmpget -r 2 -v 3 -a MD5 -A "$PASSWD" -l authNoPriv -u nagios -Oqv localhost $OID_STORAGE_USED.${indice}
Nagios check_snmp

Exemple de supervision de ports sur un switch

/usr/local/nagios/etc/objects/commands.cfg

define command{
        command_name    check_port_com
        command_line    $USER1$/check_snmp -H $HOSTADDRESS$ -P3 -L authNoPriv -a MD5 -U $USER3$ -A "$USER4$" -c 1,1 -o IF-MIB::ifOperStatus.$ARG1$
        }

switch.cfg

define service{
	use			generic-service	; Inherit values from a template
	host_name		linksys-srw224p
	service_description	Port 1 Link Status
	check_command		check_snmp!-C public -o ifOperStatus.1 -r 1 -m RFC1213-MIB
	}

/usr/local/nagios/etc/objects/switch.cfg

define service{
        use                     EtatPortCom
        hostgroup_name          RouteurSwitchs
        service_description     EtatPortCom1
        check_command           check_port_com!1
        #event_handler           trigger_etatport!1
    }
Lister les utilisateurs SNMPv3
snmpwalk .1.3.6.1.6.3.15.1.2.2.1.3
Ajout d'une MIB

Voir : https://github.com/simonjj/SnmpMibs

Logs Zabbix

MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (DISMAN-EVENT-MIB): At line 1 in (none)
apt-get install snmp-mibs-downloader

La MIB sera installée ici : /var/lib/snmp/mibs/ietf/DISMAN-EVENT-MIB

Commenter mibs :

/etc/snmp/snmp.conf

#mibs :
snmptranslate -Tp

Pour DISMAN-EVENT-MIB le pb est résolu

Mais il reste CPQRACK-MIB et CPQIDA-MIB

Cannot find module (CPQRACK-MIB): At line 1 in (none)
Cannot find module (CPQIDA-MIB): At line 1 in (none)
git clone https://github.com/simonjj/SnmpMibs
cd SnmpMibs
cp CPQ* /usr/share/snmp/mibs/
chmod a+r /usr/share/snmp/mibs/CPQ*
Notes
snmpget -t 1 -r 5 -M /usr/local/share/snmp/mibs -v 1 -c public 159.217.18.10:161 cpqRackCommonEnclosureTemp
tcpdump -i any -s 0 host hp-array-1.0 and port 161 -n
snmpcheck

Il existe l'ancienne version écrit en Perl et une plus récente écrit en Ruby

Il ne faut pas confondre la commande snmpcheck de Debian (paquet snmp) avec la snmpcheck de http://www.nothink.org/codes/snmpcheck

Debian

apt-get install ruby-snmp

RedHat

yum install ruby
gem install snmp
wget http://www.nothink.org/codes/snmpcheck/snmpcheck-1.9.rb
chmod +x snmpcheck-1.9.rb
./snmpcheck.rb
nmap -sS 192.168.56.21
snmpcheck -h 
snmpcheck -t 192.168.56.21
qtmib

GUI SNMP MIB Browser for Linux platforms Liens : https://sourceforge.net/projects/qtmib/

The program comes with a large number of MIBs pre-installed, anything from Cisco’s and Juniper’s to HP’s and Dell’s. You can also install your own MIBs by copying them into ~/.config/qtmib/mibs directory.

2025/03/24 15:06

C'est quoi cet OS

Version OS

$ cat /proc/version
Linux version 2.6.32-504.3.3.el6.x86_64 (mockbuild@x86-028.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-9) (GCC) ) #1 SMP Fri Dec 12 16:05:43 EST 2014
$ lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.6 (Santiago)
Release:        6.6
Codename:       Santiago
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.6 (Santiago)

$ cat /etc/os-release
$ cat /etc/debian_version 
8.0
$ cat /usr/lib/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="https://bugs.debian.org/"

Voir aussi /etc/system-release

2025/03/24 15:06

Adminer interface web pour DB mysql postgres sqlite

Voir aussi :

Voir les données en brute directement en base.

Exemple avec MySQL (comme phpMyAdmin)

Install

Docker
docker run -d --rm -p 8082:80 clue/adminer # --net=mynet19
Exemple install et conf MariaDB

Télécharger “Adminer for MySQL English only” sur https://www.adminer.org/

Nous créerons un compte en lecture seul, pouvant accéder à toutes les bases de données

mysql -u root -p
GRANT SELECT ON *.* TO 'allro'@'localhost' IDENTIFIED BY 'P@ssw0rd';
FLUSH PRIVILEGES;
mkdir /var/www/adminer/

Déposer adminer-4.2.3-mysql-en.php sur /var/www/adminer/

Puis faire un lien index.php

ln -s /var/www/adminer/adminer-4.2.3-mysql-en.php /var/www/adminer/index.php

Installation de nginx et de php-fpm

apt-get install nginx php-fpm php5-mysqlnd

Conf Nginx

/etc/nginx/sites-available/adminer

server {
        listen          8081;
 
        location / {
                root   /var/www/adminer;
                index  index.php index.html index.htm;
        }
 
 
        location ~ \.php$ {
                root           /var/www/adminer;
                fastcgi_index  index.php;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                #include fastcgi_params;
                include fastcgi.conf;
        }
}
ln -s /etc/nginx/sites-available/adminer /etc/nginx/sites-enabled/adminer
nginx -t
service nginx reload 

Connexion

Ici nous ferons un tunnel SSH pour nous connecter

ssh -L8081:localhost:8081 mysql-server

Allez sur http://localhost:8081 est renseigner le compte MySQL souhaité (allro dans notre exemple)

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