0

I'm trying to send a snmp trap with these command line :

snmptrap -v 1 -c public host '1.2.3.4.5.6' '192.193.194.195' 6 99 '55' 1.11.12.13.14.15  s "teststring"

or

snmptrap -v 2c -c public host "" UCD-NOTIFICATION-TEST-MIB::demoNotif \
   SNMPv2-MIB::sysLocation.0 s "Just here"

But I get this error message :

getaddrinfo: host Name or service not known
getaddrinfo("host", NULL, ...): Name or service not known
snmptrap: 
zsh: exit 1     snmptrap -v 1 -c public host '1.2.3.4.5.6' '192.193.194.195' 6 99 '55'  s

What's wrong ? It seems I don't get something..

My final aim is just to send a trap on localhost on a specific port in a shell script..

EDIT : I have a new error :

read_config_store open failure on /var/lib/snmp/snmpapp.conf

How can I fix that ? I can't modify any files on the computer. I just can write some lines in a shell script to send a trap..

DouglasAdams
  • 490
  • 7
  • 19

1 Answers1

3

I think the host "host" does not exist on your network. Try putting in the IP address or existent host name of the trap destination, instead.

BTW, you don't need to put quotes around the OID strings.

There is more info about the syntax of the command on the man page, "man snmptrap"

Edit: Your second error looks like the result of a misconfiguration of the machine you're working on. Either the person who built (compiled) the program made a mistake, or the sysadmin has set unusual permissions on some files/directories.

Assuming it's some sort of Unix/Linux, I've searched the web for suggestions, and you could try setting the shell variable SNMP_PERSISTENT_DIR to a directory writable for the user (e.g. /tmp). Then try the command again. I.e. if using Bash:

  # SNMP_PERSISTENT_DIR=/tmp
  # export SNMP_PERSISTENT_DIR
  # snmptrap <etc>
Jolta
  • 2,620
  • 1
  • 29
  • 42
  • Thank you ! But now I have a new error : read_config_store open failure on /var/lib/snmp/snmpapp.conf I can't modify any file on the computer. I just can write some lines in a shell script to send a trap. – DouglasAdams Apr 03 '14 at 10:51