-
Notifications
You must be signed in to change notification settings - Fork 4
/
vnet.ph
executable file
·89 lines (69 loc) · 1.68 KB
/
vnet.ph
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# copyright, 2003-2009 Hewlett-Packard Development Company, LP
# NOTE - this module will build the global %virtMacs like this:
# $virtMacs{macaddr}=vnetname, where the macaddr is the rightmost 5 octets of the address
#
# RESTRICTIONS
# - if run with -sZ, this will collectl vnet info every interval2; otherwise interval1
use strict;
our ($subsys, $counted2, $limit2);
my $VNET;
our %virtMacs;
my $interval2Flag;
my $dirname="/sys/devices/virtual/net";
sub vnetInit
{
my $impOptsref=shift;
my $impKeyref= shift;
$interval2Flag=($subsys=~/Z/) ? 1 : 0;
opendir ($VNET, "$dirname") or logmsg('F', "Couldn't open '$dirname' for reading");
$$impOptsref='s'; # only one collectl cares about
$$impKeyref='vnet';
return(1);
}
# Nothing to add to header
sub vnetUpdateHeader
{ }
sub vnetGetData
{
# read network data every interval unless we're also doing process data, then only then
if (!$interval2Flag || $counted2==$limit2)
{
my $vnets='';
seekdir($VNET, 0);
while (my $vnet=readdir($VNET))
{
next if $vnet!~/^tap/;
my $filename="$dirname/$vnet/address";
open FILE, "<$filename" or die "DIE: $filename";
my $mac=<FILE>;
chomp $mac;
close FILE;
$vnets.="$vnet=$mac ";
}
$vnets=~s/ $//;
record(2, "vnets $vnets\n") if $vnets ne '';
}
}
sub vnetInitInterval
{ }
sub vnetAnalyze
{
my $type= shift;
my $dataref=shift;
foreach my $vnet (split(/\s+/, $$dataref))
{
my ($netname, $mac)=split(/=/, $vnet);
$mac=~s/^.{3}//;
$virtMacs{$mac}=$netname;
#print "virtMacs{$mac}=$netname\n";
}
}
sub vnetPrintBrief
{ }
sub vnetPrintVerbose
{ }
sub vnetPrintPlot
{ }
sub vnetPrintExport
{ }
1;