Bonjour,

Je cherche à utiliser la sortie standard de snmptrapd plutôt que de logguer dans un fichier (mon but étant de lancer le démon comme un process et d'attraper ce qu'il sort). J'ai donc modifier le fichier snmptrapd en changeant la ligne des options en remplaçant le -Lf $log_file par -Lo comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
OPT="$prog_option -u $user -g $group -c $conf_file -Lo -p $pid_file"
Voici le début de fichier.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

## BEGIN INIT INFO
# Provides:             snmptrapd
# Required-Start:       $local_fs $network
# Required-Stop:
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Net-SNMP snmpd daemon
### END INIT INFO

# Fichier de démarrage /etc/init.d/snmpd du démon snmpd de Net-SNMP
# Fichier écrit par ram-0000 (http://ram-0000.developpez.com/)
#

name=snmptrapd
prog=/usr/local/sbin/$name
pid_file=/var/run/$name.pid
conf_file=/etc/snmp/$name.conf
log_file=/var/log/snmp/$name.log
user=snmp
group=snmp
prog_option="-A -Lsd"
start=yes

# check if must start, start only if $start = 'yes'
[ "$start" != "yes" ] && exit 0

[ -x $prog -a -f $conf_file ] || exit 0

. /lib/lsb/init-functions

# snmpd options
OPT="$prog_option -u $user -g $group -c $conf_file -Lo -p $pid_file"
#OPT="$prog_option -u $user -g $group -c $conf_file -Lf $log_file -p $pid_file"
Alors effectivement les traps ne sont plus loggués dans le fichier mais par contre il n'apparaissent pas dans le terminal.

J'ai loupé quelque chose?

voici un extrait de man snmpcmd:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
LOGGING OPTIONS
The mechanism and destination to use for logging of warning and error messages can be controlled by passing various parameters to the -L flag.

-Le
    Log messages to the standard error stream. 
-Lf FILE
    Log messages to the specified file. 
-Lo
    Log messages to the standard output stream. 
-Ls FACILITY
    Log messages via syslog, using the specified facility ('d' for LOG_DAEMON, 'u' for LOG_USER, or '0'-'7' for LOG_LOCAL0 through LOG_LOCAL7). 

There are also "upper case" versions of each of these options, which allow the corresponding logging mechanism to be restricted to certain priorities of message. Using standard error logging as an example:

-LE pri
    will log messages of priority 'pri' and above to standard error. 
-LE p1-p2
    will log messages with priority between 'p1' and 'p2' (inclusive) to standard error. 

For -LF and -LS the priority specification comes before the file or facility token. The priorities recognised are:

    0 or ! for LOG_EMERG,
    1 or a for LOG_ALERT,
    2 or c for LOG_CRIT,
    3 or e for LOG_ERR,
    4 or w for LOG_WARNING,
    5 or n for LOG_NOTICE,
    6 or i for LOG_INFO, and
    7 or d for LOG_DEBUG. 

Normal output is (or will be!) logged at a priority level of LOG_NOTICE

EDIT: Bon j'ai réussi à résoudre le problème, j'ai du mettre -f -Lo (et -Le facultatif) comme ceci (j'avais oublié -f pour rester dans le shell):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
OPT="$prog_option -u $user -g $group -c $conf_file -Lf $log_file -p $pid_file -f -Lo -Le"