Your SlideShare is downloading. ×
エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

エロサイト管理者の憂鬱3 - Hokkaiodo.pm#4 -

5,727

Published on

エロサイト管理者の憂鬱3 …

エロサイト管理者の憂鬱3
Hokkaido.pm#4 のの発表資料です。

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,727
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
15
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. ./!"" repo#   !"" Changes#   !"" MANIFEST.SKIP#   !"" Makefile.PL#   !"" README#   !"" lib#   #   %"" SampleApp.pm#   !"" t#   #   %"" 00_compile.t#   %"" xt#   !"" 01_podspell.t#   !"" 02_perlcritic.t#   !"" 03_pod.t#   %"" perlcriticrc%"" sandbox
  • 2. ./lib!"" SampleApp#   !"" CLI#   #   %"" Crawler.pm#   !"" Role.pm use Mouse::Role;#   %"" Web#   !"" API.pm use Mouse; with “SampleApp::Role”;#   %"" Controller#   %"" Root.pm $c->model(“API”)->get_entries();%"" SampleApp.pm
  • 3. use LWP::UserAgent;use Email::Sender::Simple qw(sendmail);use Email::MIME;use Try::Tiny;use YAML qw(LoadFile);use Path::Class qw( file );my $file = $ARGV[0] || "config.yaml";die "Cant open $file" unless ( -f file($file)->stringify );my $config = LoadFile( file($file) );my $ua = LWP::UserAgent->new( agent => Monita/0.01, timeout => 30 );for my $url ( @{ $config->{url} } ) { my $res = $ua->get($url); send_report( $res ) unless $res->is_success;}sub send_report { my $res = shift; my $email = Email::MIME->create( header => [ From => $config->{from}, To => $config->{to}, Subject => $res->request->uri . : . $res->code, ], attributes => { content_type => text/plain, }, body => $res->status_line, ); try { sendmail($email) } catch { my $error = $_; warn $error->message };}

×