summaryrefslogtreecommitdiff
path: root/scripts/snmp/vyatta-snmp.pl
diff options
context:
space:
mode:
authorMohit Mehta <mohit.mehta@vyatta.com>2008-04-30 07:38:55 +0000
committerMohit Mehta <mohit.mehta@vyatta.com>2008-04-30 07:38:55 +0000
commite7d2b737df1f6194af2c652923647dd57280d2df (patch)
tree0b447ce88e8f674838d87312fa39070031d2798b /scripts/snmp/vyatta-snmp.pl
parent558da727945e243443045ffb791f427c837cff37 (diff)
downloadvyatta-cfg-quagga-e7d2b737df1f6194af2c652923647dd57280d2df.tar.gz
vyatta-cfg-quagga-e7d2b737df1f6194af2c652923647dd57280d2df.zip
Modifications to send link up/down traps to configured trap-target
Diffstat (limited to 'scripts/snmp/vyatta-snmp.pl')
-rw-r--r--scripts/snmp/vyatta-snmp.pl32
1 files changed, 28 insertions, 4 deletions
diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl
index b443eda4..ea77f7b7 100644
--- a/scripts/snmp/vyatta-snmp.pl
+++ b/scripts/snmp/vyatta-snmp.pl
@@ -34,7 +34,8 @@ use warnings;
my $mibdir = '/opt/vyatta/share/snmp/mibs';
my $snmp_init = '/opt/vyatta/sbin/snmpd.init';
my $snmp_conf = '/etc/snmp/snmpd.conf';
-
+my $snmp_snmpv3_user_conf = '/usr/share/snmp/snmpd.conf';
+my $snmp_snmpv3_createuser_conf = '/var/lib/snmp/snmpd.conf';
sub snmp_init {
#
@@ -61,7 +62,6 @@ sub snmp_get_constants {
my $date = `date`;
chomp $date;
$output = "#\n# autogenerated by vyatta-snmp.pl on $date\n#\n";
- $output .= "trap2sink localhost vyatta 51510\n";
$output .= "sysServices 14\n";
$output .= "smuxpeer .1.3.6.1.4.1.3317.1.2.2\n"; # ospfd
$output .= "smuxpeer .1.3.6.1.4.1.3317.1.2.5\n"; # bgpd
@@ -124,14 +124,38 @@ sub snmp_get_values {
$output .= "syslocation \"$location\" \n";
}
- my @trap_targets = $config->returnValues("trap-target");
+ my @trap_targets = $config->returnValues("trap-target");
+ if ($#trap_targets >= 0) {
+ # code for creating a snmpv3 user, setting access-level for it and use user to do internal snmpv3 requests
+ snmp_create_snmpv3_user();
+ snmp_write_snmpv3_user();
+ $output .= "iquerySecName vyatta\n";
+ # code to activate link up down traps
+ $output .= "linkUpDownNotifications yes\n";
+ }
foreach my $trap_target (@trap_targets) {
- $output .= "trapsink $trap_target\n";
+ $output .= "trap2sink $trap_target\n";
}
return $output;
}
+sub snmp_create_snmpv3_user {
+
+ my $createuser = "createUser vyatta MD5 \"vyatta\" DES";
+ open(my $fh, '>>', $snmp_snmpv3_createuser_conf) || die "Couldn't open $snmp_snmpv3_createuser_conf - $!";
+ print $fh $createuser;
+ close $fh;
+}
+
+sub snmp_write_snmpv3_user {
+
+ my $user = "rwuser vyatta";
+ open(my $fh, '>', $snmp_snmpv3_user_conf) || die "Couldn't open $snmp_snmpv3_user_conf - $!";
+ print $fh $user;
+ close $fh;
+}
+
sub snmp_write_file {
my ($config) = @_;