Schrift
[thread]6996[/thread]

snmpwalk: output verwenden.... (Seite 2)



<< |< 1 2 >| >> 17 Einträge, 2 Seiten
renee
 2005-05-16 15:11
#54979 #54979
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Mit Chart::Plot:
Code: (dl )
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
#! /usr/bin/perl

use strict;
use warnings;
use Chart::Plot;

#! /usr/bin/perl

use strict;
use warnings;

my @infos;

while(my $line = <DATA>){
my ($port) = $line =~ /ifLastChange\.(\d+)/;
my ($time) = $line =~ /Timeticks:\s\((\d+)\)/;
push(@infos,$port,$time);
}

#--
# create a chart
#--
my @data = qw(20 25 60 25 40 10 100 35 50 55);

my $chart = Chart::Plot->new();
$chart->setData(\@data);

my $output = '/homes/reneeb/test.gif';
open(GIF,">$output") or die $!;
binmode GIF;
print GIF $chart->draw('gif');
close GIF;

# ohne leerzeichen:
_ _DATA_ _
IF-MIB::ifLastChange.1 = Timeticks: (219923100) 25 days, 10:53:51.00
IF-MIB::ifLastChange.2 = Timeticks: (291442830) 33 days, 17:33:48.30
IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.4 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.5 = Timeticks: (291443150) 33 days, 17:33:51.50
IF-MIB::ifLastChange.6 = Timeticks: (413522130) 47 days, 20:40:21.30
IF-MIB::ifLastChange.7 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.8 = Timeticks: (300617070) 34 days, 19:02:50.70
IF-MIB::ifLastChange.9 = Timeticks: (291443150) 33 days, 17:33:51.50
IF-MIB::ifLastChange.10 = Timeticks: (219981820) 25 days, 11:03:38.20
IF-MIB::ifLastChange.11 = Timeticks: (219999180) 25 days, 11:06:31.80
IF-MIB::ifLastChange.12 = Timeticks: (301946910) 34 days, 22:44:29.10
IF-MIB::ifLastChange.13 = Timeticks: (220033420) 25 days, 11:12:14.20
IF-MIB::ifLastChange.14 = Timeticks: (221288170) 25 days, 14:41:21.70
IF-MIB::ifLastChange.15 = Timeticks: (24179410) 2 days, 19:09:54.10
IF-MIB::ifLastChange.16 = Timeticks: (516433680) 59 days, 18:32:16.80
IF-MIB::ifLastChange.17 = Timeticks: (516419040) 59 days, 18:29:50.40
IF-MIB::ifLastChange.18 = Timeticks: (516431600) 59 days, 18:31:56.00
IF-MIB::ifLastChange.19 = Timeticks: (543368960) 62 days, 21:21:29.60
IF-MIB::ifLastChange.20 = Timeticks: (468715520) 54 days, 5:59:15.20
IF-MIB::ifLastChange.21 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.22 = Timeticks: (505795440) 58 days, 12:59:14.40
IF-MIB::ifLastChange.23 = Timeticks: (508682160) 58 days, 21:00:21.60
IF-MIB::ifLastChange.24 = Timeticks: (531186240) 61 days, 11:31:02.40
IF-MIB::ifLastChange.25 = Timeticks: (543026560) 62 days, 20:24:25.60
IF-MIB::ifLastChange.26 = Timeticks: (540585440) 62 days, 13:37:34.40
IF-MIB::ifLastChange.27 = Timeticks: (567193920) 65 days, 15:32:19.20
IF-MIB::ifLastChange.28 = Timeticks: (543360160) 62 days, 21:20:01.60
IF-MIB::ifLastChange.29 = Timeticks: (324904140) 37 days, 14:30:41.40
IF-MIB::ifLastChange.30 = Timeticks: (543354720) 62 days, 21:19:07.20
IF-MIB::ifLastChange.31 = Timeticks: (540741200) 62 days, 14:03:32.00
IF-MIB::ifLastChange.32 = Timeticks: (544203200) 62 days, 23:40:32.00
IF-MIB::ifLastChange.33 = Timeticks: (532586320) 61 days, 15:24:23.20
IF-MIB::ifLastChange.34 = Timeticks: (539739520) 62 days, 11:16:35.20
IF-MIB::ifLastChange.35 = Timeticks: (317402830) 36 days, 17:40:28.30
IF-MIB::ifLastChange.36 = Timeticks: (526321280) 60 days, 22:00:12.80
IF-MIB::ifLastChange.37 = Timeticks: (516494640) 59 days, 18:42:26.40
IF-MIB::ifLastChange.38 = Timeticks: (516494000) 59 days, 18:42:20.00
IF-MIB::ifLastChange.39 = Timeticks: (393778460) 45 days, 13:49:44.60
IF-MIB::ifLastChange.40 = Timeticks: (482336080) 55 days, 19:49:20.80
IF-MIB::ifLastChange.41 = Timeticks: (301946910) 34 days, 22:44:29.10
IF-MIB::ifLastChange.42 = Timeticks: (220132380) 25 days, 11:28:43.80
IF-MIB::ifLastChange.43 = Timeticks: (220194060) 25 days, 11:39:00.60
IF-MIB::ifLastChange.44 = Timeticks: (291442830) 33 days, 17:33:48.30
IF-MIB::ifLastChange.45 = Timeticks: (526602400) 60 days, 22:47:04.00
IF-MIB::ifLastChange.46 = Timeticks: (524041440) 60 days, 15:40:14.40
IF-MIB::ifLastChange.47 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.48 = Timeticks: (450) 0:00:04.50
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
cheggler
 2005-05-16 15:21
