I was trying to get ifOperStatus with snmpget, but I found here that he does it like this
snmpwalk -Os -c public -v 1 192.168.1.1 1.3.6.1.2.1.2.2.1.8
So I tried that but I get no result
But the SNMP agent is working.
Can anyone tell me how can I access ifOperStatus?
Assuming your snmpwalk is the NET-SNMP version, then
snmpwalk -Os -c public -v 1 192.168.1.1 .1.3.6.1.2.1.2.2.1.8
should work (notice the extra dot in front of the OID).
That makes it an absolute OID, rather than relative.
Related
I have to change from snmp v2c to snmp v3.
With snmp v2c, if I run the follow command line:
$ snmpwalk -c MyCom -v 2c 10.10.6.2 sysUpTime
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (44765283) 5 days, 4:20:52.83
I can get the systemUptime
But after config snmpv v3 in the same devide (Switch HP A5120)
$ snmpwalk -v3 -u UserSnmp -l AuthNoPriv -a MD5 -A 'SnmpPAss' 10.10.6.2 sysUpTime
SNMPv2-MIB::sysUpTime = No Such Object available on this agent at this OID
If i run snmpwalk -v3 -u UserSnmp -l AuthNoPriv -a MD5 -A 'SnmpPAss' 10.10.6.2 I receive a list of OID, the problem occurs only for item under sys table
I tried to find specific MIB for snmpv3 but I can't find anyone.
How can I solve this?
The problem was not related with MIB or snmpwalk command.
The config on switch was wrong, the snmp user was not allowed to see some specific OID's.
The result of curl -s http://127.0.0.1 is 200 OK
The result of /usr/bin/time -f "%e" curl -s http://127.0.0.1 is 200 OK0.08
In this case, I only need 0.08. How can I only get 0.08 instead of the whole string when I redirect the output to >> result.txt?
ps: the response can change in the future (not always 200 OK), and the format of time can also change in the future. So I really need a solution that is not based on string manipulation. Thanks.
Do this:
/usr/bin/time -f "%e" curl -s -o /dev/null http://127.0.0.1
By adding -o /dev/null you are telling curl to write its output nowhere, leaving you with only the output of time.
I'm not quite sure what the issue is. I'm on Kali Linux 2.0 right now, fresh install. The following worked on Ubuntu 14.04 but it's not working anymore (maybe I accidentally changed it?). It looks correct to me, but every time it runs it blocks.
backup_folder=$(ssh -i /home/dexter/.ssh/id_rsa $server 'ls -t '$dir' | head -1')
This is part of a larger script. $server and $dir are set. When I run the command alone, I get the correct output, but it doesn't end the connection.
I don't know if this may help to solve the question but your command doesn't handle dirs with space in the filename. Add double quotes inside the single quote section like this:
SERVER='remoteServer' && REMOTE_DIR='remoteDir' && backup_folder=$(ssh -i /home/dexter/.ssh/id_rsa "${SERVER}" 'ls -t "'${REMOTE_DIR}'" | head -n1'); echo "${backup_folder}"
If it doesn't help try to add increasing number of -v switch to ssh to debug eventually reaching:
SERVER='remoteServer' && REMOTE_DIR='remoteDir' && backup_folder=$(ssh -vvv -i /home/dexter/.ssh/id_rsa "${SERVER}" 'ls -t "'${REMOTE_DIR}'" | head -n1'); echo "${backup_folder}"
If the verbose output does not help may be an MTU problem (these kind of problems are not of binary type, acts strangely).
You can try lowering MTU (usually 1500) on your side to solve:
sudo ifconfig eth0 mtu 1048 up
eth0 is obviously an example interface, use your own.
i work with net-snmp and i try a few commands like:
snmptrap -v 1 -c public host TRAP-TEST-MIB::demotraps localhost 6 17 '' \
SNMPv2-MIB::sysLocation.0 s "Just here"
snmptrap -v 2c -c public localhost '' NOTIFICATION-TEST-MIB::demo-notif \
SNMPv2-MIB::sysLocation.0 s "just here"
snmptrap -v 1 -c public host NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification "" 6 17 "" \
netSnmpExampleHeartbeatRate i 123456
but is just give me a new line without error or something
someone can give me advice ?
Netsnmp provides Snmptrapd for this purpose.
It is an application which can listen on a port (default 162) on a host for traps and will log those that are received.
//EDIT ...
Here is an example ...
snmptrapd -f -m +ALL -Lo -c /tmp/snmptrapd.conf 9876
where /tmp/snmptrapd.conf only contains one line which for simplicity disables community/password checking
disableAuthorization yes
Use man snmptrapd to see what the flags/arguements mean.
I run the command below in my linux environment.
snmpwalk -t 10000000 -v2c -cpublic localhost:161 1 >abc.txt
The problem is i always get different number of variable bindings!! What is happening? Any solution?