2014年12月30日 星期二

Python get supervisord process Info

import xmlrpclib
server = xmlrpclib.Server('http://localhost:9001/RPC2')
status_response = server.supervisor.getAllProcessInfo()
print status_response




References :
XML-RPC API Documentation — Supervisor 3.1.3 documentation

Python get gearman job queue status

import gearman
gm_admin_client = gearman.GearmanAdminClient(['localhost:4730'])
status_response = gm_admin_client.get_status()
print status_response




References :
1.3. gearman.admin_client — Gearman Admin client — python-gearman v2.0.2 documentation

2014年12月29日 星期一

FAN - Fully Automated Nagios

比較 :
OMD - Open Monitoring Distribution
Integrated tools :
  • Nagios : core monitoring application;
  • Nagios plug-ins : plug-ins to monitor different equipments;
  • Centreon : Web interface for Nagios (Centreon is one of the best for this purpose!);
  • NagVis : advanced mapping (geographical, functional, by services…);
  • NDOUtils : stores the Nagios data into a MySQL database;
  • NRPE : makes it possible to monitor the Windows servers (the NRPE daemon is not provided);
  • NaReTo (Nagios Reporting Tools): reporting tool (availability report).





FAN « Fully Automated Nagios

OMD - Open Monitoring Distribution

比較 :
FAN - Fully Automated Nagios

OMD 包含軟體 :
  • Nagios
  • Icinga
  • Shinken
  • NagVis
  • rrdtool/rrdcached
  • Check_MK
  • MK Livestatus
  • Multisite
  • Thruk
  • Mod-Gearman
  • check_logfiles
  • check_oracle_health
  • check_mysql_health
  • jmx4perl
  • check_webinject
  • check_multi

改進功能:
Livestatus and Livecheck

OMD Architecture :



References :
Open Monitoring Distribution
The Check_MK Monitoring System
Best Monitoring Solution - OMD (Nagios + Check_MK) | IT on Demand

Thruk

功能:
Multibackend monitoring webinterface

支援監控軟體:
Naemon, Nagios, Icinga, Shinken

Backend 協定:
Livestatus API




References :
Thruk Monitoring Webinterface

Nagios NagVis

功能:
使用地圖、拓撲圖、機櫃圖等背景照片顯示 Nagios 監控的主機狀態

支援的 Backends 協定:
mklivestatus, ndomy, ndo2fs, merlinmy

設定檔位置:
/etc/nagvis/nagvis.ini.php




References :
Backends
Use Shinken with Nagvis — Shinken Manual 2.2-RC1 documentation
[转]安装使用Nagvis插件 - OneCMDB中文

Composer - PHP Dependency Manager

Composer - PHP Dependency Manager

安裝 Composer
$ curl -sS https://getcomposer.org/installer | php
$ ls composer.phar

安裝 Composer 管理的專案
Composer 會讀取 composer.json 設定檔,並將函式庫安裝在 vendor/ 資料夾
$ php composer.phar install

2014年12月25日 星期四

aplay : unable to open slave

設定預設音效裝置
$ aplay -l
card 0: PCH [HDA Intel PCH], device 0: CX20590 Analog [CX20590 Analog]
  Subdevices: 1/1
  Subdevice #1: subdevice #0

一般爲 Analog 那一個 

# vi /etc/asound.conf
defaluts.pcm.card 1
defaults.pcm.device 0
defaults.ctl.card 1

pcm.!default {
    type plug
    slave.pcm "hw:1,0"
}



References :
ALSA で snd_pcm_dmix_open が unable to open slave になる場合 | 衣谷止の開発日誌

FullCalendar event background color

1. 在 event 指定 backgroundColor
backgroundColor: '#ED1317'


php - change the background color of the events in FullCalendar - Stack Overflow


2. 使用 CSS 修改
$(this).css('border-color', 'red');
eventClick - Documentation | FullCalendar

2014年12月23日 星期二

PHP echo json_encode error

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at )


origin :
...
echo json_encode($myarray);

fix :
...
header("Content-type: application/json; charset=utf-8");
echo json_encode($myarray);
die;









References :
Output.php with compress_output = true, always calls ob_start(‘ob_gzhandler’) causing warning with ajax / Forums / Community / EllisLab

fullcalendar rerender new calendar

function rerender_calendar(id, url)
{
    // clear all event
    $('#' + id).fullCalendar('removeEvents');

    // render new event
    $('#' + id).fullCalendar('addEventSource', url);
}




References :
javascript - rerendering events in fullCalendar after Ajax database update - Stack Overflow
removeEvents - Documentation | FullCalendar

2014年12月18日 星期四

2014年12月16日 星期二

Bonfire flash message

在 Controller 裏 Template::render 前使用 set_message:
Template::set_message('Your message displayed just fine.', 'success');

在 View 裏,欲顯示通知訊息的地方加入:
echo Template::message();


另一種手動的方法爲:

Controller :
$message['type'] = 'success';
$message['message'] = 'Your message displayed just fine.';
Template::set('message', $message);
View :
 <div class="alert alert-block alert-{type} fade in notification">
    <a data-dismiss="alert" class="close" href="#">×</a>
    <div>{message}</div>
</div>



 
References :
Docs - My Bonfire
Template::message problem - Bonfire Forums

git push to non bare repository

$ git config --bool receive.denyCurrentBranch false

$ vi .git/hooks/post-receive
# Update working tree after receiving pushed branch
echo "*****************************************************"
echo "Post-receive hook: updating remote working directory"
echo "*****************************************************"
cd ..
env -i git reset --hard

$ chmod +x .git/hooks/post-receive




References :
Quick 'n' Dirty Git Deployment

2014年12月9日 星期二

JavaScript count checkbox checked

alert(document.querySelectorAll('input[type="checkbox"]:checked').length);

alert(document.querySelectorAll('input[name="selectItem[]"]:checked').length);




References :
javascript - Count the number of checked checkboxes in html - Stack Overflow

2014年12月3日 星期三

symbol EC_GFp_nistp521_method, version OPENSSL_1.0.1 not defined in file libcrypto.so.1.0.0 with link time reference

# /etc/init.d/carbon-cache restart
cffi.ffiplatform.VerificationError: importing '/usr/lib/python2.7/dist-packages/cryptography/_Cryptography_cffi_36a40ff0x2bad1bae.x86_64-linux-gnu.so': /usr/lib/python2.7/dist-packages/cryptography/_Cryptography_cffi_36a40ff0x2bad1bae.x86_64-linux-gnu.so: symbol EC_GFp_nistp521_method, version OPENSSL_1.0.1 not defined in file libcrypto.so.1.0.0 with link time reference

# apt-get install libssl1.0.0

Python logging level

Level Numeric value
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0





References :
15.7. logging — Logging facility for Python — Python 2.7.9rc1 documentation