From e7de034e4cd3fb3873eb695987857fe02afa8729 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 22 Dec 2009 20:48:24 -0800 Subject: Read Vyatta version from file Part of ehancement requested in Bug 3869 Include Vyatta version in system description. --- scripts/snmp/vyatta-snmp.pl | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'scripts/snmp/vyatta-snmp.pl') diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl index 6c80eaa0..fcbeeb3f 100644 --- a/scripts/snmp/vyatta-snmp.pl +++ b/scripts/snmp/vyatta-snmp.pl @@ -36,6 +36,7 @@ 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'; +my $versionfile = '/opt/vyatta/etc/version'; sub snmp_restart { system("$snmp_init restart > /dev/null 2>&1 &"); @@ -54,13 +55,30 @@ sub snmp_start { snmp_restart(); } +sub get_version { + my $version = "unknown-version"; + + if (open (my $f, '<', $versionfile)) { + while (<$f>) { + chomp; + if (m/^Version\s*:\s*(.*)$/) { + $version = $1; + last; + } + } + close $f; + } + return $version; +} + sub snmp_get_constants { my $output; - + my $version = get_version(); + my $date = `date`; chomp $date; $output = "#\n# autogenerated by vyatta-snmp.pl on $date\n#\n"; - $output .= "sysDescr Vyatta\n"; + $output .= "sysDescr Vyatta $version\n"; $output .= "sysObjectID 1.3.6.1.4.1.30803\n"; $output .= "sysServices 14\n"; $output .= "smuxpeer .1.3.6.1.4.1.3317.1.2.2\n"; # ospfd -- cgit v1.2.3