#54980 #54980
User since
2005-05-16
7 Artikel
BenutzerIn
[default_avatar]
okay, nun sollte ich aber nicht den output direkt im script haben, sondern den output in ein file tun und dieses file verwenden.
oder muss ich den output des snmpwalk immer von hand ins script packen?
coax
 2005-05-16 15:47
#54981 #54981
User since
2003-08-11
457 Artikel
BenutzerIn
[default_avatar]
[quote=cheggler,16.05.2005, 13:21]oder muss ich den output des snmpwalk immer von hand ins script packen?[/quote]
Im Post #4 verwendet renee den qx//-Operator, mit dem sich ein Befehl ausfuehren und dessen Ausgabe sammeln laesst.
Code: (dl )
1
2
3
my $cmd_output = qx{ command };
# ... ist das selbe wie
my $cmd_output = `command`;

Ueber den split-Befehl bekommst du dann noch jede Zeile als ein Element einer Liste.
Code: (dl )
my @lines = split /\n/, $cmd_output;
,,Das perlt aber heute wieder...'' -- Dittsche
Gast Gast
 2005-05-17 13:43
#54982 #54982
Hmmm, dann sollte dies so funktionieren?
Code: (dl )
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
#! /usr/bin/perl

use strict;
use warnings;

my @infos;

while(my $line = <DATA>){
my ($port) = $line =~ /ifLastChange\.(\d+)/;
my ($time) = $line =~ /Timeticks:\s\((\d+)\)/;
push(@infos,$port,$time);
}

#--
# create a chart
#--
my @data = qw(20 25 60 25 40 10 100 35 50 55);

my $result = qx{snmpwalk -v 1 -c public <host> ifLastChange};
my $chart = Chart::Plot->new();
$chart->setData(\@data);

my $output = '/sandia/vol0/home/cheggler/test.gif';
open(GIF,">$output") or die $!;
binmode GIF;
print GIF $chart->draw('gif');
close GIF;


Ich habe wirklich keine Ahnung von Perl....okay, bin nun am lesen des Oreilly Programming Perl....aber das ist ein relativ dicker Schunken... ;-)
renee
 2005-05-17 13:56
#54983 #54983
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
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
#! /usr/bin/perl

use strict;
use warnings;
use Chart::Plot;

my @infos;

my $result = qx{snmpwalk -v 1 -c public <ip-address> ifLastChange};
my @lines = split(/\n/,$result);

for my $line(@lines){
  my ($port) = $line =~ /ifLastChange\.(\d+)/;
  my ($time) = $line =~ /Timeticks:\s\((\d+)\)/;
  push(@infos,$port,$time);
}

#--
#  create a chart
#--

my $chart = Chart::Plot->new();
$chart->setData(\@infos);

my $output = '/sandia/vol0/home/cheggler/test.gif';
open(GIF,">$output") or die $!;
binmode GIF;
print GIF $chart->draw('gif');
close GIF;
\n\n

<!--EDIT|renee|1116323973-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
cheggler
 2005-05-17 17:31
#54984 #54984
User since
2005-05-16
7 Artikel
BenutzerIn
[default_avatar]
hmm, funz noch nicht....mir fehlen glaub ich die libraries der "Chart::Plot"... ;-((
wo kann ich mir diese holen?
renee
 2005-05-17 17:52
#54985 #54985
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
auf CPAN...

folge dem Link: CPAN:Chart::Plot und so installierst Du ein Modul: http://wiki.perl-community.de/bin....inModul
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
<< |< 1 2 >| >> 17 Einträge, 2 Seiten



View all threads created 2005-05-16 13:58.