今まで、写真関連とPC関連を分けて投稿していましたが、正直 運用が面倒になってきました。
なので、少しずつphoto.viasv.comの投稿を転載していこうと思います。
いずれ、photo.viasv.comのapacheは停止させよう。
手始めに、カメラ機材を整理したよ。
今まで、写真関連とPC関連を分けて投稿していましたが、正直 運用が面倒になってきました。
なので、少しずつphoto.viasv.comの投稿を転載していこうと思います。
いずれ、photo.viasv.comのapacheは停止させよう。
手始めに、カメラ機材を整理したよ。
Sonnar 50mm f/2のコピー品
ロシア製 Jupiter-8 Blackを調達
発注は終わったが、現物が届くのは月末になりそうだ。
すぐ自分の持ち物の詳細を忘れてしまうので、控えておく。
購入先のサイトから転載
やわらかくも力強い、オールド・ゾナーの写りを手軽に楽しめるロシア製レンズ。
各種ミラーレスカメラで撮影を楽しめます。レアな未開封新品です。
所持しているミラーレス 数年前のX-M1
偶然、見つけたオールドレンズIndustar-61 L/D 55mm f/2.8
購入先サイトから転載
旧ソビエト時代に作られたレンジファインダーカメラFED-5の標準レンズです。
優れた描画力で人気の単焦点レンズです。
参考にならない撮影結果
X-M1で初めてのマニュアル撮影で、ピンが何処に合わしたのか、自分でも不明w
室内撮影
暗くて、あまり参考にならない。ご容赦を・・・
ここからは、Industarを装着してみた感じ。Xperia Z3にて撮影
netatmo apiを利用してTemperatureを取得したので、自分の備忘として。
phpとpythonでデータ取得を試してみた。
phpでは、battery_vpの取得方法がわからん。
pythonでは、WeatherStationが複数ある場合、個々の取得方法がわからん。
今回は、1拠点のバッテリー数値の取得は、pythonで行い、温度はphpを使った。
netatmoのModule1が外部温度センサーに割り当てられbattery_vpがある。
この数値がイマイチよくわからない。
/*for raingauge and outdoor module*/
class NABatteryLevelModule
{
/* Battery range: 6000 … 3600 */
const BATTERY_LEVEL_0 = 5500;/*full*/
const BATTERY_LEVEL_1 = 5000;/*high*/
const BATTERY_LEVEL_2 = 4500;/*medium*/
const BATTERY_LEVEL_3 = 4000;/*low*/
/* below 4000: very low */
}
のように書かれているので、cactiでThresholdsを設定する。
値は、Warnigを4100、Alertを4500とした。
netatmo.php
#!/usr/bin/php <?php /** * Example of Weather station API * If you need more details, please take a glance at https://dev.netatmo.com/doc */ define('__ROOT__', dirname(dirname(__FILE__))); require_once (__ROOT__.'/src/Netatmo/autoload.php'); require_once 'Utils.php'; require_once 'Config.php'; /** * Prints a list of devices * */ function printDevices($devices, $title = NULL) { if(!is_null($devices) && is_array($devices) && !empty($devices)) { if(!is_null($title)) printMessageWithBorder($title); foreach($devices as $device) { printWSBasicInfo($device); } } } $scope = Netatmo\Common\NAScopes::SCOPE_READ_STATION; $config = array("client_id" => $client_id, "client_secret" => $client_secret, "username" => $test_username, "password" => $test_password); $client = new Netatmo\Clients\NAWSApiClient($config); //Authentication with Netatmo server (OAuth2) try { $tokens = $client->getAccessToken(); } catch(Netatmo\Exceptions\NAClientException $ex) { handleError("An error happened while trying to retrieve your tokens: " .$ex->getMessage()."\n", TRUE); } //Retrieve user's Weather Stations Information try { //retrieve all stations belonging to the user, and also his favorite ones $data = $client->getData(NULL, TRUE); // printMessageWithBorder("Weather Stations Basic Information"); } catch(Netatmo\Exceptions\NAClientException $ex) { handleError("An error occured while retrieving data: ". $ex->getMessage()."\n", TRUE); } if(empty($data['devices'])) { echo 'No devices affiliated to user'; } else { $users = array(); $friends = array(); $fav = array(); $device = $data['devices'][0]; $tz = isset($device['place']['timezone']) ? $device['place']['timezone'] : "GMT"; //devices are already sorted in the following way: first weather stations owned by user, then "friend" WS, and finally favorites stations. Still let's store them in different arrays according to their type foreach($data['devices'] as $device) { //favorites have both "favorite" and "read_only" flag set to true, whereas friends only have read_only if(isset($device['favorite']) && $device['favorite']) $fav[] = $device; else if(isset($device['read_only']) && $device['read_only']) $friends[] = $device; else $users[] = $device; } //print first User's device Then friends, then favorite printDevices($users, "User's weather stations"); // printDevices($friends, "User's friends weather stations"); // printDevices($fav, "User's favorite weather stations"); } ?>;
バッテリーデータを取得するのは、こんな感じで調整した。
print ($module['battery_vp'])."\n";
netatmo.shでデータ取得
netatmo.sh
#!/bin/sh cd /usr/share/cacti/site/scripts/netatmo-api/bin /usr/bin/php ./netatmo.php >/tmp/netatmo.data indoor=`cat /tmp/netatmo.data |sed -e '11,11!d'|cut -d' ' -f2` outdoor=`cat /tmp/netatmo.data |sed -e '29,29!d'|cut -d' ' -f2` indoorh=`cat /tmp/netatmo.data |sed -e '45,45!d'|cut -d' ' -f2` outdoorh=`cat /tmp/netatmo.data |sed -e '63,63!d'|cut -d' ' -f2` printf ' Indoor:'$indoor printf ' Outdoor:'$outdoor printf ' Indoorh:'$indoorh printf ' Outdoorh:'$outdoorh rm /tmp/netatmo.data exit 0
netatmo.py
#!/usr/bin/python3 # encoding=utf-8 # 2013-01 : philippelt@users.sourceforge.net # Just connect to a Netatmo account, and print internal and external temperature of the default (or single) station # In this case, sensors of the station and the external module have been named 'internal' and 'external' in the # Account station settings. import lnetatmo authorization = lnetatmo.ClientAuth() devList = lnetatmo.DeviceList(authorization) #print ("Current temperature (inside/outside/battry): %s / %s °C" % # ( devList.lastData()['Indoor']['Temperature'], # devList.lastData()['Outdoor']['Temperature']), # devList.lastData()['Outdoor']['battery_vp'] #) print "Inndoor:",devList.lastData()['Indoor']['Temperature'] print "Outdoor:",devList.lastData()['Outdoor']['Temperature'] print "Battery:",devList.lastData()['Outdoor']['battery_vp'] #print('External module battery : ', "OK" if int(devList.lastData()['Outdoor']['battery_vp']) > 5000 else "0" )
netatmo.sh
cd /usr/share/cacti/site/scripts/ python netatmo.py > /tmp/netatmo indoor=`cat /tmp/netatmo|grep Inndoor|cut -b10-` outdoor=`cat /tmp/netatmo|grep Outdoor|cut -b10-` batt=`cat /tmp/netatmo|grep Battery|cut -b10-` printf ' Indoor:'$indoor printf ' Outdoor:'$outdoor printf ' Battery:'$batt rm /tmp/netatmo exit 0
上に書いたソースを元に試行錯誤の結果このようなグラフで妥協した。
温度データは取得出来ているのだが、グラフが結構途切れてしまう。
先日の記事でYAMAHA WLX302 cacti templateのscriptを修正した。
前回は、curlで取得したHTTP DATAを加工して利用していたが、データの取得が不安定だった。
原因は特定していませんが、HTTPから取得する際にデータの取りこぼしがありました。
今回は、telenetを利用して取得していきます。
wlx302のtelnetは1ユーザーしか許可していない。
よって別端末からwlx302にtelnetでログインしていると、データは取得出来ません。
まずは、telnetにログインしてデータを取得するscriptを設置
使用しているwlx302のtelnetはloginIDとpasswdは設定していない。
設定している場合は、一番最初のechoのあとに、ID
次のechoの後に、passwdを入力
#!/bin/sh sleep 1;echo sleep 1;echo sleep 3;echo "show status wlan-controller ap list member" sleep 3;echo "show environment" sleep 1;echo exit
これを、wlxauto.shで保存し、telnetへパイプで渡す。sleepはネットワーク環境等で調整する。
/bin/sh /usr/share/cacti/site/scripts/wlxauto.sh |telnet 192.168.xxx.xxx Trying 192.168.xxx.xxx... Connected to 192.168.xxx.xxx. Escape character is '^]'. Password: WLX302 BootROM Ver.1.xx WLX302 Rev.12.xx.xx (Tue Jan 5 17:53:58 2016) Copyright (c) 1994-2015 Yamaha Corporation. All Rights Reserved. 00:a0:de:xx:xx:xx, 00:a0:de:xx:xx:xx, 00:a0:de:xx:xx:xx Memory 256Mbytes > > show status wlan-controller ap list member [00:a0:de:xx:xx:xx] Connection : -- Last update : Mar 30 09:14:24 2016 System name : WLX302_S44xxxxxx System location : IP address : 192.168.xxx.xxx [module1] Channel : 1 Transmit power rate : 100 Number of connection : 1 [module2] Channel : 36 Transmit power rate : 100 Number of connection : 3 > show environment WLX302 BootROM Ver.1.xx WLX302 Rev.12.xx.xx (Tue Jan 5 17:53:58 2016) main: WLX302 ver=00 serial=S44xxxxxx MAC-Address=00:a0:de:xx:xx:xx MAC-Addre ss=00:a0:de:xx:xx:xx MAC-Address=00:a0:de:xx:xx:xx CPU: 1%(5sec) 4%(1min) 4%(5min) Memory: 28% used Firmware: internal Config. file: 0 Boot time: 2016/03/25 21:52:58 +09:00 Current time: 2016/03/30 09:14:58 +09:00 Elapsed time from boot: 4days 11:22:00 Security Class: 1, FORGET: ON, TELNET: OFF Inside Temperature(C.): 36 Power: PoE State of cooperation: NONE > Connection closed by foreign host.
このようにデータが流れれば取得出来ている。
wlxget.shを書き直す。
データ加工はうまく書けないので、いじくり回した結果このようになりました。
/bin/sh /usr/share/cacti/site/scripts/wlxauto.sh |telnet 192.168.xxx.xxx > /tmp/wlxtelnetget.log wlxload=`cat /tmp/wlxtelnetget.log |sed -e '36,36!d'|cut -c29-30` wlxmem=`cat /tmp/wlxtelnetget.log |sed -e '36,36!d'|cut -c50-51` wlxtemp=`cat /tmp/wlxtelnetget.log |sed -e '42,42!d'|cut -c25-26` wlx24as=`cat /tmp/wlxtelnetget.log |sed -e '25,25!d'|cut -c24-25` wlx5as=`cat /tmp/wlxtelnetget.log | sed -e '29,29!d'|cut -c24-25` wlxload=`echo $wlxload` wlxmem=`echo $wlxmem` wlxtemp=`echo $wlxtemp` wlx24as=`echo $wlx24as` wlx5as=`echo $wlx5as` # wlxload:4 wlxmem:29 wlxtemp:38 wlx24as:1 wlx5as:4 #CPU (5sec) printf ' wlxload:'$wlxload printf ' wlxmem:'$wlxmem printf ' wlxtemp:'$wlxtemp printf ' wlx24as:'$wlx24as printf ' wlx5as:'$wlx5as rm /tmp/wlxtelnetget.log exit 0
走らせてみる。
$ sh wlxget.sh Connection closed by foreign host. wlxload:4 wlxmem:28 wlxtemp:36 wlx24as:1 wlx5as:3$