<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DkANQXozfyp7ImA9WhVUFU0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061</id><updated>2012-05-20T18:06:30.487+09:00</updated><category term="ruby" /><category term="node.js" /><category term="bad-knowhow" /><category term="websocket" /><category term="jenkins" /><category term="tomcat" /><category term="gitolite" /><category term="nltk" /><category term="vyatta" /><category term="mapreduce" /><category term="supervisord" /><category term="sleepy.mongoose" /><category term="git" /><category term="python" /><category term="okinawa" /><category term="rudix" /><category term="freebsd" /><category term="memo" /><category term="fluent" /><category term="aws" /><category term="linux" /><category term="centos" /><category term="NLP" /><category term="tornado" /><category term="camera" /><category term="php" /><category term="security" /><category term="mac os x" /><category term="nagios" /><category term="openssl" /><category term="music" /><category term="etc" /><category term="monitoring" /><category term="django" /><category term="mongodb" /><category term="sshd" /><category term="lunch" /><category term="javascripts" /><category term="jquery" /><category term="movie" /><category term="shellscripts" /><category term="tripwire" /><category term="lifelog" /><category term="ssl" /><category term="snmp" /><category term="network" /><category term="bootstrap" /><category term="boto" /><category term="ubuntu" /><category term="mercurial" /><category term="munin" /><category term="json" /><title>no workaround</title><subtitle type="html">チラ裏☆彡
python 関連はバージョン 2.6 か 2.7 を前提に</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.j4f.jp/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.j4f.jp/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>68</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/j4f/oeuE" /><feedburner:info uri="j4f/oeue" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DkANQXoycCp7ImA9WhVUFU0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-5358817497935696759</id><published>2012-05-20T18:06:00.000+09:00</published><updated>2012-05-20T18:06:30.498+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-20T18:06:30.498+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="memo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="jenkins" /><category scheme="http://www.blogger.com/atom/ns#" term="centos" /><category scheme="http://www.blogger.com/atom/ns#" term="supervisord" /><title>CentOS 6.x で supervisord と jenkins</title><content type="html">CentOS 6.x に supervisord と jenkins を導入したきろく&lt;br /&gt;
&lt;h2&gt;supervisord のインストールと設定ファイルの作成&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo yum install python-setuptools
[asato@localhost ~]$ sudo easy_install supervisor
[asato@localhost ~]$ sudo echo_supervisord_conf &gt; /etc/supervisord.conf
]]&gt;&lt;/script&gt;

