Slide 1

Slide 1 text

͸ͯͳͷαʔό؅ཧπʔϧͷ࿩ Mackerel - Server Management with Tool YAPC::Asia Tokyo 2013

Slide 2

Slide 2 text

HatenaJEZ@VVLJ Twitter!Z@VVL CPAN:66,* ͸ͯͳࣾΞϧόΠτࢯ !γεςϜϓϥοτϑΥʔϜ෦

Slide 3

Slide 3 text

ࠓ೔ͷ༷ࢠͰ͢

Slide 4

Slide 4 text

͍͖͞Μ৬࣭͞Ε·ͨ͠ http://moznion.hatenadiary.com/entry/2013/08/14/010104 id:moznionࢯ

Slide 5

Slide 5 text

Perlྺ1೥͘Β͍

Slide 6

Slide 6 text

Perl CPAN WebService::Qiita RRDTool::Rawish Plack::Middleware::GitStatus Net::Signalet vim-plugin unite-perl-module.vim perl-local-lib-path.vim

Slide 7

Slide 7 text

Kyoto.pm

Slide 8

Slide 8 text

YAPCࢀՃ͸͡ΊͯͰ͢

Slide 9

Slide 9 text

ͻʔ y_uuki

Slide 10

Slide 10 text

40෼͠Ό΂Γ·͢

Slide 11

Slide 11 text

ͦͷ·͑ʹ

Slide 12

Slide 12 text

ӡ༻ܥͷํʁ

Slide 13

Slide 13 text

Muninͱ͔Zabbixܥͷπʔϧ Λ࢖ͬͯΒͬ͠ΌΔํʁ

Slide 14

Slide 14 text

RRDtoolΛ͝ଘ஌ͷํ?

Slide 15

Slide 15 text

ࠓ೔ͷ͓࿩ ͸ͯͳͷαʔό؅ཧπʔϧͷࢥ૝ ύϑΥʔϚϯεϝτϦΫε ՄࢹԽͷ࢓૊Έͷ࣮૷

Slide 16

Slide 16 text

αʔό؅ཧπʔϧ Munin Cacti Zabbix Ganglia collectd etc...

Slide 17

Slide 17 text

͍Ζ͍Ζ͋Δ

Slide 18

Slide 18 text

αʔό؅ཧपลπʔϧ ؂ࢹܥ ߏ੒؅ཧܥ σϓϩΠܥ Cinnamon

Slide 19

Slide 19 text

͍Ζ͍Ζ͋Δ

Slide 20

Slide 20 text

໰୊఺

Slide 21

Slide 21 text

ϗετ৘ใ͕෼ࢄͯ͠͠·͏ ໨తผʹπʔϧ͕ଘࡏ͢Δ Nagiosͷconfig Capistranoͷconfig.rb Muninͷconfig Chef Server

Slide 22

Slide 22 text

͡Ό͋ϑϧελοΫܥͷ πʔϧ࢖͑͹?

Slide 23

Slide 23 text

ϑϧελοΫπʔϧ Zabbix (ϗετ؅ཧ + ؂ࢹ) Crowbar (Ganglia + Chef + Nagios) ࢖͍͍ͨπʔϧͱ૊Έ߹Θͤʹ͍͘ ֤ػೳ͕ີ݁߹

Slide 24

Slide 24 text

ϗετ৘ใΛ෼ࢄͤͣ͞ҰݩԽ͍ͨ͠ ֤πʔϧͱૄ݁߹ʹ౷߹͍ͨ͠ ࣗ࡞͠Α͏ʂ

Slide 25

Slide 25 text

ϑϧεΫϥον http://anond.hatelabo.jp/20120313004820

Slide 26

Slide 26 text

Mackerel ʲՄࢉ໊ࢺʳɹαό ʲෆՄࢉ໊ࢺʳαό(ͷ਎) Plack / Starlet / Teng / Router::Simple / Class::Accessor::Lite::Lazy / TheSchwartz / Text::Xslate / Config::ENV / Scope::Container / SQL::Maker ... Perl 5.14 / Carton 1.0

Slide 27

Slide 27 text

·ͣ͸ࢥ૝͔Β

