#!/bin/bash
MYCMD="mysql -B -N -h 127.0.0.1 -u root -s -pxxxxxxxxxxxxxxxxxx -e "
for IP in `$MYCMD " use mt; select ip from router;"` ; do
VER=`snmpget -r2 -v1 -c public -Ovq $IP .1.3.6.1.4.1.14988.1.1.4.4.0 |cut -d" " -f1|sed -e "s/\"//g"`
NAME=`snmpget -r2 -v1 -c public -Ovq $IP SNMPv2-MIB::sysName.0 |cut -d: -f4`
RADIOS=`snmpwalk -v1 -c public -Ovq $IP .1.3.6.1.2.1.2.2.1.3 |grep ieee80211 |wc -l`
ETHERS=`snmpwalk -v1 -c public -Ovq $IP .1.3.6.1.2.1.2.2.1.3 |grep ethernetCsmacd |wc -l`
VLANS=`snmpwalk -v1 -c public -Ovq $IP .1.3.6.1.2.1.2.2.1.3 |grep l2vlan |wc -l`
LICENSE=`snmpwalk -v1 -c public -Ovq $IP .1.3.6.1.4.1.14988.1.1.4.3.0`
SSHACCESS=`$MYCMD "use mt; select sshaccess from router where ip='$IP';"`
SYSTEM=
if [ 1 == $SSHACCESS ]
then
V=`echo $VER |cut -b1`
if [ $V -ge 3 ]
then
SYSTEM=`ssh jp@10.0.0.7 "ssh admin@$IP system resource print" |grep board-name |cut -d: -f2`
fi
# if [ $V -lt 3 ]
# then
# SYSTEM=` ssh jp@10.0.0.7 "ssh admin@$IP system routerboard print; ssh admin@$IP system resource print" |egrep -i "
" |head -n 1 |cut -d: -f2`
# echo $NAME $SYSTEM
# fi
fi
SYSTEM=` ssh jp@10.0.0.7 "ssh admin@$IP system routerboard print; ssh admin@$IP system resource print" |egrep -i "m
|head -n 1 |cut -d: -f2`
UPTIME=` ssh jp@10.0.0.7 "ssh admin@$IP system resource print" |grep uptime |cut -d: -f2`
$MYCMD "use mt; update router set version='$VER' where IP='$IP'"
$MYCMD "use mt; update router set hostname='$NAME' where ip='$IP'"
$MYCMD "use mt; update router set radios='$RADIOS' where ip='$IP'"
$MYCMD "use mt; update router set ethers='$ETHERS' where ip='$IP'"
$MYCMD "use mt; update router set vlans='$VLANS' where ip='$IP'"
$MYCMD "use mt; update router set license='$LICENSE' where ip='$IP'"
$MYCMD "use mt; update router set system='$SYSTEM' where ip='$IP'"
$MYCMD "use mt; update router set uptime='$UPTIME' where ip='$IP'"
done
echo updated > /tmp/db.update.IP.done
I did, I rejected known OID's and ...do an SNMP-walk on your RouterOS device, and you will find the OID for the Version. Just saw it yesterday, but can't tell you the oid right now ..
SNMPv2-MIB::sysDescr.0 = STRING: router
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.14988.1
SNMPv2-MIB::sysServices.0 = INTEGER: 78
IP-MIB::ipForwarding.0 = INTEGER: forwarding(1)
IP-MIB::ipDefaultTTL.0 = INTEGER: 255
SNMPv2-SMI::mib-2.17.2.1.0 = INTEGER: 3
My snmpwalk was from RB433ahmaybe I don't understand this thing, but Dude SNMP-walk gives me:
iso.org.dod.internet.private.enterprises.mikrotik.mikrotikExperimentalModule.mtXRouterOs.mtxrLicense.mtxrLicVersion.0
1.3.6.1.4.1.14988.1.1.4.4.0 = 3.20
Edit: maybe it's related to the fact that mine is a routerboard? I will look into this
# snmpwalk -v 1 -c public 10.86.89.129 1.3.6.1.4.1.14988.1.1.4.4.0
SNMPv2-SMI::enterprises.14988.1.1.4.4.0 = STRING: "3.17"
SNMPv2-SMI::mib-2.9999.1.1.1.1.0 = STRING: "MikroTik DHCP server"
SNMPv2-SMI::mib-2.9999.1.1.1.2.0 = OID: SNMPv2-SMI::enterprises.14988.1
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.1.11 = IpAddress: 10.86.89.158
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.4.11 = INTEGER: 2
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.5.11 = Gauge32: 217399
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.7.11 = INTEGER: 3
SNMPv2-SMI::mib-2.9999.1.1.6.4.1.8.11 = Hex-STRING: 00 1F C6 2B E0 2B
There are many thinks to be fixed and a lot to be created, but this, I think has totally really low priority. I would appreciate to have a better SNMP GUI than a MIB Dictionary. Anyway... lets see what 3.20 has.Seems to me that Mikrotik may need to release a MIB (dictionary) file one of these days....