&lt;h2&gt;設定ファイルの編集&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
# /etc/supervisord.conf
; Sample supervisor config file.
-- snip --
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=info                ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
-- snip --
[include]
files = /etc/supervisord/*.ini
]]&gt;&lt;/script&gt;

&lt;h2&gt;supervisord の upstart 用設定の作成&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
# /etc/init/supervisord.conf
description 'supervisord'

start on [2345]
stop on [!2345]

respawn
exec /usr/bin/supervisord -n
]]&gt;&lt;/script&gt;


&lt;h2&gt;もろもろのディレクトリ作成と jdk, jenkins の導入&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo mkdir /etc/supervisord/
[asato@localhost ~]$ sudo mkdir /usr/bin/jenkins
[asato@localhost ~]$ sudo touch /var/log/supervisord.log
[asato@localhost ~]$ sudo rpm -ivh jdk-7u4-linux-x64.rpm
[asato@localhost ~]$ cd /usr/bin/jenkins
[asato@localhost ~]$ sudo wget http://mirrors.jenkins-ci.org/war/latest/jenkins.war
]]&gt;&lt;/script&gt;

&lt;h2&gt;jenkins の supervisord 用設定ファイル&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
# /etc/supervisord/jenkins.ini
[program:jenkins]
command=/usr/bin/java -jar /usr/jenkins/jenkins.war
directory=/usr/jenkins
user=root
stdout_logfile_maxbytes=10MB
stderr_logfile_maxbytes=10MB
stdout_logfile=/tmp/jenkins_stdout
stderr_logfile=/tmp/jenkins_stderr
autostart=true
autorestart=true
]]&gt;&lt;/script&gt;





&lt;h2&gt;supervisord の起動&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo initctl start supervisord
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-5358817497935696759?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ij0nGmqVe10wVeXFwqvfUAE6CB8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ij0nGmqVe10wVeXFwqvfUAE6CB8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ij0nGmqVe10wVeXFwqvfUAE6CB8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ij0nGmqVe10wVeXFwqvfUAE6CB8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/fR1HDK9dbR8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/5358817497935696759/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/centos-6x-supervisord-jenkins.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5358817497935696759?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5358817497935696759?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/fR1HDK9dbR8/centos-6x-supervisord-jenkins.html" title="CentOS 6.x で supervisord と jenkins" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/centos-6x-supervisord-jenkins.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYCSHs-fyp7ImA9WhVUFU0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-1461940834060743165</id><published>2012-05-20T17:35:00.000+09:00</published><updated>2012-05-20T17:39:29.557+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-20T17:39:29.557+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="boto" /><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>boto の config にかける項目</title><content type="html">boto 2.4.1 のソースをざっと見た。設定ファイルには以下の値を書いておける&lt;br /&gt;
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
# ~/.boto       - for user-specific settings
# /etc/boto.cfg - for site-wide settings that all users on this machine will use

[Credentials]
aws_access_key_id = &lt;your access key&gt;
aws_secret_access_key = &lt;your secret key&gt;

[Boto]
debug =                                     # デバッグレベル 0-2
num_retries =                               # リトライ回数

proxy =                                     # プロキシ
proxy_port = 
proxy_user = 
proxy_pass = 

# EC2
ec2_region_name =
ec2_region_endpoint =

# autoscale
autoscale_endpoint =
autoscale_region_name =

# ELB
elb_region_name =
elb_region_endpoint =

# CloudWatch
cloudwatch_region_name =
cloudwatch_region_endpoint =

# ElasticMapReduce
emr_region_name =
emr_region_endpoint =

# CloudFormation
cfn_region_name =
cfn_region_endpoint =

# CloudSearch
cs_region_name =
cs_region_endpoint =

[DynamoDB]
region = 

[SDB]
region =

[DB]          # SDB 関連の設定値のはずだけどなぜか section が別になってる?
debug =
db_name =
db_user =
db_passwd =
db_type =
db_table =
db_host =
db_port =
enable_ssl =
sql_dir =

[SWF]
region =

]]&gt;&lt;/script&gt;
それぞれのリージョン名とかエンドポイント名は&lt;a href="http://docs.amazonwebservices.com/general/latest/gr/rande.html"&gt;ここ&lt;/a&gt;で確認&lt;br /&gt;
設定ファイルで指定してあげればそれぞれのサービスのデフォルトの接続先が 'us-east-1' から変更される。 S3 とか RDS はなんで設定ファイル見るようになってないのかな&lt;br /&gt;
まだ、全部試してないけど問題ないはず。。。。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pyami 関連は何するものかわかんないので省いています。&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-1461940834060743165?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/5WCoxetsORJXj09oVHL1H-CN66s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5WCoxetsORJXj09oVHL1H-CN66s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/5WCoxetsORJXj09oVHL1H-CN66s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/5WCoxetsORJXj09oVHL1H-CN66s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/o4c_ak3C2pk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/1461940834060743165/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/boto-config.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1461940834060743165?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1461940834060743165?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/o4c_ak3C2pk/boto-config.html" title="boto の config にかける項目" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/boto-config.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQGRHY7fip7ImA9WhVUE04.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-3029954839466780090</id><published>2012-05-18T19:18:00.000+09:00</published><updated>2012-05-18T19:18:45.806+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-18T19:18:45.806+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="boto" /><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>boto で rds</title><content type="html">boto の rds のインターフェースのドキュメントは API リファレンスくらいしか用意されてなくて、その API リファレンスも sphinx でうまくビルドできないのでソース見ながらいろいろとやった&lt;br /&gt;
&lt;h2&gt;rds インスタンスの作成&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import boto.rds
&gt;&gt;&gt; boto.rds.regions()                       # 使用可能なりーきょんの確認
[RegionInfo:us-east-1, RegionInfo:eu-west-1, RegionInfo:us-west-1, RegionInfo:us-west-2, RegionInfo:sa-east-1, RegionInfo:ap-northeast-1, RegionInfo:ap-southeast-1]
&gt;&gt;&gt; conndb = boto.rds.connect_to_region('ap-northeast-1')   # 東京リージョンに接続
&gt;&gt;&gt; print conndb
RDSConnection:rds.ap-northeast-1.amazonaws.com
&gt;&gt;&gt; req = conndb.create_dbinstance(
...     id='mydb1',                           # 作成するインスタンスの名前
...     allocated_storage=5,                  # ストレージのサイズ GB 単位()
...     instance_class='db.m1.small',         # インスタンスのクラス
...     engine='MySQL5.1',                    # 現在は MySQL5.1 のみの対応っぽい
...     master_username='asato',              # 作成するユーザ名
...     master_password='databasepassword',   # 作成するユーザのパスワード
...     port=3306,                            # mysql が listen するポート
...     db_name='myFirstDatabase',            # 作成するデータベースの名前。指定しなければデータベースは作られないので後で別途作成する必要がある
...     param_group='myparamgroupname',       # パラメータグループの名前
...     security_groups=['default'],          # 適用するセキュリティグループの名前
...     multi_az=False,                       # マルチアベイラリティゾーンの有効/無効 boolean で指定
...     engine_version='5.1.62',              # データベースのエンジンのバージョン
...     auto_minor_version_upgrade=True)      # マイナーバージョンが上がった時に自動でアップグレードするかどうか
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=CreateDBInstance&amp;AllocatedStorage=5&amp;AutoMinorVersionUpgrade=true&amp;DBInstanceClass=db.m1.small&amp;DBInstanceIdentifier=mydb1&amp;DBName=myFirstDatabase&amp;DBParameterGroupName=myparamgroupname&amp;DBSecurityGroups.member.1=default&amp;Engine=MySQL5.1&amp;EngineVersion=5.1.62&amp;MasterUserPassword=databasepassword&amp;MasterUsername=asato&amp;MultiAZ=false&amp;Port=3306&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T09%3A26%3A18Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage  HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: 8602efa0-a0cb-11e1-80bb-d9be177606a9
header: Content-Type: text/xml
header: Content-Length: 1618
header: Date: Fri, 18 May 2012 09:26:18 GMT
&gt;&gt;&gt; conndb.get_all_dbinstances()
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=DescribeDBInstances&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T09%3A26%3A59Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage  HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: 9e30831a-a0cb-11e1-8e49-3b33a03f00bb
header: Content-Type: text/xml
header: Content-Length: 1792
header: Date: Fri, 18 May 2012 09:26:59 GMT
[DBInstance:mydb1]
]]&gt;&lt;/script&gt;

&lt;h2&gt;リードレプリカの作成&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; rep = conndb.create_dbinstance_read_replica(
...     id='mydb1-read',                 # 作成するインスタンスの名前
...     source_id='mydb1',               # もとになる rds インスタンスの名前
...     instance_class='db.m1.small',
...     port=3306,
...     auto_minor_version_upgrade=True)
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=CreateDBInstanceReadReplica&amp;AutoMinorVersionUpgrade=true&amp;DBInstanceClass=db.m1.small&amp;DBInstanceIdentifier=mydb1-read&amp;Port=3306&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;SourceDBInstanceIdentifier=mydb1&amp;Timestamp=2012-05-18T09%3A34%3A49Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage  HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: b6ebba80-a0cc-11e1-80bb-d9be177606a9
header: Content-Type: text/xml
header: Content-Length: 1674
header: Date: Fri, 18 May 2012 09:34:50 GMT
&gt;&gt;&gt; conndb.get_all_dbinstances()           # 確認
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=DescribeDBInstances&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T09%3A35%3A14Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage  HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: c5b85537-a0cc-11e1-a3b6-e3abe3d1e1e3
header: Content-Type: text/xml
header: Content-Length: 3484
header: Date: Fri, 18 May 2012 09:35:14 GMT
[DBInstance:mydb1, DBInstance:mydb1-read]      # mydb1-read が、ちゃんと作成されていることが確認できる
]]&gt;&lt;/script&gt;
&lt;h2&gt;rds インスタンスの削除&lt;/h2&gt;
rds の場合は ec2 でいう stop ができないみたい。再起動はできるけど
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; conndb.delete_dbinstance('mydb1-read',skip_final_snapshot=True)
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=DeleteDBInstance&amp;DBInstanceIdentifier=mydb1-read&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;SkipFinalSnapshot=true&amp;Timestamp=2012-05-18T09%3A49%3A06Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage  HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: b5273c20-a0ce-11e1-80c9-9b3aec753c46
header: Content-Type: text/xml
header: Content-Length: 1906
header: Date: Fri, 18 May 2012 09:49:05 GMT
DBInstance:mydb1-read
&gt;&gt;&gt; conndb.get_all_dbinstances()     # 削除されたか確認
send: 'GET /?AWSAccessKeyId=HogeHogeHoge&amp;Action=DescribeDBInstances&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T09%3A56%3A20Z&amp;Version=2011-04-01&amp;Signature=HogeHageHogeHageHogeHage HTTP/1.1\r\nHost: rds.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 0\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: x-amzn-RequestId: b8812072-a0cf-11e1-9ce6-251b1a1198bb
header: Content-Type: text/xml
header: Content-Length: 2001
header: Date: Fri, 18 May 2012 09:56:21 GMT
[DBInstance:mydb1]                    # ちゃんと削除された
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-3029954839466780090?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/e_TVGcch940DPPjgN3LJy-cEqco/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/e_TVGcch940DPPjgN3LJy-cEqco/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/e_TVGcch940DPPjgN3LJy-cEqco/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/e_TVGcch940DPPjgN3LJy-cEqco/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/JjQKytDVLbg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/3029954839466780090/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/boto-rds.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/3029954839466780090?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/3029954839466780090?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/JjQKytDVLbg/boto-rds.html" title="boto で rds" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/boto-rds.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAHQnw8eyp7ImA9WhVUE08.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-2011250664600806257</id><published>2012-05-18T14:58:00.000+09:00</published><updated>2012-05-18T14:58:53.273+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-18T14:58:53.273+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="boto" /><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>boto で ec2 インスタンスの作成/起動/停止/終了</title><content type="html">&lt;h2&gt;インスタンスの作成&lt;/h2&gt;
どんなリクエストをなげて、どんなレスポンスが返って来ているのか確認するために boto のデバッグレベルを 2 にしてあります。
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import boto
&gt;&gt;&gt; conn = boto.connect_ec2()
&gt;&gt;&gt; req = conn.run_instances(
...     'ami-e47acbe5',                # AMI ID
...     key_name='awskey',             # key pair
...     instance_type='t1.micro',      # インスタンスのタイプ
...     security_groups=['default'])   # セキュリティグループ
send: 'POST / HTTP/1.1\r\nHost: ec2.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 316\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
send: 'AWSAccessKeyId=hagehogehagehoge&amp;Action=RunInstances&amp;ImageId=ami-e47acbe5&amp;InstanceType=t1.micro&amp;KeyName=awskey&amp;MaxCount=1&amp;MinCount=1&amp;SecurityGroup.1=default&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T05%3A07%3A10Z&amp;Version=2012-03-01&amp;Signature=hogehogehogehogehogehogehoge'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: text/xml;charset=UTF-8
header: Transfer-Encoding: chunked
header: Date: Fri, 18 May 2012 05:07:11 GMT
header: Server: AmazonEC2
&gt;&gt;&gt; print req.instances                # 起動されたインスタンスの ID を確認
[Instance:i-a54f27a5]
]]&gt;&lt;/script&gt;
run_instances() に placement='アベイラリティゾーン名' のオプションを渡せばインスタンスが起動するアベイラリティゾーンを指定することも可能。指定がない場合は適当なゾーンが指定されるみたい。&lt;br /&gt;


&lt;h2&gt;インスタンスの停止と起動&lt;/h2&gt;
停止したインスタンスはまた起動してやれば使える。複数のインスタンスを停止したい場合は .stop_instances(instance_ids=['instance1-id','instance2-id','instance3-id']) な感じで
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; conn.stop_instances(instance_ids=['i-a54f27a5'])
send: 'POST / HTTP/1.1\r\nHost: ec2.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 241\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
send: 'AWSAccessKeyId=hagehogehagehoge&amp;Action=StopInstances&amp;InstanceId.1=i-a54f27a5&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T05%3A31%3A46Z&amp;Version=2012-03-01&amp;Signature=hogehogehogehogehogehogehoge'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: text/xml;charset=UTF-8
header: Transfer-Encoding: chunked
header: Date: Fri, 18 May 2012 05:31:45 GMT
header: Server: AmazonEC2
[Instance:i-a54f27a5]
&gt;&gt;&gt; conn.start_instances(instance_ids=['i-a54f27a5'])  # 停止したインスタンスの起動
]]&gt;&lt;/script&gt;



&lt;h2&gt;インスタンスの終了&lt;/h2&gt;
終了したインスタンスは再利用できない。インスタンスの停止と同じように複数のインスタンスを終了することもできる。
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; conn.terminate_instances(instance_ids=['i-i-a54f27a5'])
send: 'POST / HTTP/1.1\r\nHost: ec2.ap-northeast-1.amazonaws.com\r\nAccept-Encoding: identity\r\nContent-Length: 244\r\nContent-Type: application/x-www-form-urlencoded; charset=UTF-8\r\nUser-Agent: Boto/2.4.1 (linux2)\r\n\r\n'
send: 'AWSAccessKeyId=hagehogehagehoge&amp;Action=TerminateInstances&amp;InstanceId.1=i-a54f27a5&amp;SignatureMethod=HmacSHA256&amp;SignatureVersion=2&amp;Timestamp=2012-05-18T05%3A34%3A45Z&amp;Version=2012-03-01&amp;Signature=hogehogehogehogehogehogehoge'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: text/xml;charset=UTF-8
header: Transfer-Encoding: chunked
header: Date: Fri, 18 May 2012 05:34:45 GMT
header: Server: AmazonEC2
[Instance:i-a54f27a5]
]]&gt;&lt;/script&gt;

&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-2011250664600806257?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/v4ctc_-3hOxjya-zEP778CbUv-8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v4ctc_-3hOxjya-zEP778CbUv-8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/v4ctc_-3hOxjya-zEP778CbUv-8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v4ctc_-3hOxjya-zEP778CbUv-8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/5NMYZTlRa4w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/2011250664600806257/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/boto-ec2_18.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/2011250664600806257?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/2011250664600806257?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/5NMYZTlRa4w/boto-ec2_18.html" title="boto で ec2 インスタンスの作成/起動/停止/終了" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/boto-ec2_18.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIGQXo_eip7ImA9WhVUEko.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-4807275358729323425</id><published>2012-05-18T01:02:00.000+09:00</published><updated>2012-05-18T01:02:00.442+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-18T01:02:00.442+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="nltk" /><category scheme="http://www.blogger.com/atom/ns#" term="NLP" /><title>nltk.text の関数を使ってみる</title><content type="html">&lt;a href="http://blog.j4f.jp/2012/05/blog-post.html"&gt;前回&lt;/a&gt;は python のビルトインの関数だけだったので nltk.text の関数も使ってみる。
&lt;h2&gt;単語の検索&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; from nltk.book import *
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908
&gt;&gt;&gt; text6.concordance('spam')    # Monty Python and the Holy Grail から 'spam' の単語を検索
Building index...
Displaying 1 of 1 matches:             # まぁ、アーサー王の話だし 1つしか見つからないのは当たり前か
 in Camelot . We eat ham and jam and spam a lot [ dancing ] We ' re knights of
&gt;&gt;&gt; text6.concordance('silly')      # じゃあ 'silly' はどうなんだろと
Displaying 8 of 8 matches:            # 8つ見つかった
 let ' s not go to Camelot . It is a silly place . KNIGHTS : Right . Right SCEN
 I have this outrageous accent , you silly king - a ?! GALAHAD : What are you d
 Go and boil your bottom , sons of a silly person . I blow my nose at you , so 
alled Arthur King , you and all your silly English k - nnnnniggets . Thpppppt !
IM : It is the rabbit ! ARTHUR : You silly sod ! TIM : What ? ARTHUR : You got 
. Chop his head off ! BORS : Right ! Silly little bleeder . One rabbit stew com
ut - clever us French folk with your silly knees - bent running about advancing
d call your door - opening request a silly thing , you tiny - brained wipers of
]]&gt;&lt;/script&gt;
&lt;!--- more ---&gt;
Text.concordance() は前後の文章とあわせて表示してくれるけど純粋に単語がいくつ含まれるか知りたい場合は Text.count() をつかえばいいみたいだけど、大文字と小文字区別する
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; text6.count('silly')
7
&gt;&gt;&gt; text6.count('Silly')
1
]]&gt;&lt;/script&gt;
&lt;a href="http://ja.wikipedia.org/wiki/%E9%80%A3%E8%AA%9E"&gt;連語&lt;/a&gt;を抽出
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; text6.collocations()
Building collocations list
BLACK KNIGHT; HEAD KNIGHT; Holy Grail; FRENCH GUARD; Sir Robin; Run
away; CARTOON CHARACTER; King Arthur; Iesu domine; Pie Iesu; DEAD
PERSON; Round Table; OLD MAN; dramatic chord; dona eis; eis requiem;
LEFT HEAD; FRENCH GUARDS; music stops; Sir Launcelot
&gt;&gt;&gt; text6.collocations(num=30)   # num を指定しないと、最初の 20 しか表示されないのでそれ以上見たい場合はこんな感じで 
Building collocations list
BLACK KNIGHT; HEAD KNIGHT; Holy Grail; FRENCH GUARD; Sir Robin; Run
away; CARTOON CHARACTER; King Arthur; Iesu domine; Pie Iesu; DEAD
PERSON; Round Table; OLD MAN; dramatic chord; dona eis; eis requiem;
LEFT HEAD; FRENCH GUARDS; music stops; Sir Launcelot; MIDDLE HEAD;
RIGHT HEAD; Sir Galahad; angels sing; Arthur music; Hand Grenade;
Three questions; Heh heh; brave Sir; make sure
]]&gt;&lt;/script&gt;
正規表現が使える Text.findall() 
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; text6.findall("&lt;a.*&gt;{3,}")   # a から始まる単語が3回連続で使われているところを抽出
act as a; at all afraid; and argue about; and anchovies and
]]&gt;&lt;/script&gt;
text6 に含まれる単語をつかって、それっぽい文章の生成
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; text6.generate()
Building ngram index...
SCENE 1 : Right . How many did we lose ? LAUNCELOT : Farewell , sweet
Concorde ! CONCORDE : No one live there . ARTHUR : Well , u -- um ,
riding north from Camelot , a swallow ' s no ordinary rabbit . ARTHUR
: If you do doubt your courage or your strength , come no further ,
for beyond the cave of Caerbannog -- wherein , carved in the van .
OFFICER # 1 : Get on with it thou mayest blow thine enemies to tiny
bits , in which Arthur discovers a vital clue
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-4807275358729323425?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/loX37cgNXdY3LsD2U-xguv6v4CM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/loX37cgNXdY3LsD2U-xguv6v4CM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/loX37cgNXdY3LsD2U-xguv6v4CM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/loX37cgNXdY3LsD2U-xguv6v4CM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/bFrLjbOVRZw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/4807275358729323425/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/nltktext.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4807275358729323425?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4807275358729323425?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/bFrLjbOVRZw/nltktext.html" title="nltk.text の関数を使ってみる" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/nltktext.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8BQXo7eyp7ImA9WhVUEks.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-1059462224204052916</id><published>2012-05-18T00:00:00.000+09:00</published><updated>2012-05-18T00:00:50.403+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-18T00:00:50.403+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="boto" /><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>boto で ec2 接続</title><content type="html">&lt;a href="http://www.cloud-japan.jp/CLOUDJAPAN/Venue-and-Date/"&gt;先日のクラウドコンピューティング Expo&lt;/a&gt; の&lt;a href="http://classmethod.jp/"&gt;クラスメソッド&lt;/a&gt;さんのブースでガチャ回したら、 &lt;a href="http://classmethod.jp/service/voucher/"&gt;aws の1万円分のバウチャーチケット&lt;/a&gt;もらった。&lt;br /&gt;
なので、前から試したかった&lt;a href="https://github.com/boto/boto"&gt;boto&lt;/a&gt; で、いろいろやってます&lt;br /&gt;
&lt;h2&gt;EC2 に接続&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import boto
&gt;&gt;&gt; conn = boto.connect_ec2('&lt;AWS_ACCESS_KEY_ID&gt;', '&lt;AWS_SECRET_ACCESS_KEY&gt;')
&gt;&gt;&gt; conn
EC2Connection:ec2.us-east-1.amazonaws.com
]]&gt;&lt;/script&gt;
標準だと 'us-east-1' に接続されるんだね&lt;br /&gt;
どうやって接続先のリージョンかえるんだろと思ってドキュメントみたけど見つけらんなかったのでソース(boto/ec2/connection.py)みた
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
-- snip --
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                 proxy=None, proxy_port=None,
                 proxy_user=None, proxy_pass=None, debug=0,
                 https_connection_factory=None, region=None, path='/',
                 api_version=None, security_token=None):
        """
        Init method to create a new connection to EC2.
        """
        if not region:
            region = RegionInfo(self, self.DefaultRegionName,
                                self.DefaultRegionEndpoint)
        self.region = region
        AWSQueryConnection.__init__(self, aws_access_key_id,
                                    aws_secret_access_key,
                                    is_secure, port, proxy, proxy_port,
                                    proxy_user, proxy_pass,
                                    self.region.endpoint, debug,
                                    https_connection_factory, path,
                                    security_token)
-- snip --
 ]]&gt;&lt;/script&gt;
boto.connect_ec2() にアクセスキーとかと一緒に渡せばいいみたいだけど、毎回書くのは面倒だしどうせ東京リージョンしか使わないので&lt;br /&gt;
コンフィグを書いた
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
# ~/.boto
[Credentials]
aws_access_key_id = '&lt;AWS_ACCESS_KEY_ID&gt;'
aws_secret_access_key = '&lt;AWS_SECRET_ACCESS_KEY&gt;'
[Boto]
debug = 0
num_retries = 10
ec2_region_name = 'ap-northeast-1'
ec2_region_endpoint = 'ec2.ap-northeast-1.amazonaws.com'
]]&gt;&lt;/script&gt;
ec2_region_name, ec2_region_endpoint は&lt;a href="http://docs.amazonwebservices.com/general/latest/gr/rande.html#ec2_region"&gt;ここ&lt;/a&gt;で確認した。&lt;br /&gt;
ちゃんと接続できるか確認
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
&gt;&gt;&gt; conn = boto.connect_ec2()
&gt;&gt;&gt; conn
EC2Connection:'ec2.ap-northeast-1.amazonaws.com'
]]&gt;&lt;/script&gt;
おｋ&lt;br /&gt;
次回はインスタンスの起動、停止と破棄など&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-1059462224204052916?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hdbU67A-rvbhMrVXHqYelDdT_E8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hdbU67A-rvbhMrVXHqYelDdT_E8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hdbU67A-rvbhMrVXHqYelDdT_E8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hdbU67A-rvbhMrVXHqYelDdT_E8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/-eeo_5x9AsI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/1059462224204052916/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/boto-ec2.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1059462224204052916?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1059462224204052916?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/-eeo_5x9AsI/boto-ec2.html" title="boto で ec2 接続" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/boto-ec2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AFRXw7eip7ImA9WhVVF0g.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-6791764266479263133</id><published>2012-05-12T01:57:00.000+09:00</published><updated>2012-05-12T02:01:54.202+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-12T02:01:54.202+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="nltk" /><category scheme="http://www.blogger.com/atom/ns#" term="NLP" /><title>初歩の初歩？</title><content type="html">とりあえず&lt;a href="http://blog.j4f.jp/2012/05/ubuntu-nltk.html"&gt;前回&lt;/a&gt;ダウンロードしたデータで python のビルトインの関数だけを使っていろいろやってみる。&lt;br&gt;
&lt;a href="http://blog.j4f.jp/2012/05/blog-post.html#more"&gt;もっと読む »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-6791764266479263133?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vJtqeU1-h0BwqRInfb_KBMwj7d0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vJtqeU1-h0BwqRInfb_KBMwj7d0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vJtqeU1-h0BwqRInfb_KBMwj7d0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vJtqeU1-h0BwqRInfb_KBMwj7d0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/NL1nORRxtk8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/6791764266479263133/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/blog-post.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6791764266479263133?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6791764266479263133?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/NL1nORRxtk8/blog-post.html" title="初歩の初歩？" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/blog-post.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EEQH04eyp7ImA9WhVVFE0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-1796123570882916908</id><published>2012-05-08T00:46:00.000+09:00</published><updated>2012-05-08T00:46:41.333+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-08T00:46:41.333+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="websocket" /><title>websocket クライアント側の実装(js)</title><content type="html">動作が確認出来ればいいだけなのでとりあえず&lt;a href="http://www.tornadoweb.org/documentation/websocket.html"&gt;ドキュメント&lt;/a&gt;からそのまんまこぴぺ
&lt;script type='syntaxhighlighter' class='brush:js'&gt;&lt;![CDATA[

var ws = new WebSocket("ws://localhost:8080/");
ws.onopen = function() {
   ws.send("Hello, world");
   };
   ws.onmessage = function (evt) {
      alert(evt.data);
      };
 
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-1796123570882916908?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kgz3121XpzXYXwKkHeUJWQhuH6A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kgz3121XpzXYXwKkHeUJWQhuH6A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kgz3121XpzXYXwKkHeUJWQhuH6A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kgz3121XpzXYXwKkHeUJWQhuH6A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/dSkj_yKx5cU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/1796123570882916908/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/websocket-js.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1796123570882916908?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1796123570882916908?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/dSkj_yKx5cU/websocket-js.html" title="websocket クライアント側の実装(js)" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/websocket-js.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4FRHg6eSp7ImA9WhVVFE0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-3838542847666698864</id><published>2012-05-08T00:27:00.001+09:00</published><updated>2012-05-08T00:35:15.611+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-08T00:35:15.611+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="websocket" /><category scheme="http://www.blogger.com/atom/ns#" term="tornado" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>tornado で websocket</title><content type="html">ひとまず &lt;a href="http://www.tornadoweb.org/"&gt;tornado&lt;/a&gt; でサーバサイドを&lt;a href="http://www.tornadoweb.org/documentation/websocket.html"&gt;ドキュメント&lt;/a&gt;見ながら書いてみた
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
# -*- coding: utf-8 -*-
from tornado import ioloop, web, websocket, httpserver

class EchoWebSocket(websocket.WebSocketHandler):
    def open(self):
        print "WebSocket Opend"

    def on_message(self, message):
        self.write_message(u"ウェブソケットのてすと" + message)

    def on_close(self):
        print "WebSocket Closed"

application = web.Application([
    (r'/', EchoWebSocket),
])

if __name__ == '__main__':
    http_server = httpserver.HTTPServer(application)
    http_server.listen(8080)
    ioloop.IOLoop.instance().start()

]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-3838542847666698864?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/oz79ks9yC8H9MwaDK7-FBrgWitw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oz79ks9yC8H9MwaDK7-FBrgWitw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/oz79ks9yC8H9MwaDK7-FBrgWitw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oz79ks9yC8H9MwaDK7-FBrgWitw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/cU6HxLbMrmI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/3838542847666698864/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/tornado-websocket.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/3838542847666698864?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/3838542847666698864?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/cU6HxLbMrmI/tornado-websocket.html" title="tornado で websocket" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/tornado-websocket.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBQHc8eyp7ImA9WhVVE0s.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-5572261191671051191</id><published>2012-05-07T14:40:00.004+09:00</published><updated>2012-05-07T14:40:51.973+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-07T14:40:51.973+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><category scheme="http://www.blogger.com/atom/ns#" term="NLP" /><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu" /><title>ubuntu へ nltk をインストール</title><content type="html">N・L・P！！N・L・P！！ &lt;br /&gt;
自然言語処理を勉強しようと ubuntu 10.04 へ&lt;a href="http://www.nltk.org/"&gt;nltk(Natural Language Toolkit)&lt;/a&gt; を導入しためも
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
asato@localhost:~$ sudo aptitude install python-nltk
]]&gt;&lt;/script&gt;
使えるデータが何もないので nltk のプロジェクトが提供しているデータをダウンロードします。&lt;br /&gt;
ここから python のシェルで
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import nltk
&gt;&gt;&gt; nltk.download()  # 実行するとダウンロードメニューが表示される
NLTK Downloader
---------------------------------------------------------------------------
    d) Download      l) List      c) Config      h) Help      q) Quit
---------------------------------------------------------------------------
Downloader&gt; l  # ダウンロード可能なパッケージ(データ)のリストを確認

Packages:
/usr/lib/pymodules/python2.6/nltk/__init__.py:588: DeprecationWarning: object.__new__() takes no parameters
  [ ] conll2000........... CONLL 2000 Chunking Corpus
  [ ] conll2002........... CONLL 2002 Named Entity Recognition Corpus
  [ ] conll2007........... Dependency Treebanks from CoNLL 2007 (Catalan
                           and Basque Subset)
  [ ] dependency_treebank. Dependency Parsed Treebank
  [ ] europarl_raw........ Sample European Parliament Proceedings Parallel
                           Corpus
  [ ] floresta............ Portuguese Treebank
  [ ] gazetteers.......... Gazeteer Lists
  [ ] genesis............. Genesis Corpus
  [ ] gutenberg........... Project Gutenberg Selections
  [ ] ieer................ NIST IE-ER DATA SAMPLE
  [ ] inaugural........... C-Span Inaugural Address Corpus
  [ ] indian.............. Indian Language POS-Tagged Corpus
  [ ] jeita............... JEITA Public Morphologically Tagged Corpus (in
                           ChaSen format)
  [ ] kimmo............... PC-KIMMO Data Files
  [ ] knbc................ KNB Corpus (Annotated blog corpus)
  [ ] langid.............. Language Id Corpus
  [ ] mac_morpho.......... MAC-MORPHO: Brazilian Portuguese news text with
                           part-of-speech tags
Hit Enter to continue:
--- snip ---
Collections:
  [ ] all-corpora......... All the corpora
  [ ] all................. All packages
  [ ] book................ Everything used in the NLTK Book

([*] marks installed packages)

---------------------------------------------------------------------------
    d) Download      l) List      c) Config      h) Help      q) Quit
---------------------------------------------------------------------------
Downloader&gt; d   # d を入力するとダウンロードするパッケージを聞いてくる
Download which package (l=list; x=cancel)?
  Identifier&gt; book  # 今回は book コレクションをダウンロード
    Downloading collection 'book'
       |
       | Downloading package 'brown' to /home/asato/nltk_data...
       |   Unzipping corpora/brown.zip.
       | Downloading package 'chat80' to /home/asato/nltk_data...
       |   Unzipping corpora/chat80.zip.
       | Downloading package 'cmudict' to /home/asato/nltk_data...
       |   Unzipping corpora/cmudict.zip.
       | Downloading package 'conll2000' to /home/asato/nltk_data...
       |   Unzipping corpora/conll2000.zip.
       | Downloading package 'conll2002' to /home/asato/nltk_data...
       |   Unzipping corpora/conll2002.zip.
       | Downloading package 'dependency_treebank' to
--- snip ---
       | Downloading package 'punkt' to /home/asato/nltk_data...
       |   Unzipping tokenizers/punkt.zip.
       | Downloading package 'book_grammars' to
       |     /home/asato/nltk_data...
       |   Unzipping grammars/book_grammars.zip.
       | Downloading package 'tagsets' to /home/asato/nltk_data...
       |
     Done downloading collection 'book'

---------------------------------------------------------------------------
    d) Download      l) List      c) Config      h) Help      q) Quit
---------------------------------------------------------------------------
Downloader&gt; l # パッケージのリストを確認すると、すでに導入済みのパッケージは * でマークされている。

Packages:
  [*] conll2000........... CONLL 2000 Chunking Corpus
  [*] conll2002........... CONLL 2002 Named Entity Recognition Corpus
  [ ] conll2007........... Dependency Treebanks from CoNLL 2007 (Catalan
                           and Basque Subset)
  [*] dependency_treebank. Dependency Parsed Treebank
  [ ] europarl_raw........ Sample European Parliament Proceedings Parallel
                           Corpus
  [ ] floresta............ Portuguese Treebank
  [ ] gazetteers.......... Gazeteer Lists
  [*] genesis............. Genesis Corpus
  [*] gutenberg........... Project Gutenberg Selections
  [*] ieer................ NIST IE-ER DATA SAMPLE
  [*] inaugural........... C-Span Inaugural Address Corpus
  [ ] indian.............. Indian Language POS-Tagged Corpus
  [ ] jeita............... JEITA Public Morphologically Tagged Corpus (in
--- snip ---
]]&gt;&lt;/script&gt;
とりあえずここまで&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-5572261191671051191?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8zDwpVRK81OQXy2XLwUsQgZt1bg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8zDwpVRK81OQXy2XLwUsQgZt1bg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8zDwpVRK81OQXy2XLwUsQgZt1bg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8zDwpVRK81OQXy2XLwUsQgZt1bg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/t2Xgjm3ED0Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/5572261191671051191/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/ubuntu-nltk.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5572261191671051191?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5572261191671051191?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/t2Xgjm3ED0Y/ubuntu-nltk.html" title="ubuntu へ nltk をインストール" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/ubuntu-nltk.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQAQHY-eip7ImA9WhVWGU8.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-5704840839316860828</id><published>2012-05-02T10:49:00.001+09:00</published><updated>2012-05-02T10:49:01.852+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-02T10:49:01.852+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python で url のパースその2</title><content type="html">&lt;a href="https://github.com/codeinthehole/purl"&gt;purl&lt;/a&gt; をつかって&lt;br /&gt;
easy_install か pip でインストール
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
asato@localhost:~$ sudo easy_install purl
]]&gt;&lt;/script&gt;
で、
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
&gt;&gt;&gt; from purl import URL
&gt;&gt;&gt; BASE_URL = "http://192.168.0.xxx/db/coll/_action?query={ _id: -1}"
&gt;&gt;&gt; u = URL.from_string(BASE_URL)
&gt;&gt;&gt; u
_URLTuple(host='192.168.0.xxx', username=None, password=None, scheme='http', port=None, path='/db/coll/_action', query='query={ _id: -1}', fragment='')
&gt;&gt;&gt; u.scheme()
'http'
&gt;&gt;&gt; u.host()
'192.168.0.xxx'
&gt;&gt;&gt; u.domain()
'192.168.0.xxx'
&gt;&gt;&gt; u.port()
&gt;&gt;&gt; u.path()
'/db/coll/_action'
&gt;&gt;&gt; u.query()
'query={ _id: -1}'
&gt;&gt;&gt; u.fragment()
''
]]&gt;&lt;/script&gt;

今度は組み立ててみる
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; u = URL().scheme('http').host('192.168.0.xxx').path('/db/coll/_action').query('query={ _id: -1}')
&gt;&gt;&gt; u
_URLTuple(host='192.168.0.xxx', username=None, password=None, scheme='http', port=None, path='/db/coll/_action', query='query={ _id: -1}', fragment=None)
&gt;&gt;&gt; print u.as_string()
http://192.168.0.xxx/db/coll/_action?query={ _id: -1}
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-5704840839316860828?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/v5QosdjCCRv60dv7X8Tn2xn6I1c/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v5QosdjCCRv60dv7X8Tn2xn6I1c/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/v5QosdjCCRv60dv7X8Tn2xn6I1c/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v5QosdjCCRv60dv7X8Tn2xn6I1c/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/fOrBHooaR5g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/5704840839316860828/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/python-url-2.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5704840839316860828?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5704840839316860828?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/fOrBHooaR5g/python-url-2.html" title="python で url のパースその2" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/python-url-2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8NRn0-fyp7ImA9WhVWGEU.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-6336789880906494848</id><published>2012-05-02T00:58:00.001+09:00</published><updated>2012-05-02T00:58:17.357+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-02T00:58:17.357+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python で url のパース その１</title><content type="html">標準のモジュール urlparse で&lt;br /&gt;
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; from urlparse import urlparse
&gt;&gt;&gt; BASE_URL = "http://192.168.0.xxx/db/coll/_action?query={ _id: -1}"
&gt;&gt;&gt; res = urlparse(BASE_URL)
&gt;&gt;&gt; res
ParseResult(scheme='http', netloc='192.168.0.xxx', path='/db/coll/_action', params='', query='query={ _id: -1}', fragment='')
&gt;&gt;&gt; res.scheme
'http'
&gt;&gt;&gt; res.netloc
'192.168.0.xxx'
&gt;&gt;&gt; res.path
'/db/coll/_action'
&gt;&gt;&gt; res.params
''
&gt;&gt;&gt; res.query
'query={ _id: -1}'
&gt;&gt;&gt; res.fragment
''
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-6336789880906494848?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2_ubkwisgDTufTlLuJlbxinxYy8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2_ubkwisgDTufTlLuJlbxinxYy8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2_ubkwisgDTufTlLuJlbxinxYy8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2_ubkwisgDTufTlLuJlbxinxYy8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/NFJRkui8HEA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/6336789880906494848/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/python-url.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6336789880906494848?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6336789880906494848?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/NFJRkui8HEA/python-url.html" title="python で url のパース その１" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/python-url.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IMRHY7eCp7ImA9WhVWGEU.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-9069114793467309881</id><published>2012-05-01T23:13:00.000+09:00</published><updated>2012-05-01T23:13:05.800+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-01T23:13:05.800+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>なんで Python なのかって</title><content type="html">だいたいの Linux のディストリなら最小限の構成で OS インストールした直後にソフトウェアを追加したりせずにすぐ使えるから :-)&lt;br /&gt;
それじゃあ Perl でも（ｒｙ &lt;br /&gt;
&lt;b&gt;参考：&lt;a href="https://wiki.linuxfoundation.org/en/LSB_Wiki"&gt;LSB&lt;/a&gt;、&lt;a href="https://wiki.linuxfoundation.org/en/LsbPython"&gt;LSB Python&lt;/a&gt;&lt;/b&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-9069114793467309881?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/UYUG3uEC8F2CYZwoxar3aR47zYA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UYUG3uEC8F2CYZwoxar3aR47zYA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/UYUG3uEC8F2CYZwoxar3aR47zYA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UYUG3uEC8F2CYZwoxar3aR47zYA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/gpitlsfzp80" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/9069114793467309881/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/05/python.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/9069114793467309881?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/9069114793467309881?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/gpitlsfzp80/python.html" title="なんで Python なのかって" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/05/python.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcFR3k6fyp7ImA9WhVWFUk.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-4917476382879089049</id><published>2012-04-28T02:14:00.001+09:00</published><updated>2012-04-28T02:16:56.717+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-28T02:16:56.717+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sshd" /><category scheme="http://www.blogger.com/atom/ns#" term="centos" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>sftp-server のログを</title><content type="html">CentOS5.x で、 sftp の転送ログというか操作ログ？を syslog に記録するめも&lt;br /&gt;
標準の /etc/ssh/sshd_config の Subsystem の項目はこうなっているはず
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
-- snip --
# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server
]]&gt;&lt;/script&gt;
これを
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
-- snip --
# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server -l INFO
]]&gt;&lt;/script&gt;
こう変更して sshd を再起動すると /var/log/messages に
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
Mar 25 20:31:05 hoge sftp-server[16354]: session opened for local user asato from [192.168.0.xxx]
Mar 25 20:31:05 hoge sftp-server[16354]: opendir "/home/asato"
Mar 25 20:31:05 hoge sftp-server[16354]: closedir "/home/asato"
Mar 25 20:31:31 hoge sftp-server[16354]: open "/home/asato/access_log.hoge.log" flags READ mode 0666
Mar 25 20:31:44 hoge sftp-server[16354]: close "/home/asato/access_log.hoge.log" bytes read 83197172 written 0
Mar 25 20:31:52 hoge sftp-server[16354]: remove name "/home/asato/access_log.hoge.log"
Mar 25 20:31:52 hoge sftp-server[16354]: opendir "/home/asato"
Mar 25 20:31:52 hoge sftp-server[16354]: closedir "/home/asato"
Mar 25 20:32:03 hoge sftp-server[16354]: remove name "/home/asato/hoge.tgz"
Mar 25 20:32:04 hoge sftp-server[16354]: opendir "/home/asato"
Mar 25 20:32:04 hoge sftp-server[16354]: closedir "/home/asato"
Mar 25 20:32:10 hoge sftp-server[16354]: session closed for local user asato from [192.168.0.xxx]
]]&gt;&lt;/script&gt;
こういう感じでログが記録されるようになる。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-4917476382879089049?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/UCNdmRd0eaQC2VmttwlrtWIhpEc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UCNdmRd0eaQC2VmttwlrtWIhpEc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/UCNdmRd0eaQC2VmttwlrtWIhpEc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/UCNdmRd0eaQC2VmttwlrtWIhpEc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/P8pBT13GCfQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/4917476382879089049/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/sftp-server.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4917476382879089049?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4917476382879089049?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/P8pBT13GCfQ/sftp-server.html" title="sftp-server のログを" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/sftp-server.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAGQH4-cSp7ImA9WhVWFU4.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-4398665445929710353</id><published>2012-04-27T21:45:00.000+09:00</published><updated>2012-04-27T21:45:21.059+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-27T21:45:21.059+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="centos" /><category scheme="http://www.blogger.com/atom/ns#" term="tripwire" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>CentOS 5.x de Tripwire ぱーと2</title><content type="html">前回は導入と Tripwire のデータベースの初期化まで行ったので、今回は Tripwire のレポートメール関連の設定を

&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo tripwire --check
]]&gt;&lt;/script&gt;

メールが送信できるかテスト
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo tripwire --test --email someone@example.com
Sending a test message to: someone@example.com
]]&gt;&lt;/script&gt;
メールが送信できない場合はローカルのMTAの設定を見直すか外部のSMTPを使用するように設定を変更
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo vi /etc/tripwire/twcfgl.txt
]]&gt;&lt;/script&gt;

標準のコンフィグ
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
-- snip --
MAILMETHOD             =SENDMAIL
SYSLOGREPORTING        =false
MAILPROGRAM            =/usr/sbin/sendmail -oi -t
-- snip --
]]&gt;&lt;/script&gt;

外部の SMTP を使用するようにはコンフィグをこんな感じで
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
-- snip --
MAILMETHOD             =SMTP              # SENDMAIL から SMTP へ変更
SMTPHOST               =                  # IP アドレスかホスト名(fqdn)
SMTPPORT               =25                # ポート
SYSLOGREPORTING        =false
MAILPROGRAM            =/usr/sbin/sendmail -oi -t
-- snip --
]]&gt;&lt;/script&gt;
レポート全体をメールで受け取りたい場合は、ポリシーの "# Tripwire Binaries" の直前あたりと最後あたりに行を追加
&lt;script type='syntaxhighlighter' class='brush: bash'&gt;&lt;![CDATA[
-- snip --
SIG_MED       = 66 ;                 # Non-critical files that are of significant security impact
SIG_HI        = 100 ;                # Critical files that are significant points of vulnerability

(  emailto = "someone@example.com" ) # 追加
{                                    # 追加

# Tripwire Binaries
(
   rulename = "Tripwire Binaries",
   severity = $(SIG_HI)
)
-- snip --
}

}                                    # 追加
# disabled-entries: 184

# license:
#=============================================================================
#
-- snip --
]]&gt;&lt;/script&gt;
コンフィグもポリシーも編集したら、"tw.pol" と "tw.cfg" の再生成とデータベースの初期化を忘れずに&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-4398665445929710353?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kghPFomW63wEKyJqaCnu-WPaq-8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kghPFomW63wEKyJqaCnu-WPaq-8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kghPFomW63wEKyJqaCnu-WPaq-8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kghPFomW63wEKyJqaCnu-WPaq-8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/bQBGWsa3IQg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/4398665445929710353/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/centos-5x-de-tripwire-2.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4398665445929710353?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4398665445929710353?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/bQBGWsa3IQg/centos-5x-de-tripwire-2.html" title="CentOS 5.x de Tripwire ぱーと2" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/centos-5x-de-tripwire-2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMHRnczfip7ImA9WhVWFEg.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-8559058279204612336</id><published>2012-04-27T00:33:00.001+09:00</published><updated>2012-04-27T00:33:57.986+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-27T00:33:57.986+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="munin" /><category scheme="http://www.blogger.com/atom/ns#" term="monitoring" /><category scheme="http://www.blogger.com/atom/ns#" term="nagios" /><title>munin で監視してアラートメールとか</title><content type="html">nagios で使っている check_munin_rrd.pl が、何故かすんごい勢いでCPUを使いまくって監視サーバのロードアベレージの値が精神衛生上あまりよくない数字になっちゃっているので、 munin でやれることは munin で nagios はプラグインは極力使わずping監視くらいにしようと思いmuninで監視設定したったメモ&lt;br&gt;
&lt;br&gt;
&lt;h2&gt;エスカレーション先の定義&lt;/h2&gt;
munin.conf へ&amp;quot;contact.&lt;b&gt;hogehoge&lt;/b&gt;.command some_action&amp;quot; という行を追加してエスカレーション先を指定していきます。&lt;b&gt;hogehoge&lt;/b&gt; の部分は任意です。わかり易い名前がいいんでしょうね&lt;br&gt;
command の後ろに色々書くことで自作のスクリプトをキックしたりnagiosと連携させることが出来るんだけれども、だけれども今回は単純にアラートメールを送信するだけにします。&lt;br&gt;こったことやりたかったらこんなチラ裏を参考にしないで、ちゃんと&lt;a href="http://munin-monitoring.org/wiki/HowToContact"&gt;公式のドキュメント&lt;/a&gt;読もうね♪&lt;br&gt;
&lt;a href="http://blog.j4f.jp/2012/04/munin.html#more"&gt;もっと読む »&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-8559058279204612336?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XOWlgWQAgLWTUkYUPMjlYPY7ZkA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XOWlgWQAgLWTUkYUPMjlYPY7ZkA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XOWlgWQAgLWTUkYUPMjlYPY7ZkA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XOWlgWQAgLWTUkYUPMjlYPY7ZkA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/5_XDaiOD4gA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/8559058279204612336/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/munin.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/8559058279204612336?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/8559058279204612336?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/5_XDaiOD4gA/munin.html" title="munin で監視してアラートメールとか" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/munin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcDRnYzfyp7ImA9WhVWFEg.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-4464030756738498371</id><published>2012-04-27T00:27:00.003+09:00</published><updated>2012-04-27T00:27:57.887+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-27T00:27:57.887+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python subprocess のサンプル</title><content type="html">&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; def ping(addr):
...     try:
...             output = subprocess.check_output(['ping', addr, '-c 3'])
...     except subprocess.CalledProcessError as err:
...             print 'ERROR: ', err
...     else:
...             print output
...
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-4464030756738498371?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/bbj1lrR5Vlp1TJkkQ-NYE7vOqJY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bbj1lrR5Vlp1TJkkQ-NYE7vOqJY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/bbj1lrR5Vlp1TJkkQ-NYE7vOqJY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/bbj1lrR5Vlp1TJkkQ-NYE7vOqJY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/A1lSEW0hygY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/4464030756738498371/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/python-subprocess.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4464030756738498371?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/4464030756738498371?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/A1lSEW0hygY/python-subprocess.html" title="python subprocess のサンプル" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/python-subprocess.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIBRng_fyp7ImA9WhVWFEg.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-624018790162034704</id><published>2012-04-27T00:02:00.000+09:00</published><updated>2012-04-27T00:02:37.647+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-27T00:02:37.647+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="memo" /><category scheme="http://www.blogger.com/atom/ns#" term="mongodb" /><title>mongodb のシェルで全件表示</title><content type="html">mongodb のシェルで  "db.collection.find()" とかやってもデータの件数が多いと最初の何件かが表示されて "has more" ってでて全件は表示されない。&lt;br /&gt;
たまに ML とかでも全件表示するにはどうすれば〜っていうのを見かける。たしか公式のドキュメントに書いてあったと思うんだけど、全件表示させるには
&lt;script type='syntaxhighlighter' class='brush: js'&gt;&lt;![CDATA[
&gt; db.collection.find().forEach(printjson)
]]&gt;&lt;/script&gt;
とする。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-624018790162034704?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/959ekmYPr8iHkqqAdJYJ4bSl2NE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/959ekmYPr8iHkqqAdJYJ4bSl2NE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/959ekmYPr8iHkqqAdJYJ4bSl2NE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/959ekmYPr8iHkqqAdJYJ4bSl2NE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/XLTs19dyUNQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/624018790162034704/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/mongodb.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/624018790162034704?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/624018790162034704?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/XLTs19dyUNQ/mongodb.html" title="mongodb のシェルで全件表示" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/mongodb.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4GRnc6eip7ImA9WhVWFEg.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-6172955292561859180</id><published>2012-04-26T23:35:00.000+09:00</published><updated>2012-04-26T23:35:27.912+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-26T23:35:27.912+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rudix" /><category scheme="http://www.blogger.com/atom/ns#" term="mac os x" /><title>Rudix ステキ</title><content type="html">ちょっと前に &lt;a href="http://blog.j4f.jp/2012/03/blog-post.html"&gt;Xcode Tools がインストールできなくて云々&lt;/a&gt;と書いたんだけど、その後 &lt;a href="http://rudix.org/"&gt;Rudix&lt;/a&gt; とかいう素敵なパッケージ管理システムをみつけていろいろはかどっているのでめも&lt;br /&gt;
&lt;h2&gt;Rudix のインストール&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
mba-anr:~ asato$ curl -O http://rudix.googlecode.com/hg/Ports/rudix/rudix.py
mba-anr:~ asato$ sudo python rudix.py install rudix
]]&gt;&lt;/script&gt;
&lt;h2&gt;パッケージの検索とインストール&lt;/h2&gt;
&lt;script type='syntaxhighlighter' class='brush:bash'&gt;&lt;![CDATA[
mba-anr:~ asato$ rudix search make    # make コマンドのパッケージを検索
make-3.82-2
mba-anr:~ asato$ sudo rudix install make   # パッケージのインストール
Password:
Downloading rudix-snowleopard.googlecode.com/files/make-3.82-2.pkg
######################################################################## 100.0%
installer: Package name is GNU Make 3.82
installer: Installing at base path /
installer: The install was successful.
All done
]]&gt;&lt;/script&gt;
macports とかに比べるとパッケージ数が少ないみたいだけど、いまのところ不自由はしていないです。&lt;br /&gt;
一時期 make コマンドのためだけに Lion にバージョンアップしようかと本気で悩んでいたので、ほんと助かった&lt;br /&gt;
これで Mountain Lion が出るまで Snow Leopard で戦える&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-6172955292561859180?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vj9teq8AEWfg541Qyhng0ddtswI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vj9teq8AEWfg541Qyhng0ddtswI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vj9teq8AEWfg541Qyhng0ddtswI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vj9teq8AEWfg541Qyhng0ddtswI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/HnZR552qmvI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/6172955292561859180/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/rudix.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6172955292561859180?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/6172955292561859180?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/HnZR552qmvI/rudix.html" title="Rudix ステキ" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/rudix.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcNRXc_fip7ImA9WhVXGU0.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-2774313272585700347</id><published>2012-04-20T16:46:00.002+09:00</published><updated>2012-04-20T16:48:14.946+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-20T16:48:14.946+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascripts" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python の urllib2.urlopen()</title><content type="html">&lt;a href="http://blog.j4f.jp/2012/04/jquery-getjson-sleepymongoose.html"&gt;前回の&lt;/a&gt; jquery の getJSON() ではなく python でデータを取ってくる場合のめも 
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import urllib2
&gt;&gt;&gt; url = "http://192.168.0.xxx:27080/testdb/count_hourly/_find"
&gt;&gt;&gt; res = urllib2.urlopen(url)
&gt;&gt;&gt; res.read()
'{"ok": 1, "results": [{"_id": "2011-04-18 09:00:00", "value": 439.0}, {"_id": "2011-04-18 10:00:00", "value": 322.0},
 {"_id": "2011-04-18 11:00:00", "value": 250.0}, {"_id": "2011-04-18 12:00:00", "value": 643.0}, {"_id": "2011-04-18 13:00:00", "value": 20.0},
 {"_id": "2011-04-18 14:00:00", "value": 252.0}, {"_id": "2011-04-18 15:00:00", "value": 747.0}, {"_id": "2011-04-18 16:00:00", "value": 486.0},
 {"_id": "2011-04-18 17:00:00", "value": 2097.0}, {"_id": "2011-04-18 18:00:00", "value": 3437.0}, {"_id": "2011-04-18 19:00:00", "value": 20018.0},
 {"_id": "2011-04-18 20:00:00", "value": 2060.0}, {"_id": "2011-04-18 21:00:00", "value": 655.0}, {"_id": "2011-04-18 22:00:00", "value": 950.0},
 {"_id": "2011-04-18 23:00:00", "value": 1164.0}], "id": 61}'
]]&gt;&lt;/script&gt;
http://192.168.0.xxx:27080/testdb/count_hourly/_find?sort={"_id": -1}
みたいに query をいじりたい場合は
&lt;script type='syntaxhighlighter' class='brush:python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import urllib, urllib2
&gt;&gt;&gt; url = "http://192.168.0.xxx:27080/testdb/count_hourly/_find?"
&gt;&gt;&gt; str = '{"_id": -1}'
&gt;&gt;&gt; query = { 'sort' : str }
&gt;&gt;&gt; opt = urllib.urlencode(query)
&gt;&gt;&gt; req = url + opt
&gt;&gt;&gt; req
'http://192.168.0.xxx:27080/testdb/count_hourly/_find?sort=%7B%22_id%22%3A+-1%7D'
&gt;&gt;&gt; res = urllib2.urlopen(req)
&gt;&gt;&gt; res.read()
{"ok": 1, "results": [{"_id": "2012-04-20 06:00:00", "value": 807.0}, {"_id": "2012-04-20 05:00:00", "value": 1154.0},
 {"_id": "2012-04-20 04:00:00", "value": 1019.0}, {"_id": "2012-04-20 03:00:00", "value": 778.0}, {"_id": "2012-04-20 02:00:00", "value": 1520.0},
 {"_id": "2012-04-20 01:00:00", "value": 1145.0}, {"_id": "2012-04-20 00:00:00", "value": 1961.0}, {"_id": "2012-04-19 23:00:00", "value": 2214.0},
 {"_id": "2012-04-19 22:00:00", "value": 2133.0}, {"_id": "2012-04-19 21:00:00", "value": 1951.0}, {"_id": "2012-04-19 20:00:00", "value": 1859.0},
 {"_id": "2012-04-19 19:00:00", "value": 3476.0}, {"_id": "2012-04-19 18:00:00", "value": 3082.0}, {"_id": "2012-04-19 17:00:00", "value": 3703.0},
 {"_id": "2012-04-19 16:00:00", "value": 4837.0}], "id": 63}
]]&gt;&lt;/script&gt;
javascript だとこんな感じか
&lt;script type='syntaxhighlighter' class='brush:js'&gt;&lt;![CDATA[
$.getJSON("http://192.168.0.xxx:27080/testdb/count_hourly/_find?sort="+ encodeURIComponent('{"_id": -1}'),
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-2774313272585700347?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/31CgUEWan4jakxAUHXn7yuXpZCY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/31CgUEWan4jakxAUHXn7yuXpZCY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/31CgUEWan4jakxAUHXn7yuXpZCY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/31CgUEWan4jakxAUHXn7yuXpZCY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/Ze5W-UW-gwA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/2774313272585700347/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/python-urllib2urlopen.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/2774313272585700347?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/2774313272585700347?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/Ze5W-UW-gwA/python-urllib2urlopen.html" title="python の urllib2.urlopen()" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/python-urllib2urlopen.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QFQn45eCp7ImA9WhVXGEk.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-1773846927273301966</id><published>2012-04-19T22:15:00.000+09:00</published><updated>2012-04-19T22:15:13.020+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-19T22:15:13.020+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascripts" /><category scheme="http://www.blogger.com/atom/ns#" term="sleepy.mongoose" /><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="json" /><title>jquery の getJSON() で sleepy.mongoose からデータを</title><content type="html">&lt;a href="https://github.com/kchodorow/sleepy.mongoose"&gt;sleepy.mongoose&lt;/a&gt; が吐き出してくれる JSON のデータを使ってかっちょいいグラフを javascript で表示したいと思い&lt;br /&gt;
jquery の getJSON を初めて使ってみたのでめも&lt;br /&gt;
sleepy.mongoose が出力しているのはこんな形式
&lt;script type='syntaxhighlighter' class='brush:js'&gt;&lt;![CDATA[
{"ok": 1, "results": [{"_id": "2011-11-09 18:00:00", "value": 149.0}, {"_id": "2011-11-09 19:00:00", "value": 4028.0}, {"_id": "2011-11-14 17:00:00", "value": 35.0}, {"_id": "2011-11-17 15:00:00", "value": 479.0}, {"_id": "2011-11-17 16:00:00", "value": 170.0}, {"_id": "2011-11-17 17:00:00", "value": 295.0}, {"_id": "2011-11-17 18:00:00", "value": 279.0}, {"_id": "2011-11-17 19:00:00", "value": 380.0}, {"_id": "2011-11-17 20:00:00", "value": 37.0}, {"_id": "2011-11-17 21:00:00", "value": 97.0}, {"_id": "2011-11-17 22:00:00", "value": 80.0}, {"_id": "2011-11-17 23:00:00", "value": 7.0}, {"_id": "2011-11-18 00:00:00", "value": 10.0}, {"_id": "2011-11-18 01:00:00", "value": 10.0}, {"_id": "2011-11-18 02:00:00", "value": 9.0}], "id": 59}
]]&gt;&lt;/script&gt;
で、 getJSON の使い方はこんな感じで
&lt;script type='syntaxhighlighter' class='brush:js'&gt;&lt;![CDATA[
  $.getJSON("http://192.168.0.xxx:27080/DB/COLLECTION/_find?callback=?",
    null,
    function (data) {
      $.each(data.results, function(i, result) {
        // データを加工したり
      });
    });
]]&gt;&lt;/script&gt;
callback=? がポイント&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-1773846927273301966?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4WKAqSOVUTgo5MVyf8jPuwRCGcA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4WKAqSOVUTgo5MVyf8jPuwRCGcA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4WKAqSOVUTgo5MVyf8jPuwRCGcA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4WKAqSOVUTgo5MVyf8jPuwRCGcA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/DRKARqbMF94" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/1773846927273301966/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/jquery-getjson-sleepymongoose.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1773846927273301966?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1773846927273301966?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/DRKARqbMF94/jquery-getjson-sleepymongoose.html" title="jquery の getJSON() で sleepy.mongoose からデータを" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/jquery-getjson-sleepymongoose.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4DR3s9fSp7ImA9WhVXGEw.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-5294952561891466969</id><published>2012-04-19T15:29:00.002+09:00</published><updated>2012-04-19T15:29:36.565+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-19T15:29:36.565+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="memo" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python の型変換 float -&gt; str</title><content type="html">&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
&gt;&gt;&gt; import time
&gt;&gt;&gt; t = time.time()
&gt;&gt;&gt; print t
1334816889.71
&gt;&gt;&gt; type(t)
&lt;type 'float'&gt;
&gt;&gt;&gt; t = str(t)
&gt;&gt;&gt; print t
1334816889.71
&gt;&gt;&gt; type(t)
&lt;type 'str'&gt;
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-5294952561891466969?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TEH5q9JabRSHksU2-On2H4MZHag/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TEH5q9JabRSHksU2-On2H4MZHag/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TEH5q9JabRSHksU2-On2H4MZHag/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TEH5q9JabRSHksU2-On2H4MZHag/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/TWo_trsnRoU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/5294952561891466969/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/python-float-str.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5294952561891466969?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/5294952561891466969?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/TWo_trsnRoU/python-float-str.html" title="python の型変換 float -&gt; str" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/python-float-str.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4BRXczfip7ImA9WhVXF08.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-700135896289146775</id><published>2012-04-18T12:49:00.000+09:00</published><updated>2012-04-18T12:49:14.986+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-18T12:49:14.986+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="munin" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python で munin-node から値を取ってくる</title><content type="html">munin-node は telnet で接続して"fetch &lt;b&gt;PLUGINNAME&lt;/b&gt;"とコマンドを入力すると、その plugin で取得できる値を一覧で出力してくれる。&lt;br /&gt;
この値を python から参照したい場合はこんな感じで
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
import telnetlib

HOST = '192.168.0.xxx'
PORT = '4949'

tel = telnetlib.Telnet()

tel.open(HOST, PORT)
tel.read_until("munin node")
tel.write("fetch PLUGINNAME¥n")
res = tel.read_until(".¥n")
tel.close()
]]&gt;&lt;/script&gt;
あとは res をいじって扱いやすい形式にする。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-700135896289146775?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ps-1hXomgwSzhOqgzEWjWcuDKNE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ps-1hXomgwSzhOqgzEWjWcuDKNE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ps-1hXomgwSzhOqgzEWjWcuDKNE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ps-1hXomgwSzhOqgzEWjWcuDKNE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/oY8lzmXn_wg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/700135896289146775/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/python-munin-node.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/700135896289146775?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/700135896289146775?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/oY8lzmXn_wg/python-munin-node.html" title="python で munin-node から値を取ってくる" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/python-munin-node.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQAQnc5fyp7ImA9WhVXFko.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-1723852992320654387</id><published>2012-04-18T00:42:00.001+09:00</published><updated>2012-04-18T00:42:23.927+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-18T00:42:23.927+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="memo" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>python リストから空の要素を削除</title><content type="html">例えばこんなリストがあったとして
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
list = ["", "1", "2", "3", "", "4"]
]]&gt;&lt;/script&gt;
このリストから空の要素("")を削除するには
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
while list.count("") &gt; 0:
    list.remove("")

print list
#['1', '2', '3', '4']
]]&gt;&lt;/script&gt;
か
&lt;script type='syntaxhighlighter' class='brush: python'&gt;&lt;![CDATA[
while (True):
    try:
        list.remove("")
    except:
        break

print list
#['1', '2', '3', '4']
]]&gt;&lt;/script&gt;
とする。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-1723852992320654387?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6gm9Ge1Lph-RgkwNLBjfuPofF-Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6gm9Ge1Lph-RgkwNLBjfuPofF-Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6gm9Ge1Lph-RgkwNLBjfuPofF-Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6gm9Ge1Lph-RgkwNLBjfuPofF-Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/LJRn5MwotRo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/1723852992320654387/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/python.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1723852992320654387?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/1723852992320654387?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/LJRn5MwotRo/python.html" title="python リストから空の要素を削除" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/python.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QEQXo8fSp7ImA9WhVXEk4.&quot;"><id>tag:blogger.com,1999:blog-5665538881670842061.post-8183310406529604421</id><published>2012-04-12T21:55:00.000+09:00</published><updated>2012-04-12T21:55:00.475+09:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-12T21:55:00.475+09:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="centos" /><category scheme="http://www.blogger.com/atom/ns#" term="tripwire" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>CentOS 5.x de Tripwire ぱーと1</title><content type="html">epel のリポジトリから

tripwire をインストール
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo yum install tripwire
]]&gt;&lt;/script&gt;


ローカルキーの作成
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo twadmin --generate-keys -L /etc/tripwire/local.key

(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)

Enter the local keyfile passphrase:     #パスフレーズの入力
Verify the local keyfile passphrase:    #もう一度入力
Generating key (this may take several minutes)...Key generation complete.
]]&gt;&lt;/script&gt;

サイトキーの作成
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo twadmin --generate-keys -S /etc/tripwire/site.key

(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)

Enter the site keyfile passphrase:     #パスフレーズの入力
Verify the site keyfile passphrase:    #もう一度入力
Generating key (this may take several minutes)...Key generation complete.
]]&gt;&lt;/script&gt;

&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
Please enter your site passphrase:      #サイトキーのパスフレーズを入力
Wrote configuration file: /etc/tripwire/tw.cfg
]]&gt;&lt;/script&gt;

設定ファイルの編集
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo vi /etc/tripwire/twcfg.txt
]]&gt;&lt;/script&gt;

LOCALKEYFILE が標準だと /etc/tripwire/$(HOSTNAME)-local.key になっているが、
今回は /etc/tripwire/local.key としてローカルキーを作成しているので変更
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
ROOT                   =/usr/sbin
POLFILE                =/etc/tripwire/tw.pol
DBFILE                 =/var/lib/tripwire/$(HOSTNAME).twd
REPORTFILE             =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
SITEKEYFILE            =/etc/tripwire/site.key
LOCALKEYFILE           =/etc/tripwire/local.key
EDITOR                 =/bin/vi
LATEPROMPTING          =false
LOOSEDIRECTORYCHECKING =false
MAILNOVIOLATIONS       =true
EMAILREPORTLEVEL       =3
REPORTLEVEL            =3
MAILMETHOD             =SENDMAIL
SYSLOGREPORTING        =false
MAILPROGRAM            =/usr/sbin/sendmail -oi -t
]]&gt;&lt;/script&gt;

修正したらコンフィグファイルを生成
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
Please enter your site passphrase:
Wrote configuration file: /etc/tripwire/tw.cfg
]]&gt;&lt;/script&gt;

ポリシーファイルを生成
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo twadmin -m P -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key /etc/tripwire/twpol.txt
Please enter your site passphrase:
Wrote policy file: /etc/tripwire/tw.pol
]]&gt;&lt;/script&gt;

初期化を実行
&lt;script type='syntaxhighlighter' class='brush: php|python|html|css|bash|js'&gt;&lt;![CDATA[
[asato@localhost ~]$ sudo tripwire --init
Please enter your local passphrase:
Incorrect local passphrase.
Please enter your local passphrase:

Parsing policy file: /etc/tripwire/tw.pol
Generating the database...
*** Processing Unix File System ***
### Warning: File system error.
### Filename: /dev/kmem
--- snip ---
### Continuing...
### Warning: File system error.
### Filename: /dev/cua0
### \\xe3\\x81\\x9d\\xe3\\x81\\xae\\xe3\\x82\\x88\\xe3\\x81\\x86\\xe3\\x81\\xaa\\xe3\\x83\\x95\\xe3\\x82\\xa1\\x
e3\\x82\\xa4\\xe3\\x83\\xab\\xe3\\x82\\x84\\xe3\\x83\\x87\\xe3\\x82\\xa3\\xe3\\x83\\xac\\xe3\\x82\\xaf\\xe3\\x83
\\x88\\xe3\\x83\\xaa\\xe3\\x81\\xaf\\xe3\\x81\\x82\\xe3\\x82\\x8a\\xe3\\x81\\xbe\\xe3\\x81\\x9b\\xe3\\x82\\x93
### Continuing...
Wrote database file: /var/lib/tripwire/localhost.localdomain.twd
The database was successfully generated.
]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5665538881670842061-8183310406529604421?l=blog.j4f.jp' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4wbjnVNg5tk6b1w7yiMY8SQ9Osc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4wbjnVNg5tk6b1w7yiMY8SQ9Osc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4wbjnVNg5tk6b1w7yiMY8SQ9Osc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4wbjnVNg5tk6b1w7yiMY8SQ9Osc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/j4f/oeuE/~4/BxWY9Bti_m4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.j4f.jp/feeds/8183310406529604421/comments/default" title="コメントの投稿" /><link rel="replies" type="text/html" href="http://blog.j4f.jp/2012/04/centos-5x-de-tripwire-1.html#comment-form" title="0 件のコメント" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/8183310406529604421?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/5665538881670842061/posts/default/8183310406529604421?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/j4f/oeuE/~3/BxWY9Bti_m4/centos-5x-de-tripwire-1.html" title="CentOS 5.x de Tripwire ぱーと1" /><author><name>MASAKI Asato</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-zZIUzNrNtM4/AAAAAAAAAAI/AAAAAAAACrw/2AAi_T8Q0sQ/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.j4f.jp/2012/04/centos-5x-de-tripwire-1.html</feedburner:origLink></entry></feed>