Slide 28

Slide 28 text

ϗετ৘ใͷҰݩ؅ཧ ͋ͬͪͬͪ͜ʹಉ͡Α͏ͳϗετ৘ใ͕͋Δͷ͸Α͘ͳ͍ ֤छπʔϧͱૄ݁߹ʹ౷߹ REST APIʹΑΔपลπʔϧͱͷ࿈ܞ

Slide 29

Slide 29 text

ϗετ৘ใͷҰݩ؅ཧ ϗετ؅ཧ ෺ཧϗετ or Ծ૝ϗετ or AWS ෺ཧϗετͱԾ૝ϗετͷରԠؔ܎ ͲͷαʔϏεͷͲ͏͍͏໾ׂ(DBαʔό,ϓϩΩγαʔόͳͲʣ ͲͷσʔληϯλͷͲͷϥοΫ ͲͷωοτϫʔΫʢαϒωοτʣ ঢ়ଶ (working,standby,maintenace,poweroff,destroyed)

Slide 30

Slide 30 text

ServiceҰཡ

Slide 31

Slide 31 text

ServiceҎԼͷRoleҰཡ RoleҰཡ Role ϗετ৘ใ

Slide 32

Slide 32 text

ৄࡉϗετ৘ใ load average CPU time iops memory usaage ... other graphs

Slide 33

Slide 33 text

पลπʔϧͱͷ࿈ܞ

Slide 34

Slide 34 text

Nagios࿈ܞ

Slide 35

Slide 35 text

ઃఆͷࣗಈੜ੒ MackerelͷAPI͔Βϗετ৘ใΛऔಘͯ͠ϗετఆٛ ϑΝΠϧΛࣗಈੜ੒ NagiosͷϗετstatusΛMackerelͷϏϡʔʹ΋දࣔ NagiosͷWeb UIʹͱ͹ͳ͍͍ͯ͘Α͏ʹ ৄ͘͠͸ίνϥ ϞχΧδ#3 http://www.slideshare.net/shoichimasuhara/3-ss-17097401 Nagios࿈ܞ

Slide 36

Slide 36 text

Chef࿈ܞ (Just Idea)

Slide 37

Slide 37 text

Chef Serverͱͷಉظ MackerelͷDBΛϚελͱ͢Δ Mackerelʹߋ৽ɾ࡟আ͕૸Ε͹Chef ServerͷAPIΛୟ ͍ͯPOST Chef Serverͷഇࢭ MackerelͷRole͝ͱʹϨγϐΛ༻ҙ Ϩγϐͷద༻ઌ͸MackerelͷAPI͔Β౎౓औಘ Knife SoloͰϨγϐద༻

Slide 38

Slide 38 text

Capistrano࿈ܞ

Slide 39

Slide 39 text

Capistrano࿈ܞ Capfileʹ௚ʹσϓϩΠઌϦετΛॻ͖ͨ͘ͳ͍ σϓϩΠ͢ΔͨͼʹMackerelͷAPIΛୟ͍ͯσϓϩΠઌ ϗετҰཡΛऔಘ http://mackerelhost/service/Hatena-Blog/roles/ backend?format=json backend = ΞϓϦέʔγϣϯαʔό ͸ͯͳϒϩάͷΞϓϦέʔγϣϯαʔόͷΑ͏ʹRoleͰࢦఆ

Slide 40

Slide 40 text

IRC࿈ܞ

Slide 41

Slide 41 text

IRC࿈ܞ ϗετ৘ใͷ࡞੒ɾߋ৽ɾ࡟আΛIkachanܦ༝Ͱ IRCʹ௨஌ ୭͕ͲͷΑ͏ͳૢ࡞Λ͔͕ͨ͠ϦΞϧλΠϜʹΘ͔Δ DBૢ࡞ʹରͯ͠௨஌ͷHookΛ࢓ࠐΉ (wtatsuru) update host 'intern2013': {"status"=>"maintenance"} εςʔλεΛ”ϝϯςφεத”ʹҠߦ

Slide 42

Slide 42 text

DNS࿈ܞ

Slide 43

Slide 43 text

RoleΛߏ੒͢Δϗετ reverse proxy LVS Role Role ৑௕Խɾෛՙ෼ࢄ͞Ε͍ͯΔ͜ͱʹண໨

Slide 44

Slide 44 text

৑௕Խɾෛՙ෼ࢄ Role Ծ૝IP(VIP) LVS Role DNS ϥ΢ϯυϩϏϯ DNS DNSϥ΢ϯυϩϏϯ༻FQDNʹର ͯ͠ෳ਺ͷIP͔Βϥ΢ϯυϩϏ ϯͰҰͭʹIPΛฦ͢ LVSϗετʹԾ૝IPΛׂΓ౰ͯ Ծ૝IP͑͞Θ͔͍ͬͯΕ͹ɹɹ ͋ͱ͸উखʹ෼ࢄ

Slide 45

Slide 45 text

ϥ΢ϯυϩϏϯ༻FQDNͱ VIP͸͋·Γม͑ͨ͘ͳ͍ Service໊ͱRole໊͸΄ͱΜͲมΘΒ ͳ͍͜ͱʹண໨

Slide 46

Slide 46 text

DNSϥ΢ϯυϩϏϯ DNSϥ΢ϯυϩϏϯ༻ͷFQDNΛService-Roleϕʔε ͷ໊લͰׂΓ౰ͯ nslookup hosts.db-slave.bookmark Name: hosts.db-slave.bookmark Address: 10.0.0.1 Name: hosts.db-slave.bookmark Address: 10.0.0.2 Name: hosts.db-slave.bookmark Address: 10.0.0.3 role.service

Slide 47

Slide 47 text

VIP LVSͷVIPʹରͯ͠FQDNΛService-Roleϕʔε ͷ໊લͰׂΓ౰ͯ nslookup db-slave.bookmark Name: db-slave.bookmark Address: 192.168.1.1 role.service

Slide 48

Slide 48 text

पลπʔϧͱͷ࿈ܞͷ࿩ऴΘΓ

Slide 49

Slide 49 text

αʔό؅ཧʹ޲͍ͨϏϡʔ

Slide 50

Slide 50 text

৘ใີ౓͕ߴ͘໢ཏతͳϏϡʔ ڝഅ৽ฉΈ͍ͨͳΠϝʔδ ۭ͖༰ྔͱ͔͕ͬ͟ͱΈΕΔ

Slide 51

Slide 51 text

ϗετ໊/IP ͳͲ loadavg άϥϑ Datacenter/ Rack Service/ Role Resource Memo

Slide 52

Slide 52 text

͍ͭ΋ΈΔάϥϑ΍ൺֱ͍ͨ͠άϥϑΛબΜͰ̍ϖʔδ ʹ·ͱΊΔ HTMLʹՃ͑ͯɺάϥϑه๏Λ࢖ͬͯΧελϚΠζ [:graph:service=SERVICE:role=ROLE] [:graph:service=SERVICE:role=ROLE] ΧελϚΠζͰ͖ΔμογϡϘʔυ

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Roleϗετͷάϥϑൺֱ ͸ͯͳϒϩάͷΞϓϦέʔγϣϯαʔόͷload averageൺֱ ҟৗͳϗετ͕͍ͳ͍͔Ͳ͏͔ݕग़

Slide 55

Slide 55 text

લ൒͓ΘΓ

Slide 56

Slide 56 text

αʔόϝτϦΫεՄࢹԽͷ ࢓૊Έ ϝτϦΫεMPBEBWFSBHFɼ$16UJNFɼNFNPSZVTBHF FUD

Slide 57

Slide 57 text

αʔόϝτϦΫεՄࢹԽͬͯʁ

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

MackerelͰͲ͏΍࣮ͬͯ૷ɹ ͯ͠Δ͔ͷ࿩

Slide 60

Slide 60 text

αʔόϝτϦΫεՄࢹԽʹඞਢͷཁૉ

Slide 61

Slide 61 text

αʔόϝτϦΫεՄࢹԽ Host Host Host Host Process Storage ֤ϗετ͔ΒͷϝτϦΫεͷऔಘ ετϨʔδʹ֨ೲ ετϨʔδ͔Β஋ΛऔΓग़͢ άϥϑԽ

Slide 62

Slide 62 text

ͲͷΑ͏ͳΞʔΩςΫνϟ͕Α͍͔

Slide 63

Slide 63 text

Push or Pull

Slide 64

Slide 64 text

Pushܕ Host Host Host Host Process Storage ֤ϗετ͔ΒͷϝτϦΫεͷऔಘ Host͔ΒProcess΁ ϝτϦΫεΛPush

Slide 65

Slide 65 text

Pushܕͷ໰୊఺ ֤ϗετʹcronͰճ͢ϝτϦΫεऔಘ&ૹ৴εΫ ϦϓτΛ഑෍͠ͳ͚Ε͹ͳΒͳ͍ εΫϦϓτͷܧଓతͳมߋ͕໘౗

Slide 66

Slide 66 text

Pullܕ Host Host Host Host Process Storage ֤ϗετ͔ΒͷϝτϦΫεͷऔಘ Process͔ΒHost΁ ϦΫΤετ͢Δ

Slide 67

Slide 67 text

PullܕͰ΋݁ہࣗલͷ ʢܧଓతͳมߋ͕ඞཁͳʣσʔϞϯΛ ཱͯͳ͚Ε͹ͳΒͳ͍ͷͰ͸ʁ

Slide 68

Slide 68 text

ϝτϦΫεऔಘͷͨΊͷ ωοτϫʔΫΠϯλϑΣʔεΛ΋ͭ طଘͷσʔϞϯΛ࢖͏

Slide 69

Slide 69 text

SNMP OS͕ఏڙ͢ΔجຊతͳϝτϦΫεΛऔಘ ͦͷଞϧʔλ΍SquidͳͲ Net::SNMPΛ࢖͏ my ($session, $error) = Net::SNMP->session( -hostname => $hostname, -community => $community, -version => 2, -timeout => 10, -translate => 0x0, ); $session // croak "SNMP error: $error"; my $response = $session->get_request( -varbindlist => $mibs, # MIBΛෳ਺ࢦఆ ) || croak "SNMP error: $session->error";

Slide 70

Slide 70 text

Nginx HttpStubStatusModule HTTPͰNginxݻ༗ͷϝτϦΫεΛͱΕΔ Active connections: 291 server accepts handled requests 16630948 16630948 31070465 Reading: 6 Writing: 179 Waiting: 106 $ curl http://nginxhost/nginx_status:8080

Slide 71

Slide 71 text

Plack Plack::Middleware::ServerStatus::Lite JSON format͕͋ΔͷͰָ % curl http://server:port/server-status?json {"Uptime":"1332476669","BusyWorkers":"2", "stats":[ {"protocol":null,"remote_addr":null,"pid":"78639", "status":".","method":null,"uri":null,"host":null,"ss":null}, {"protocol":"HTTP/ 1.1","remote_addr":"127.0.0.1","pid":"78640", "status":"A","method":"GET","uri":"/","host":"localhost: 10226","ss":0}, ... ],"IdleWorkers":"3"}

Slide 72

Slide 72 text

Memcached TelnetΠϯλϑΣʔε stats STAT pid 14868 STAT uptime 175931 STAT time 1220540125 STAT version 1.2.2 ... STAT curr_connections 92 STAT total_connections 1740 STAT connection_structures 165 STAT cmd_get 7411 STAT cmd_set 28445156 STAT get_hits 5183 STAT get_misses 2228 STAT evictions 0 STAT bytes_read 2112768087 STAT bytes_written 1000038245 STAT limit_maxbytes 52428800 STAT threads 1 END my $sock = IO::Socket::INET->new( PeerAddr => "$hostname:$port", Proto => 'tcp', Timeout => 10, ) or croak "Couldn't connect to $hostname:$port"; $sock->print("stats\r\n"); my $value_by_stat = {}; while (my $line = $sock->getline) { last if $line =~ /^END/; $line =~ s/\n$|\r\n$//; #chomp if ($line =~ /^STAT\s+(\S*)\s+(.*)/) { $value_by_stat->{$1} = $2; } }

Slide 73

Slide 73 text

Pullܕ (࠶ܝ) Host Host Host Host Process Storage ֤ϗετ͔ΒͷϝτϦΫεͷऔಘ ετϨʔδʹ֨ೲ ετϨʔδ͔Β஋ΛऔΓग़͢

Slide 74

Slide 74 text

Process

Slide 75

Slide 75 text

Process ϗετ͸ͨ͘͞Μ͋ΔͷͰฒྻ(ඇಉظ)Ͱɹɹɹ ϝτϦΫεऔಘ͍ͨ͠ ͔͠͠ɺϗετ਺෼ͷϓϩηεΛཱͯΔͷ͸ ͪΐͬͱ... PerlͰεϨου...

Slide 76

Slide 76 text

WorkerManager Job Queue(The Schwartz)ʹରԠͨ͠ϓϩηε؅ཧ σʔϞϯ Preforkܕ: ϓϩηε਺Λ੍ݶͰ͖Δ ͔ΘΓʹParallel::Prefork΍Starlet/Starman Λ࢖ͬͯ΋Α͍

Slide 77

Slide 77 text

Jobͷॲཧ಺༰

Slide 78

Slide 78 text

Agent ֤JobΛAgentͱݺΜͰ͍Δ ϦϞʔτϗετ͔ΒϝτϦΫεΛͱͬͯ͘Δϓϩηε ରԠϛυϧ΢ΣΞɼϓϩτίϧ Apache, Nginx, MySQL, Munin, Latency, Plack, Perlbal, Redis, SNMP, Solr, TheSchwartz ϓϥΨϒϧ Hatena::Mackerel::Worker::Agent::XXX SNMP΍HTTP, TelnetͰϝτϦΫεऔಘ

Slide 79

Slide 79 text

ϓϥάΠϯ͸PerlͰͳ͍ͱॻ͚ͳ͍ ݴޠඇґଘͰϓϥάΠϯΛॻ͖͍ͨ

Slide 80

Slide 80 text

ͦΕMunin͡ΌͶ MuninͷϓϥάΠϯ͸ ඪ४ೖग़ྗͰύϥϝʔλͷड͚౉͠Λ͢Δ

Slide 81

Slide 81 text

munin-nodeͱͷ࿈ܞ munin-nodeΛϦϞʔτϗετʹཱ͓ͯͯ͘ mackerel agent͕TelnetͰmunin pluginͷ݁Ռऔಘ munin-node munin plugin mackerel agent telnet ඪ४ೖग़ྗ

Slide 82

Slide 82 text

munin-nodeͱซ༻ ϛυϧ΢ΣΞ͕ϝτϦΫεऔಘͷͨΊͷωοτϫʔ ΫΠϯλϑΣʔε͕͋ΔͳΒ͹ mackerel agent͔ΒωοτϫʔΫɾΠϯλ ϑΣʔεΛ࢖͏ netstat΍smartctlͳͲϦϞʔτϗετͷίϚϯ υΛୟ͖͍ͨͳΒ͹ munin-nodeΛ࢖͏

Slide 83

Slide 83 text

ϝτϦΫεͷߋ৽ (ετϨʔδͷ࿩)

Slide 84

Slide 84 text

Pullܕ (࠶ܝ) Host Host Host Host Worker Manager Storage

Slide 85

Slide 85 text

Storage RDBMS, KVS, other NOSQL...

Slide 86

Slide 86 text

RRDtool

Slide 87

Slide 87 text

RRD (Round Robin Database) ࣌ܥྻσʔλΛ֨ೲ͢ΔͨΊͷσʔλϑΥʔϚοτ อଘظؒΛݻఆͯ͠ݹ͍஋͸ࣺ͍ͯͯ͘ RRDtool RRDͷ࣮૷ʢσϑΝΫτελϯμʔυʣ RRDͷ࡞੒ɾߋ৽ɾࢀরػೳͱάϥϑԽػೳΛ΋ͭ I/O͕΍ͨΒ଎͍(Β͍͠) େ఍ͷαʔό؅ཧπʔϧͰ࢖ΘΕ͍ͯΔ ͳ͔ͥάϥϑը૾ੜ੒ػೳ͕͋Δ

Slide 88

Slide 88 text

RRDtoolϝϦοτɾσϝϦοτ ϝϦοτ ࣌ܥྻσʔλΛ͍͍͔Μ͡ʹॻ͖ࠐΜͰ͘ΕΔ ߋ৽ִ͔ؒΒ࣮ࡍͷॻ͖ࠐΈ࣌ࠁ͕গʑͣΕͯ΋मਖ਼ͯ͘͠ ΕΔ (10:01 -> 10:00) ஋ͷਫ਼౓ͷௐઅ͕Մೳ ϥ΢ϯυϩϏϯͳͷͰϑΝΠϧαΠζ͕Ұఆ I/O͕ߴ଎ σϝϦοτ rrdtoolʹ༩͑Δύϥϝʔλͷઃఆ͕൥ࡶ

Slide 89

Slide 89 text

ొ৔ਓ෺͕ͰͦΖͬͨͷͰ γεςϜશମΛ੔ཧ

Slide 90

Slide 90 text

Job Queue DB RRDtool Host Host Host Host enqueue.pl cron δϣϒ౤ೖ ϗετ৘ใऔಘ ϝτϦΫεऔಘ

Slide 91

Slide 91 text

RRDtool App Server Browser HTTP graph request rrdtool graph άϥϑϦΫΤετ

Slide 92

Slide 92 text

RRDtool App Server Browser HTTP graph response graph image άϥϑϨεϙϯε

Slide 93

Slide 93 text

Job Queue DB RRD Host Host Host Host enqueue.pl cron RRDtool App Server Browser γεςϜશମ

Slide 94

Slide 94 text

Web͔Βάϥϑੜ੒ͤ͞Δ ࢓૊Έ

Slide 95

Slide 95 text

RRD App Server Browser HTTP graph request rrdtool graph άϥϑϦΫΤετ ʢ࠶ܝʣ

Slide 96

Slide 96 text

RRD App Server Browser HTTP graph request rrdtool graph άϥϑϦΫΤετ ʢ࠶ܝʣ άϥϑੜ੒URLΛͲ͏දݱ ͢Δ͔

Slide 97

Slide 97 text

ཁ͸rrdtool graphίϚϯυͷҾ਺ ΛURLͰͲ͏දݱ͢Δ͔

Slide 98

Slide 98 text

rrdtool graph $ rrdtool graph --end now --start end-120000s --width 400 \\ DEF:ds0a=/home/rrdtool/data/router1.rrd:ds0:AVERAGE \\ DEF:ds0b=/home/rrdtool/data/router1.rrd:ds0:AVERAGE:step=1800 \\ DEF:ds0c=/home/rrdtool/data/router1.rrd:ds0:AVERAGE:step=7200 \\ LINE1:ds0a#0000FF:"default resolution\l" \\ LINE1:ds0b#00CCFF:"resolution 1800 seconds per interval\l" \\ LINE1:ds0c#FF00FF:"resolution 7200 seconds per interval\l" άϥϑඳըظؒͷࢦఆ άϥϑ෯ࢦఆ σʔλϦιʔεʢRRDϑΝΠϧ໊ʣࢦఆ άϥϑઢͷଠ͞΍৭ɺຌྫΛࢦఆ ...

Slide 99

Slide 99 text

γϯϓϧURL ͱ RRDtool URL ͷ2छྨ༻ҙ

Slide 100

Slide 100 text

γϯϓϧURL /graph? define=tesuhost01::_default::loadavg5::STACK,testhost0 2::mysql::second_behind_master define=::::, define=::::, ... σϑΥϧτ஋ΛܾΊͯɺͳΔ΂͘γϯϓϧʹ ઢͷଠ͞ͱ͔͸σϑΥϧτ஋Λ಺෦ͰܾΊ͓ͯ͘

Slide 101

Slide 101 text

RRDtool URL RRDtoolίϚϯυΛͦͷ··URDͰදݱ hit rateͷܭࢉͱ͔Λͤ͞Δͱ͖ʹ࢖͏ /graph/general?s=[ (def:cmd_get:::=path:memcachedhost,memcached,cmd_get:value:AVERAGE), (def:get_hits:::=path:memcachedhost,memcached,get_hits:value:AVERAGE), (cdef:hit_rate:::=get_hits,cmd_get,/), (line1:hit_rate:::@0000ff:memcachedhost-memcached-hit_rate) !end=now-0d,height=100,start=now-30d,width=400 ] memcachedͷhit rateάϥϑURL

Slide 102

Slide 102 text

my $fmt = <<'EOS'; graphformula = "[graph:" ( graphs [ ":" option ] ) "]" graphs = graph | "(" graph ")" 0*( ",(" graph ")" ) graph = "path:" elements | instruction ":" [ name ] ":::" option ) elements = object : [ tag : [ label ] ] object = name tag = name label = name instruction = "def" | "cdef" | "vdef" | "line" digit | "area" | "hrule" | "vrule" | "print" | "gprint" | "commend" | "tick" | "shift" | "textalign" option = 1*( char | "," | "=" | "#" | "@" | ":" | " " | "\" | op) name = 1*char char = alphanum | mark op = "+" | "/" | "%" | "*" mark = "-" | "_" | "." | "!" | "~" | "*" | "'" alphanum = alpha | digit alpha = lowalpha | upalpha lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" EOS BNFͰਅ໘໨ʹ࢓༷Λఆٛ

Slide 103

Slide 103 text

ύϑΥʔϚϯεվળ

Slide 104

Slide 104 text

RRDͷσΟεΫI/Oෛՙ (ϗετ਺) x (ϝτϦΫεछผ਺) io per 5෼ ϗετ਺ = ਺ઍ ϝτϦΫεछผ਺ = 20Ҏ্ 10k io per 5෼ ࣮ࡍ͸5෼ͷ͏ͪͷ͋Δ࣌ؒʹI/O͕ूத

Slide 105

Slide 105 text

2छྨͷෛՙ࡟ݮํ๏

Slide 106

Slide 106 text

rrdcached rrdtoolͷߋ৽΍ू໿ॲཧΛड͚෇͚ΔσʔϞϯ rrdͷߋ৽͸ಉ࣌͡ࠁʹࡴ౸͕ͪ͠ ॻ͖ࠐΈΛϥϯμϜͳ࣌ؒ෼஗Ԇͯ͘͠ΕΔ rrdcachedͳͩ͠ͱ, ฏۉ 700 iops όʔετ஋ 1200 iops SSDͩͱͳΜͱ͔ͳΔ HDD(AWS)ͩͱݫ͍͠ ϦϦʔε൛(1.4.8)͸updateʹ͔͠ରԠ͍ͯ͠ͳ͍ ͕trunkͳΒ͹ͦͷଞͷ֤छαϒίϚϯυʹରԠ

Slide 107

Slide 107 text

෼ࢄRRD RRDͷσΟεΫI/OΛϦϞʔτϗετ୯ҐͰ෼ࢄ ͋Δϗετ͕ͲͷRRDϗετʹׂΓ౰ͯΒΕ͍ͯΔ ͔ͷ৘ใΛDBʹ͓࣋ͬͯ͘ Job Queue DB RRD enqueue.pl Job Queue RRD Job Queue RRD

Slide 108

Slide 108 text

Future Work

Slide 109

Slide 109 text

mackereld

Slide 110

Slide 110 text

mackereld ϝτϦΫεऔಘͷͨΊͷσʔϞϯ munin-node૬౰ͷػೳ REST APIͰϝτϦΫεऔಘ ϦϞʔτϗετͷϩάΛWebͰϦΞϧλΠϜɹɹ ʹΈΕΔ ֤छϩάϑΝΠϧΛ؂ࢹ͠ɺมߋΛݕ஌ͨ͠Β Server-Sent EventsͰͱ͹͢ ܧଓతͳมߋ͕΍͸ΓΊΜͲ͏

Slide 111

Slide 111 text

RRDtoolʹΑΔ༧ଌάϥϑ

Slide 112

Slide 112 text

RRDtoolʹΑΔ༧ଌάϥϑ σΟεΫ͕ຬഋʹͳΔͷ͸͍ͭʁ 2014೥4݄

Slide 113

Slide 113 text

$ rrdtool graph ./dskUsed.png \ --start="now-1y" \ --end="now+2y" \ --imgformat=PNG \ --title="Disk Usage" \ --height=200 \ --width=500 \ --lower-limit=0 \ DEF:usage=testhost__dskUsed.rrd:value:MAX \ DEF:total=testhost__dskTotal.rrd:value:MAX \ CDEF:c_warn=total,0.85,* \ CDEF:c_crit=total,0.95,* \ VDEF:v_total=total,MINIMUM \ VDEF:v_warn=c_warn,MINIMUM \ VDEF:v_crit=c_crit,MINIMUM \ VDEF:v_usage_slope=usage,LSLSLOPE \ VDEF:v_usage_intercept=usage,LSLINT \ CDEF:c_usage_predict=usage,POP,v_usage_slope,COUNT,*,v_usage_intercept,+ \ CDEF:c_rwarn=c_usage_predict,v_warn,v_total,LIMIT \ VDEF:v_rwarn=c_rwarn,FIRST \ CDEF:c_rcrit=c_usage_predict,v_crit,v_total,LIMIT \ VDEF:v_rcrit=c_rcrit,FIRST \ HRULE:v_warn#FF8800:"warning":dashes=5 \ VRULE:v_rwarn#FF8800::dashes=5 \ HRULE:v_crit#FF4400:"critical" \ VRULE:v_rcrit#FF4400 \ HRULE:v_total#FF0000:"total" \ AREA:usage#00FF00:"Disk Usage" \ LINE1:c_usage_predict#0000FF:"Predict" \ GPRINT:v_rwarn:"Reach warning (85%)\: %c":strftime \ GPRINT:v_rcrit:"Reach critical (95%)\: %c":strftime shoichimasuhara++

Slide 114

Slide 114 text

Rich Visualization

Slide 115

Slide 115 text

Rich Visualization ত࿨ͬΆ͍(ը૾) ฏ੒ੜ·Ε͸ͬͪ͜(SVG) RRDtool D3.js

Slide 116

Slide 116 text

D3.js NVD3.js (Re-usable charts for d3.js) Rickshaw (time-series graph) rrdtool xport --json ͰJSONܗࣜͰ஋Λऔಘɹɹ Ͱ͖ΔͨΊɺετϨʔδ͸RRDͷ·· D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS.

Slide 117

Slide 117 text

RRDtool͔Βͷ୤٫

Slide 118

Slide 118 text

୅ΘΓʹRedis΍MongoDBͳͲͷετϨʔδΛ࢖͏ FnordMetrics (http://fnordmetric.io/) GrowthForecastʹࣅͯΔ ετϨʔδɿRedis άϥϑɿRickshaw my $furl = Furl->new(timeout => 10); my $res = $furl->post( "http://fnordmetricshost:4242/events", ['Content-Type' => 'application/json'], encode_json({ "_type" => '_incr', "value" => scalar @$statuses, "gauge" => "tweets_per_minute" }), );

Slide 119

Slide 119 text

αʔόϝτϦΫεՄࢹԽͷ࿩ ͓ΘΓ

Slide 120

Slide 120 text

·ͱΊ

Slide 121

Slide 121 text

ϗετ৘ใͷҰݩ؅ཧ ͋ͬͪͬͪ͜ʹಉ͡Α͏ͳϗετ৘ใ͕͋Δͷ͸Α͘ͳ͍ ֤छπʔϧͱૄ݁߹ʹ౷߹ REST APIʹΑΔपลπʔϧͱͷ࿈ܞ

Slide 122

Slide 122 text

ϝτϦΫεՄࢹԽͷ࣮૷ PullܕΞʔΩςΫνϟ WorkerManagerͰϓϩηε؅ཧ Storageʹ͸RRDtoolΛ࢖͏ RRDtool΂ΜΓ RRDtool͍ͨ΁Μ RRDtool͸΍͍ RRDtoolΉ͔͍ͣ͠

Slide 123

Slide 123 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ Thanks to id:stanaka, id:halfrack, id:wtatsuru, id:shoichimasuhara, id:hagihala