leostereo has asked for the wisdom of the Perl Monks concerning the following question:
The weird thing is when I list the output register: Take a look: Apr 12 20:56:54,186.183.101.72,77:10:00:02:06:85,77777851CFC7106,#!/usr/bin/perl -w use strict; use File::Tail; use Cwd qw(); my $path = Cwd::cwd(); my $community = 'public'; my $snmp_bsid = '.1.3.6.1.4.1.2700.1.1.11.0'; my $bsid; my $file = File::Tail->new( name =>'/var/log/messages', interval => 1, maxinterval => 1, resetafter=> 5, ); while (defined(my $line=$file->read)) { print $line,"\n"; if ($line =~ /^(.*) dns02cor dhcpd: DHCPACK on ([0-9\. +]+) to ([[:xdigit:]:]+).* ([0-9\.]+)/) { write_register($1,$2,$3); } } sub write_register { my ($date,$client_ip,$client_imsi) = @_; $output=qx(snmpget -v2c -t1 -c $community $client_ip $snmp_bsid 2> +&1); my @result=split(/:/,$output); if ($result[3]){ $bsid=$result[3]; $bsid=~s/ //g; $bsid=~s/\n//g; } system 'echo "'.$date.','.$client_ip.','.$client_imsi.','.$bsi +d.'," >>'.$path.'/register_list.txt'; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: snmpget is missing some values
by NetWallah (Canon) on Apr 13, 2016 at 04:53 UTC | |
by leostereo (Beadle) on Apr 13, 2016 at 13:52 UTC | |
by NetWallah (Canon) on Apr 13, 2016 at 21:36 UTC | |
by hippo (Archbishop) on Apr 13, 2016 at 22:43 UTC | |
by NetWallah (Canon) on Apr 14, 2016 at 01:03 UTC |