LANDISKã®ã¡ã¼ã«éç¥ã«AWS SESã使ã
ä½åº¦è¨å®ãã¦ãã¡ã¼ã«ãéä¿¡ã§ããªãã
Â
ãµã¨ãAWS SESã®ãã¹ã¯ã¼ãã¯40æå以ä¸ããã®ã«ãªãã20æåãããããå ¥ã£ã¦ããªããã¨ã«æ°ãä»ãã
Â
ã¨æã£ãããã¹ã¯ã¼ãå ¥åæ¬ã®æ大æåã20æåã ã£ãã
Â
ãªã®ã§ãã©ã¦ã¶ã®éçºè ãã¼ã«(DevTool)ã§ç´æ¥ã¶ã¡è¾¼ãã§ç»é²ããã¨ãããã
Â
å ¥åæ¬ã¯20æåå¶éããã¦ãã®ã«ç»é²ã§ããã®ããªãã ããªã¨æãã
MySQLã§é£çªãã¼ãã«çæ
group by ããã¨ãã«å¼ã£ããããªãã£ãåã®å¤ã0ã«ãããã¨ãããã¾ãããï¼
ä¾ãã°ãããªã®
mysql> SELECT a,count(a) count FROM hoge GROUP BY a; +---+-------+ | a | count | +---+-------+ | 1 | 110 | | 3 | 540 | | 4 | 245 | +---+-------+
ã
+---+-------+ | a | count | +---+-------+ | 1 | 110 | | 2 | 0 | | 3 | 540 | | 4 | 245 | | 5 | 0 | +----+------+
ã£ã¦ãªé¢¨ã«ã
PostgreSQLã 㨠generate_series() ãããã®ã«ãMySQLã ã¨ãªãã¦ã¤ã©ã¤ã©ã
ãªã®ã§ generate_series() ã®ä»£ããã«ãããªã¯ã¨ãªã§ä»£ç¨ããã
SELECT s.a, coalesce(r.count,0) count FROM ( SELECT a,count(a) count FROM hoge GROUP BY a ) r RIGHT JOIN ( SELECT 1 a UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ) s ON r.a=s.a;
ãã§ã大éã®é£çªãã¤ããã®ã§ããã°ãããªé¢¨ã«ããã
SELECT s.a, coalesce(r.count,0) count FROM ( SELECT a,count(a) count FROM hoge GROUP BY a ) r RIGHT JOIN ( SELECT s0.a*25 + s1.a*5 + s2.a a FROM (SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) s0, (SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) s1, (SELECT 0 a UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4) s2 ) s ON r.a=s.a;
ããã ã¨0ã124ã®é£çªãçæãããããã£ã¨æ¬²ãããªãRIGHT JOINå ã®UNIONãå¢ããããSELECTãå¢ããã°ããã
Xfceã§ESCãã¼ãå¹ããªã
ããã±ã¼ã¸ãæ´æ°ããã¨ãã¾ã«ãã¼ã®è¨å®ããããããªã£ã¦ã¤ã©ã¤ã©ã
ç°å¢çã«ã¯
- Xã¨ã³ã³ã½ã¼ã«ã§Ctrlã¨Capsãå ¥ãæ¿ãã
- emacsã使ãéã«ESCã§metaãã¼ã«ãã
ã ãéæããã¦ãã°ããã
Ctrlã¨Capsã®å ¥ãæ¿ã
# vi /etc/default/keyboard XKBOPTIONS="ctrl:swapcaps"
Xfceã§emacsã使ãã¨ESCãã¼ãåå¿ããªãã¦å°ã
è¨å® âãã¼ãã¼ã âã¢ããªã±ã¼ã·ã§ã³ã·ã§ã¼ãã«ãããã¼ â"xfdesktop --menu <Control>Escape" ãåé¤
ããã§ãã£ã¨ãã£ããã
Windows7ã®å ±æãã©ã«ããLinuxããç´æ¥ãã¦ã³ã
KVMä¸ã§èµ·åããWindows7ã¨ãã¡ã¤ã«ã®ããã¨ãããã®ã©ãããããã¨æã£ã¦ãå
±æãã©ã«ã使ãã°ãããããã¨ã
smbclientã¯ç¥ã£ã¦ãããã©ãä»ã¯cifsãªãã ã£ã¦ãã
ã¨ããããç¥ã£ã¦ãã¨ããã«ãã£ã¦ã¿ãã
ãã¡ã¯KVMä¸ã®ãã¹ãã®ãã¼ã139ãlocalhostã®ãã¼ã10139ã«ãããã³ã°ãã¦ãã®ã§ã
$ smbclient -p 10139 -I localhost //WIN7/hoge
ãããåé¡ãªããã§ãmountã®å ´åã¯
# mount -t cifs //WIN7/hoge hoge -o ip=127.0.0.1,port=10139 Password: mount error(112): Host is down
ãããã¤ãªãããªãããªãã ã»ã»ã»
ããã§ç¢ºãWindows2000ããã¯å¥ã®ãã¼ããç¨æãããã¨ããªãã¨ãã£ã¦ã®ãæãåºããã®ã§ããã¼ã445ã§è¨å®ããªããã¦ãã£ã¦ã¿ãã
# mount -t cifs //WIN7/hoge hoge -o ip=127.0.0.1,port=10445,user=(Windowsã®ã¦ã¼ã¶å),uid=(ãã¼ã«ã«ã®ã¦ã¼ã¶å),gid=(ãã¼ã«ã«ã®ã¦ã¼ã¶å)
ã¤ãªãã£ãï¼
ããã§ã¾ãä¸ã¤å¿«é©ã«ãªãã¾ããã
KVMä¸ãããªãã¦ããããã¯ã¼ã¯ä¸ã«ããå
±æè¨å®ããã¦ãããã®ã¯ããã§å
¨é¨ããããã ã
munin2ã§åçã«ã°ã©ããä½æ
æãã使ã£ã¦ããã©ããããããµã¼ããç»é²ããã¨ã°ã©ã表示ãããã·ã³ã«é«è² è·ããããã¾ãã£ã¦ã¦ãã®ãé£ç¹ã§ããã
æè¿ã®ã¯æ¹åãããã¨ã®ãã¨ãªã®ã§ãã£ããè¨å®ãã¦ã¿ã¾ããã
munin1ç³»ã®ã¯ã¡ãã»ããããã©ãmunin2ã®cgiã®æ¥æ¬èªã®è¨äºãæå¤ã¨å°ãªãã®ã§åå¿é²ã¨ãã¦ã
ãã¡ã¯Debianãªã®ã§aptã§ã¤ã³ã¹ãã¼ã«ãå
¥ããã®ã¯2.0.6ã ãã©ãã£ã確èªããã2.0.7ãã§ã¦ããã¾ããããã
ãã¨apacheãããªãã¦nginxã使ã£ã¦ã¾ããapacheã®äººã¯ここãå
¬å¼ã®èª¬æãªã®ã§ãã¡ããèªãã§ä¸ããã
/etc/munin/munin.conf
graph_strategy cron html_strategy cron ã graph_strategy cgi html_strategy cgi ã«ããã ã°ã©ãçæç¨ã®å é¨URLãè¨å® cgiurl_graph /munin/cgi-graph
ãã®å¾ãmuninãä¸å¿åèµ·åã
fcgiã®æºå
CGIã§ã°ã©ããæç»ããã®ã§nginxããå¼ã³åºãããå
ã®ãã¼ã¢ã³ãå¿
è¦ã
muninã®ã«ã¼ãURLç¨ã¨ã°ã©ãçæç¨ã®2ã¤ããããããèµ·åãã¦ããã
# aptitude install spawn-fcgi # chown munin /var/log/munin/munin-cgi-*.log # chown munin.www-data (munin.conf ã® cgitmpdir ã§æå®ããã¦ããã£ã¬ã¯ããª) # spawn-fcgi -s /var/run/munin/fcgi-graph.sock -U www-data -u munin -g munin /usr/lib/munin/cgi/munin-cgi-graph # spawn-fcgi -s /var/run/munin/fcgi-html.sock -U www-data -u munin -g munin /usr/lib/munin/cgi/munin-cgi-html
spawn-fcgi 㯠-n ãã¤ããã¨ãã©ã¢ã°ã©ã¦ã³ãã§åä½ããã®ã§ãåããªãã¨ãã¨ãã¯ããã§åå ã確èªãããããªãã
nginxã®è¨å®
è¨å®ãã¡ã¤ã«ã«3ã¤ã®locationãè¨å®ã
- ã°ã©ãçæç¨ã®å é¨URL
- éçãã¡ã¤ã«ã¸ã®å é¨URL
- muninã®ã«ã¼ãURL
# ã°ã©ãçæç¨ã®å é¨URL location ^~ /munin/cgi-graph/ { access_log off; fastcgi_split_path_info ^(/munin/cgi-graph)(.*); fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/var/run/munin/fcgi-graph.sock; include fastcgi_params; } # éçãã¡ã¤ã«ã¸ã®å é¨URL location /munin/static/ { alias /etc/munin/static/; } # muninã®ã«ã¼ãURL location /munin/ { fastcgi_split_path_info ^(/munin)(.*); fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass unix:/var/run/munin/fcgi-html.sock; include fastcgi_params; }
è¨è¿°ãããnginxãåèµ·åãã¦ããã©ã¦ã¶ãã/munin/ã«ã¢ã¯ã»ã¹ãã¦ç¢ºèªã
spawn-fcgiã®èµ·åã¹ã¯ãªãã(/etc/init.d/spawn-fcgi-munin)
åä½ã確èªã§ãããããµã¼ãã®èµ·åæã«spawn-fcgiãèªåã§å®è¡ãã¦æ¬²ããã®ã§/etc/init.d/ã«èµ·åã¹ã¯ãªãããè¨ç½®ããã
æ㯠update-rc.d ã§ãã£ã¦ããã©ããã¤ã®ã¾ã«ã insserv ãæ¨å¥¨ã«ãªã£ã¦ã¦ã¡ãã£ã¨ã³ã£ããã
1. /etc/init.d/spawn-fcgi-munin ã以ä¸ã®å
容ã§ä½æã
2. root ããã㯠sudo 㧠insserv spawn-fcgi-munin ãå®è¡ããã
#! /bin/sh # # init script of spawn-fcgi for munin. # ### BEGIN INIT INFO # Provides: spawn-fcgi-munin # Required-Start: $remote_fs $syslog nginx # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: spawn-fcgi for munin. ### END INIT INFO # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="spawn-fcgi for munin" NAME=spawn-fcgi-munin GRAPH_PIDFILE=/var/run/munin/fcgi-graph.pid GRAPH_SOCKFILE=/var/run/munin/fcgi-graph.sock GRAPH_CGIFILE=/usr/lib/munin/cgi/munin-cgi-graph HTML_PIDFILE=/var/run/munin/fcgi-html.pid HTML_SOCKFILE=/var/run/munin/fcgi-html.sock HTML_CGIFILE=/usr/lib/munin/cgi/munin-cgi-html DAEMON=/usr/bin/spawn-fcgi DAEMON_ARGS="-U www-data -u munin -g munin" SCRIPTNAME=/etc/init.d/$NAME # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME # Define LSB log_* functions. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present # and status_of_proc is working. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { local pidfile sockfile cgifile pidfile=$1 sockfile=$2 cgifile=$3 # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $pidfile --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $pidfile --exec $DAEMON -- \ $DAEMON_ARGS -s $sockfile -P $pidfile $cgifile > /dev/null \ || return 2 } # # Function that stops the daemon/service # do_stop() { local pidfile pidfile=$1 # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $pidfile RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $pidfile return "$RETVAL" } case "$1" in start) log_daemon_msg "Starting $DESC(graph)" "munin-cgi-graph" do_start "$GRAPH_PIDFILE" "$GRAPH_SOCKFILE" "$GRAPH_CGIFILE" log_end_msg $(( $? / 2 )) log_daemon_msg "Starting $DESC(html)" "munin-cgi-html" do_start "$HTML_PIDFILE" "$HTML_SOCKFILE" "$HTML_CGIFILE" log_end_msg $(( $? / 2 )) ;; stop) log_daemon_msg "Stopping $DESC(graph)" "munin-cgi-graph" do_stop "$GRAPH_PIDFILE" "$GRAPH_SOCKFILE" log_end_msg $(( $? / 2 )) log_daemon_msg "Stopping $DESC(html)" "munin-cgi-html" do_stop "$HTML_PIDFILE" "$HTML_SOCKFILE" log_end_msg $(( $? / 2 )) ;; status) status_of_proc -p "$GRAPH_PIDFILE" "$DAEMON" "munin-cgi-graph" RETVAL=$? status_of_proc -p "$HTML_PIDFILE" "$DAEMON" "munin-cgi-html" if [ "$RETVAL" = 0 ] && [ "$?" = 0 ]; then exit 0 elif [ "$RETVAL" = 2 ] || [ "$?" = 2 ]; then exit 2 else exit 1 fi ;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC(graph)" "munin-cgi-graph" do_stop "$GRAPH_PIDFILE" case "$?" in 0|1) do_start "$GRAPH_PIDFILE" "$GRAPH_SOCKFILE" "$GRAPH_CGIFILE" case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) log_end_msg 1 # Failed to stop ;; esac log_daemon_msg "Restarting $DESC(html)" "munin-cgi-html" do_stop "$HTML_PIDFILE" case "$?" in 0|1) do_start "$HTML_PIDFILE" "$HTML_SOCKFILE" "$HTML_CGIFILE" case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) log_end_msg 1 # Failed to stop ;; esac ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac :
insservããããæåã§å®è¡ãã spawn-fcgi ã kill ãã¦/etc/init.d/spawn-fcgi-munin start ãã¦ã¿ãã
ãã©ã¦ã¶ãã確èªã§ãããOKã
次ã¯templateããã£ã¦ãjQuery ã® lazyload ãçµã¿è¾¼ãã§ããã©ã¦ã¶ã«è¡¨ç¤ºããã¦ããã°ã©ãã ãçæããããã«ãã¦ã¿ããããªãããããã°ãã軽ããªãã¯ãã ãã
nginxã§fancyindex
ã¨ãããã£ã¬ã¯ããªä¸è¦§ã表示ããã®ã« autoindex ã¯çµæ§ä¾¿å©ã
ã ãã©è¡¨ç¤ºãã·ã³ãã«ããã¦ããã¦ã¹ã¿ã¤ã«ã·ã¼ãã使ããã°ãªãã¨æããã¨ããã°ãã°ã
apacheã§ãfancyindexã£ã¦ã®ããããã§ãnginxã§ãããããªã¨æã£ãããã£ã±ããã£ãã
makeããªãããªãããªããã®ãããã©ããã©ãã¨ããããã§ãããã§åå¿é²ã¨ãã¦ã
debã®ä½æ
æé ã¯ãããªæã
1. ngx-fancyindexãåã£ã¦ããã 2. nginxã®ã½ã¼ã¹ãå±éããã 3. configureã§fancyindexã追å ããã 4. makeãã¦ã¤ã³ã¹ãã¼ã«ã
èªåã®ç°å¢ã¯ Debian wheezy ãªãã§ããã£ããã ããdebã«ãããã¨ã«ããã
nginx-fullã使ã£ã¦ããã©ãnginx-lightã§ããã£ã¨æé ã¯ä¸ç·ã®ã¯ãã
$ su # vi /etc/apt/source.list ã½ã¼ã¹ç¨ã®apt line ãè¿½è¨ (ä¾ deb-src http://ftp.jp.debian.org/debian/ wheezy main contrib) # aptitude update # aptitude build-dep nginx # exit $ git clone git://gitorious.org/ngx-fancyindex/ngx-fancyindex.git ngx-fancyindex $ apt-get source nginx-full $ cd nginx-#.#.# $ cp -r ../ngx-fancyindex debian/module $ vi debian/rules config.status.full ãæ¢ãã¦ã --add-module=$(MODULESDIR)/ngx-fancyindex \ ã追è¨ããã $ vi debian/changelog (ãã£ããã ãã以ä¸ã®ãããªã®ãå é ã«è¿½è¨ãã¦ãã¼ã¸ã§ã³æ´æ°) nginx (#.#.#-#+custom-1) unstable; urgency=low * Add module (fancyindex). -- åå <åå@localhost> æ¥ä» $ dpkg-buildpackage -us -uc -b -rfakeroot
ãã°ããããã¨ä½æ¥ãã£ã¬ã¯ããªã®ä¸ã¤ä¸ã«debãã§ããããã®ã§ãcommon 㨠full ãã¤ã³ã¹ãã¼ã«ããã
debian/changelog ã¯ç·¨éããªãã¦ãdebã¯ä½æããããã©ãã¾ãããã¯å¥½ã¿ã§ã
fancyindexã®è¨å®
ãªããããã¥ã¡ã³ãããããã«ããã£ããã§ã¾ã¨ãã
- fancyindex
- on ã«è¨å®ããã°ããã
- fancyindex_localtime
- on ã«ããã¨æ¥æããã¼ã«ã«æå»ã«ãªããoffãªãGMTã
- fancyindex_header
- ããã¥ã¡ã³ãã«ã¼ãããã®ãã¹ãè¨è¿°ããã¨ãããã«ã¢ã¯ã»ã¹ãåå¾ããå 容ã§ããããç½®ãæããã
- fancyindex_footer
- ããã¥ã¡ã³ãã«ã¼ãããã®ãã¹ãè¨è¿°ããã¨ãããã«ã¢ã¯ã»ã¹ãåå¾ããå 容ã§ããã¿ãç½®ãæããã
- fancyindex_css_href
- æå®ããcssã¸ã®ãã¹ãå ã«è¿½è¨ãããfancyindex_headerãè¨å®ããã¦ããã¨ãã¯ç¡è¦ãããã
- fancyindex_ignore
- ä¸è¦§è¡¨ç¤ºããé¤å¤(表示ããªã)ãããã®ãè¨è¿°ããã該å½ãã¡ã¤ã«åãæ£è¦è¡¨ç¾ã§è¨è¿°ããè¤æ°æå®ã¯ã¹ãã¼ã¹åºåãã
çæãããHTMLã¯ãããªæãã
(fancyindex_header)(表示ãã¦ãããã¹)</h1>(ãã¹ã®ä¸è¦§ãã¼ãã«)(fancyindex_footer)
ããã©ã«ãã®è¨å®ãããããããªã ngx-fancyindex/template.h ã«è¨è¿°ããã¦ããã®ã§ããããããã£ã¦makeããªããã
ã§ããã¡ãã¡makeããªããã¦ã¤ã³ã¹ãã¼ã«ãªãã¦ãã£ã¦ãããªããã§ããããã貪ããããªã fancyindex_header ãåçãã¼ã¸ã«ãã¦ãjavascriptã§HTMLããããã®ãããããããªããã¨æãã
kvmã§ã²ã¹ãOSã¨ãã¦Windows 7 64bitãå ¥ãã¦ã¿ã
ãã¹ãã¯Debian wheezyã§ãkernelã¯3.2.0-2-amd64ã
Windows7ã®ã¤ã³ã¹ãã¼ã«ã¾ã§ã¯åé¡ãªãã
ãã ç¾æç¹ã§ã¯USBã¡ã¢ãªã使ããªã(USB Storageãèªèãããªã)ã®ã¨é³ããããã«åçãããªãã
ã©ããã32bitã§ã¯ä¸¡æ¹åé¡ãªãã¿ããã§ã¡ãã£ã¨ã·ã§ãã¼ã³ããã£ã¨ãã®ãã¡æ¹åãããã«éããªãã¨æãããã
(2012/5/1追è¨)
ã¨æã£ã¦ãããpulseaudio使ã£ã¦ãå ´åã¯ç°å¢å¤æ° QEMU_AUDIO_DRV=pa ãè¨å®ããã°ããã¿ããã
ããã§é³ããããã«åçãããããã«ãªã£ãã
ãã¦ãUSBã¡ã¢ãªã使ããªãã¨ãªãã¨ãã¹ãã¨ã²ã¹ãéã§ãã¡ã¤ã«ã®ããã¨ãã«å°ãã
ãã¹ãå´ã®ãããã¯ã¼ã¯ããã¾ãããããããªãã®ã§-net userã§ä½¿ã£ã¦ãã®ãããã§ä»ã¨ãªãã
Windowsã«FTPã¨ãSSHãµã¼ãã¨ããããã®ããªãã ãªã¼ã¨æã£ã¦ãèãã¦ããsambaããããããªããã¨æãåºãã
ã²ã¹ãã«å ±æãã©ã«ãä½ã£ã¦ãkvmèµ·åãªãã·ã§ã³ã« -redir tcp:10139::139 ã¨ã足ãã¦ããã¹ããã
smbclient -p 10139 -I localhost //(ã²ã¹ãã®ãã·ã³å)/(å ±æå)
ãªæãã§ãCUIãã¼ã¹ã§ããã¨ãã§ããã
mgetã¨ãmputã¨ãæããããªãã
ããã¾ã§ãããsmbmountã§ãã£ã¨æ¥½ã§ããã®ã§ã¯ï¼ã¨æã£ããã©ãHost is downã¨ãã§ã¦ã¤ãªãããªãã
smbclintã¨ã¯å®è£
ãã¡ãã£ã¨éãã¿ããããã¼ãæ®å¿µã