line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# system::freebsd:who Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::System::Freebsd::Who; |
7
|
1
|
|
|
1
|
|
751
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik::Shell::Command); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
372
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
commands => { |
19
|
|
|
|
|
|
|
get => [ ], |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
require_binaries => { |
22
|
|
|
|
|
|
|
who => [ ], |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get { |
28
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $cmd = 'who -H'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# FreeBSD 10.2-RELEASE |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# 0: NAME LINE TIME FROM |
36
|
|
|
|
|
|
|
# 1: pts/3 Oct 29 10:36 () |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
my $lines = $self->capture($cmd) or return; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $info = { |
41
|
|
|
|
|
|
|
raw => $lines, |
42
|
|
|
|
|
|
|
}; |
43
|
0
|
|
|
|
|
|
my $first = 1; |
44
|
0
|
|
|
|
|
|
for my $line (@$lines) { |
45
|
0
|
0
|
|
|
|
|
if ($first) { |
46
|
0
|
|
|
|
|
|
$first = 0; |
47
|
0
|
|
|
|
|
|
next; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$line =~ s{^\s*}{}; |
51
|
0
|
|
|
|
|
|
$line =~ s{\s*$}{}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my @t = $line =~ m{^(\S+)\s+(\S+)\s+(\d+ \S+ \S+)\s+\((\S+)\)$}; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $user = $t[0]; |
56
|
0
|
|
|
|
|
|
my $where = $t[1]; |
57
|
0
|
|
|
|
|
|
my $time = $t[2]; |
58
|
0
|
|
|
|
|
|
my $from = $t[3]; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$where =~ s{/}{_}g; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$info->{$where} = { |
63
|
|
|
|
|
|
|
user => $user, |
64
|
|
|
|
|
|
|
connection_time => $time, |
65
|
|
|
|
|
|
|
from => $from, |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $info; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |