Contenu connexe
Similaire à Introduction to cloudforecast (20)
Plus de Masahiro Nagano (20)
Introduction to cloudforecast
- 13. (2)
•
•
•
• Cacti
• munin
• Ganglia
• CloudForecast
- 15. CPAN
• Plack + Starlet
• Gearman
• Parallel::Prefork
• DBI DBD::SQLite
• YAML::Syck
• Text::Xslate
• Data::Section::Simple
• local::lib
- 22. CloudForecast 2
fetcher
worker
RRD
update
Radar Web
worker
SQLite
- 23. CloudForecast 2
Gearman
Worker
fetcher
worker
RRD
update
Radar Web
worker
SQLite
- 24. CloudForecast 2
Gearman
Worker
RRD
update
Radar Web
worker
SQLite
- 26. 1
# ubuntu
$ sudo apt-get install librrds-perl libsnmp-perl
# CentOS rrdtool EPEL
$ sudo yum install net-snmp-perl
$ sudo yum install rrdtool-perl
- 27. 2
$ git clone git://github.com/kazeburo/cloudforecast.git
$ cd cloudforecast
$ cpanm -l extlib --installdeps .
$ ls
Changes cloudforecast_web
Makefile.PL docs
README host_config
cf_devstarter htdocs
cf_fetcher_worker lib
cf_updater_worker server_list_sample.yaml
cloudforecast_radar t
cloudforecast_sample.yaml
- 38. • Basic(CPU TCP )
• Traffic
• Disk Usage
• DiskIO Count
• Apache Status
• Nginx Status
• Squid
• Mysql
• Innodb
- 42. #
$ ./cloudforecast_radar -c cloudforecast.yaml
-l server_list.yaml
# Web
$ ./cloudforecast_web -p 5000 -c cloudforecast.yaml
-l server_list.yaml
- 52. % ./gearman-starter.pl --max-prcess 8 -s 127.0.0.1:7004
--scoreboard-dir /var/run/worker --port 7005 MyWorker
% telnet localhost 7005
Trying 127.0.0.1...
System: gearman_servers: 127.0.0.1:7004 class: MyWorker
BusyWorkers: 0
IdleWorkers: 8
--
pid Status Counter Comment
1630 . 0
1631 . 0
1632 . 0
1633 . 0
1634 . 0
1635 . 0
1636 . 0
1637 . 0
- 53. % ./gearman-starter.pl --max-prcess 8 -s 127.0.0.1:7004
--scoreboard-dir /var/run/worker --port 7005 MyWorker
% telnet localhost 7005
Trying 127.0.0.1...
System: gearman_servers: 127.0.0.1:7004 class: MyWorker
BusyWorkers: 0
IdleWorkers: 8
--
pid Status Counter Comment
1630 . 0
1631 . 0
1632 . 0
1633 . 0
1634 . 0
1635 . 0
1636 . 0
1637 . 0
- 56. rrds map { [$_,'GAUGE'] } qw/busy idle/;
# rrds ‘key’, ‘TYPE’ or rrds [‘key’,‘TYPE’], []..
- 57. • COUNTER
•
•
• ) Traffic ( octet )
• GAUGE
•
•
• )
- 59. (2)
graphs 'status' => 'worker status';
..
__DATA__
@@ status
DEF:my1=<%RRD%>:busy:AVERAGE
DEF:my2=<%RRD%>:idle:AVERAGE
AREA:my1#00C000:Busy
GPRINT:my1:LAST:Cur: %4.1lf
GPRINT:my1:AVERAGE:Ave: %4.1lf
GPRINT:my1:MAX:Max: %4.1lf
GPRINT:my1:MIN:Min: %4.1lfc
STACK:my2#0000C0:Idle
GPRINT:my2:LAST:Cur: %4.1lf
GPRINT:my2:AVERAGE:Ave: %4.1lf
GPRINT:my2:MAX:Max: %4.1lf
GPRINT:my2:MIN:Min: %4.1lfc
- 60. (2)
graphs 'status' => 'worker status';
..
key
__DATA__
@@ status
DEF:my1=<%RRD%>:busy:AVERAGE
DEF:my2=<%RRD%>:idle:AVERAGE
AREA:my1#00C000:Busy
GPRINT:my1:LAST:Cur: %4.1lf
GPRINT:my1:AVERAGE:Ave: %4.1lf
GPRINT:my1:MAX:Max: %4.1lf
GPRINT:my1:MIN:Min: %4.1lfc
STACK:my2#0000C0:Idle
GPRINT:my2:LAST:Cur: %4.1lf
GPRINT:my2:AVERAGE:Ave: %4.1lf
GPRINT:my2:MAX:Max: %4.1lf
GPRINT:my2:MIN:Min: %4.1lfc
- 61. fetcher {
my $c = shift;
my $host = $c->address;
my $port = $c->args->[0] || 9000;
my $sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
);
my $raw_stats;
$sock->sysread( $raw_stats, 8192 );
my ($busy, $idle);
foreach my $line ( split /[rn]+/, $raw_stats ) {
if ( $line =~ /^Busy.+: (d+)/ ) {
$busy = $1;
}
if ( $line =~ /^Idle.+: (d+)/ ) {
$idle = $1;
}
}
return [$busy,$idle];
};
- 62. fetcher {
my $c = shift;
my $host = $c->address;
my $port = $c->args->[0] || 9000;
my $sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
);
my $raw_stats;
$sock->sysread( $raw_stats, 8192 );
my ($busy, $idle);
foreach my $line ( split /[rn]+/, $raw_stats ) {
if ( $line =~ /^Busy.+: (d+)/ ) {
$busy = $1;
}
if ( $line =~ /^Idle.+: (d+)/ ) {
$idle = $1;
}
}
return [$busy,$idle];
};