2018年 の投稿一覧

Muninでnginx_requestとnginx_statusがグラフに表示されない( ConohaVPS )

ConohaVPSで動かしているPythonアプリサーバー( Flask + OpenCV + nginx )を監視しようとおもい、久しぶりにMuninをインストールしたけどnginx_requestとnginx_statusがグラフに表示されない。

NginxのTest


curl http://localhost/nginx_status

403 Forbiddenになっていた。


location /nginx_status {
       stub_status on;
       access_log off;
       allow 127.0.0.1;
       deny all;
}

一見問題なさそうだけど
localhostにpingしたら「localhost6.localdomain6」になるのか。。


root@ocv-py3-ub:ping localhost
PING localhost(localhost6.localdomain6 (::1)) 56 data bytes
64 bytes from localhost6.localdomain6 (::1): icmp_seq=1 ttl=64 time=0.024 ms
^C
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms

「::1」をallowしたら表示された。


location /nginx_status {
       stub_status on;
       access_log off;
       allow 127.0.0.1;
       allow ::1;
       deny all;
}


root@ocv-py3-ub:~# curl http://localhost/nginx_status
Active connections: 1
server accepts handled requests
 106160 106160 108272
Reading: 0 Writing: 1 Waiting: 0

次にMuninのNginxプラグインをテスト


root@ocv-py3-ub:~#/usr/sbin/munin-run nginx_request
Use of uninitialized value $LWP::VERSION in sprintf at /etc/munin/plugins/nginx_request line 108.
Can't locate object method "new" via package "LWP::UserAgent" at /etc/munin/plugins/nginx_request line 108.
root@ocv-py3-ub:~#

「LWP::UserAgent」がない。。


root@ocv-py3-ub:~#sudo apt install libwww-perl

プラグインも動くようになった。


root@ocv-py3-ub:~#/usr/sbin/munin-run nginx_request
request.value 108282

よく使うComposerライブラリ

短いハッシュを生成するライブラリJavaなどもある。
ShortHash
https://github.com/ivanakimov/hashids.php
Install
composer require hashids/hashids

ランダム値の生成
Random
https://github.com/antonioribeiro/random
Install
composer require pragmarx/random

バリデーション
Validetion
https://github.com/Respect/Validation
Install
composer require respect/validation

LaravelのORM
Eloquent ORM
https://github.com/illuminate/database
Install
illuminate/database

ルーター
https://github.com/nikic/FastRoute
Install
composer require nikic/fast-route

キャッシュ
https://github.com/tedious/stash
Install
composer require tedivm/stash
Document
https://github.com/tedious/stash

Android adbをWi-Fi接続

ケーブルをつないで、IPアドレスを調べる。


$ adb shell ipconfig
* daemon not running; starting now at tcp:5037
* daemon started successfully
/system/bin/sh: ipconfig: not found
RC211v-mbp:~ yuta$ adb shell ifconfig
lo        Link encap:UNSPEC  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope: Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1235 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:1235 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:0 
          RX bytes:111363 TX bytes:111363 

wlan0     Link encap:UNSPEC  
          inet addr:172.16.20.19  Bcast:172.16.255.255  Mask:255.255.0.0 

tcpip <任意のポート>


$ adb tcpip 12345
restarting in TCP mode port: 12345

connect <上記の任意のポート>


$ adb connect 172.16.20.19:12345
connected to 172.16.20.19:12345

USBケーブル、Wifiそれぞれで接続ができている。


$ adb devices
List of devices attached
172.16.20.19:12345  device
P3P7N17500000000    device

cordova-iconコマンドで”throw er; // Unhandled ‘error’ event”

Cordovaでリリースアプリのアイコンを一括登録しようと、npmのcordova-iconを使ったらエラーになった。


yuta$ cordova-icon --config=config.xml --icon=www/icon.png 

Checking Project & Icon

✓ platforms found: android
✓ www/icon.png exists
✓ config.xml exists

Generating Icons for android

events.js:160
throw er; // Unhandled 'error' event
^

Error: spawn convert ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

image Magickインストールするの忘れてた。。


brew install imagemagick