get all info

snmpwalk -Os -c public -v 1 $host .

set a special info

snmpset -c public -v 1 ipDefaultTTL.0 i 66

Exceute command via snmp (in snmpd.conf)

exec muh /some/command

Install a new MIB file

  • Copy the file (e.g. MY-MIB.txt) to /usr/share/snmp/mibs
snmpwalk -Of -v 1 -c public -m +MY-MIB .

Translate a MIB to its number

  • maybe you need to delete the last .0
snmptranslate -m ALL -On <mib>

Scripting with Perl


use strict;
use Net::SNMP;
use Time::HiRes qw(usleep nanosleep);

my $snmp_host = "";
my $snmp_version = 1;
my $snmp_community = "public";

my $oid = "";

my ($snmp, $error) = Net::SNMP->session(-hostname => $snmp_host,
                                      -version => $snmp_version,
                                      -community => $snmp_community);

die "SNMP connect to $snmp_host failed: $error\n" if $error;

while (1)
  my $results = $snmp->get_request(-varbindlist => [ $oid_a_total, $oid_w_total, $oid_kwh_total, $oid_pf_total ]);
  print join("", values(%$results)) . "\n";

  # Request every millisecond

  # Request every nanosecond