diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-12-22 20:48:24 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-12-22 20:58:33 -0800 |
commit | e7de034e4cd3fb3873eb695987857fe02afa8729 (patch) | |
tree | aa801366f6569c50be22c32dd6f9d85460408ff7 /scripts/snmp | |
parent | 6b23e6b41de705826ef6e0c9d90f65c021189181 (diff) | |
download | vyatta-cfg-quagga-e7de034e4cd3fb3873eb695987857fe02afa8729.tar.gz vyatta-cfg-quagga-e7de034e4cd3fb3873eb695987857fe02afa8729.zip |
Read Vyatta version from file
Part of ehancement requested in Bug 3869
Include Vyatta version in system description.
Diffstat (limited to 'scripts/snmp')
-rw-r--r-- | scripts/snmp/vyatta-snmp.pl | 22 |
1 files changed, 20 insertions, 2 deletions
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 |