-
Notifications
You must be signed in to change notification settings - Fork 0
/
Collect.pl
52 lines (39 loc) · 1.34 KB
/
Collect.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/perl
$what = shift(@ARGV);
$community = shift(@ARGV);
$verP = shift(@ARGV);
$host = shift(@ARGV);
$baseoid = "1.3.6.1.4.1.9.9.42.1.2.10.1";
$timeout=5;
use threads;
use threads::shared;
use Thread::Exit;
my $done;
$child_thread=threads->new(\&Call_Doit);
$child_thread->detach();
CallTimer();
sub Call_Doit
{
$name=`snmpwalk -c$community -$verP $host -O qv 1.3.6.1.4.1.9.9.42.1.2.1.1.3 | grep -m 1 -w '$what'`;
$id=`snmpwalk -c$community -$verP $host -O nqa 1.3.6.1.4.1.9.9.42.1.2.1.1.3 | grep -m 1 -w '$what'`;
$name=~ s/"//g;
$id=~s/"//g;
$id=~s/.1.3.6.1.4.1.9.9.42.1.2.1.1.3.//g;
$id=~s/$name//g;
$tmp=`snmpwalk -c$community -$verP $host -O vq $baseoid.1.$id`;
$response="rttMonLatestRttOperCompletionTime=$tmp";
$tmpB=`snmpwalk -c$community -$verP $host -O vq $baseoid.2.$id `;
$response="$response rttMonLatestRttOperSense=$tmpB";
$tmpC=`snmpwalk -c$community -$verP $host -O vq $baseoid.3.$id`;
$response=" $response rttMonLatestRttOperApplSpecificSense=$tmpC";
$tmpD=`snmpwalk -c$community -$verP $host -O vqt $baseoid.5.$id`;
$response=" $response rttMonLatestRttOperTime=$tmpD";
$response=~ s/\n//g;
$response=~ s/ //g;
print "OK| $response\n";
exit();
}
sub CallTimer
{
sleep $timeout;
}