0102 | MRTG monitoring script for nginx

สร้างไฟล์ /root/bin/mrtg-nginx.pl ข้อมูลตามนี้

#!/usr/bin/perl
# $Revision: 2 $
# $Date: 2008-09-12 15:11:40 +0300 (Fri, 12 Sep 2008) $
 
my %opt = (
# http link to nginx stub_status, be sure turn on stub_status in nginx conf
    nginx_status   => 'http://localhost:80/status',
# path for program what may dump web page, normaly lynx -dump
#    lynx            => 'lynx -dump',
    lynx            => 'wget -q -Y off -O -',
);
 
$opt{var} = $ARGV[0] if $ARGV[0];
$opt{nginx_status} = $ARGV[1] if $ARGV[1] and $ARGV[1]=~/^http:\/\/\w+/;
$opt{var} ||= '';
 
my $do = `$opt{lynx} $opt{nginx_status}`;
 
if ($opt{var} eq 'req') {
    $do=~/^Active connections:\s*(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do";
    $opt{d2} = $opt{d1} = $1;
}
elsif ($opt{var} eq 'con') {
    $do=~/^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/ms or warn "Error! Can't find data!\nIN :\n$do";
    $opt{d2} = $opt{d1} = $3;
}
#elsif { $do=~/^Reading:\s+(\d+).*Writing:\s+(\d+).*Waiting:\s+(\d+)/; }
else {
    $opt{var} = 'ERROR';
    $opt{d2} = $opt{d1} = 0;
    warn "Error! Please read the help and set (req|con)\n";
}
 
print "$opt{d1}\n";
print "$opt{d2}\n";
#print "$opt{up}\n" if $opt{up};
print "Nginx $opt{var}\n";

เสร็จแล้วสั่ง
chmod a+x /root/bin/mrtg-nginx.pl
ให้รันได้

แล้วเอาไอ้นี่ไปใส่ใน nginx.conf ส่วนของ vhost นะครับ

location /status {
    stub_status on;
    access_log off;
}

แล้วก็… อันนี้เอาไปใส่ใน mrtg.cfg

Target[nginx.newconns]: `/root/bin/mrtg-nginx.pl con`
Title[nginx.newconns]: NGINX Connections
PageTop[nginx.newconns]: <H1>NGINX Connections</H1>
MaxBytes[nginx.newconns]: 10000000000
ShortLegend[nginx.newconns]: c/s
YLegend[nginx.newconns]: Conns / sec
LegendI[nginx.newconns]: In
LegendO[nginx.newconns]:
Legend1[nginx.newconns]: New inbound connections
Legend2[nginx.newconns]:
Options[nginx.newconns]: growright,nopercent
 
Target[nginx.requests]: `/root/bin/mrtg-nginx.pl req`
Title[nginx.requests]: NGINX Requests
PageTop[nginx.requests]: <H1>NGINX Requests</H1>
MaxBytes[nginx.requests]: 10000000000
ShortLegend[nginx.requests]: req
YLegend[nginx.requests]: Req
LegendI[nginx.requests]: In
LegendO[nginx.requests]:
Legend1[nginx.requests]: New inbound connections
Legend2[nginx.requests]:
Options[nginx.requests]: growright,nopercent,gauge

Tags: ,

0101 | Delux Wireless Keyboard + Mouse

แหะๆ มาแปะเรื่องไร้สาระอีกแล้ว

พอดีเมื่อวาน จอ dell LED 24″ ที่สั่งไปเพิ่งมาถึง เลยประเดิมครับ !
แล้ว mouse ปากกา พอ extend จอปุ๊ปมันเอ๋อ แถมไม่มี mouse ในห้องเลย
บวกกะกำลังเตรียมการทำอะไรนิดหน่อยด้วย เลยต้องไปหา keyboard+mouse ใหม่มา
ก็เลยได้ไอ้นี่มาครับ



เป็น keyboard mouse ไร้สายของ delux ราคา 899 บาท หน้าตาถูกใจมาก
keyboard ปุ่มแบนแบบ notebook กดง่ายดี แถมมีซิลิโคนกันฝุ่นกันน้ำสำหรับรุ่นนี้ให้ด้วย
เหมาะสำหรับคนทำอะไรๆ บนโต๊ะคอมอย่างผมมาก…

เอ่อ… อะไรๆ ที่ว่าหมายถึงเอาของกินมากินครับ -*-‘

ส่วน mouse เป็น blue optical ไฟสีสวยดี
แต่ขนาดเล็กไปนิดนึง คนที่ใหญ่ๆ ยาวๆ อย่างผมใช้ลำบากไปหน่อย
… ผมพูดถึงมือกับนิ้วนะ ถึงอย่างอื่นจะใหญ่สมส่วนตามกันด้วยก็เหอะ

อ๊ะ… ไปถึงไหนละเนี่ย
อ้อ ตัวรับ… อันกะตึ๋งนึงตามนี้ครับ เวลาเก็บก็เสียบไว้ที่ตูด mouse ได้ จะได้ไม่หาย

ใช้สัญญาณ 2.4GHz แบต AAA x 2 ทั้ง mouse ทั้ง keyboard
ตอนนี้กำลังทดสอบอยู่ว่าแบตจะอยู่ได้นานขนาดไหน

ระยะการใช้งานโฆษณาไว้ที่ 10 เมตร… เอาเป็นว่าผมถือเล่นรอบห้องสบายๆ
ยังไม่เจอปัญหาสัญญาณหาย

ทดสอบกับการเล่น O2JAM พบว่า มันกดพร้อมกันได้ 6 ปุ่ม T_T
เจอเพลงที่โน๊ตลงมา 7 ปุ่มปุ๊ป ดับอนาถเลย T_T กระซิกๆ

โดยรวมก็โอเคแหละครับ สนุกมือดี เวลาเล่นเกมก็เอาซิลิโคนออกจะกดได้มันส์มือมากขึ้นเยอะ

ข้อเสียเดียวที่เจอตอนนี้คือ… มันไม่มีปุ่ม skip เพลง

Tags: , , ,