2018年9月22日 星期六

zabbix 繁體中文顯示常見問題

Zabbix 繁中支援修改

[root@centos75 include]# pwd
/var/www/html/zabbix/include

[root@centos75 include]# vi locales.inc.php


function getLocales() {
        return [
                'en_GB' => ['name' => _('English (en_GB)'),     'display' => true],
                'en_US' => ['name' => _('English (en_US)'),     'display' => true],
                'bg_BG' => ['name' => _('Bulgarian (bg_BG)'),   'display' => false],
                'zh_CN' => ['name' => _('Chinese (zh_CN)'),     'display' => true],
                'zh_TW' => ['name' => _('Chinese (zh_TW)'),     'display' => true],


=========================================================



Zabbix MAP 支援中文字顯示修改的方式


[root@centos75 fonts]# pwd
/var/www/html/zabbix/fonts

[root@centos75 fonts]# ls -la DejaVuSans.ttf
-rw-r--r-- 1 root root 756072 Sep 15 16:26 DejaVuSans.ttf

[root@centos75 fonts]# file DejaVuSans.ttf
DejaVuSans.ttf: TrueType font data

可以用任一種繁中 TrueType font 去取代  DejaVuSans.ttf 檔案即可

=============================================================

Zabbix MAP 字型大小修改處

[root@centos75 include]# pwd
/var/www/html/zabbix/include
[root@centos75 include]# vi maps.inc.php


imagetext($im, 8, 0,

$dims = imageTextSize(8, 0, $str);

==============================================================

Zabbix interface Traffic count32 count64

http://www.oidview.com/mibs/0/IF-MIB.html

count32

ifInOctets     1.3.6.1.2.1.2.2.1.10
ifOutOctets     1.3.6.1.2.1.2.2.1.16

count64

ifHCOutOctets     1.3.6.1.2.1.31.1.1.1.10
ifHCInOctets     1.3.6.1.2.1.31.1.1.1.6




F5 Using SNMP to view throughput statistics

https://support.f5.com/csp/article/K50309321




2018年7月19日 星期四

line webhook example


webhook.py

#!/bin/python3.6

from flask import Flask, request, abort

from linebot import (
    LineBotApi, WebhookHandler
)
from linebot.exceptions import (
    InvalidSignatureError
)
from linebot.models import (
    MessageEvent, TextMessage, TextSendMessage, ImageSendMessage
)

app = Flask(__name__)

# Channel Access Token
line_bot_api = LineBotApi('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=')
# Channel Secret
handler = WebhookHandler('XXXXXXXXXXXXXXXXXXXXX')

@app.route("/callback", methods=['POST'])
def callback():
    # get X-Line-Signature header value
    signature = request.headers['X-Line-Signature']

    # get request body as text
    body = request.get_data(as_text=True)
    app.logger.info("Request body: " +body)

    # handle webhook body
    try:
        handler.handle(body, signature)
    except InvalidSignatureError:
        abort(400)

    return 'OK'



@handler.add(MessageEvent, message=TextMessage)
def handle_message(event):
    message = TextSendMessage(text=event.message.text+" "+event.source.user_id+" ")
    print(message)
    #line_bot_api.reply_message(event.reply_token, message)

import os
if __name__ == "__main__":
    port = int(os.environ.get('PORT', 8888))
    app.run(host='0.0.0.0', port=port)

more example

https://github.com/line/line-bot-sdk-python

Install Python 3.6.X on CentOS 7


Install Python 3.6.X on CentOS 7

=======================================

yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36
yum -y install python36u-devel
yum -y install python36u-libs
yum -y install python36u-pip

pip3.6  install --upgrade pip
pip3.6  install  line-bot-sdk
pip3.6  install  simplejson
pip3.6  install  responses
pip3.6  install  flask

pip3.6 install pyinstaller

=====================================

Python Flask Test

test.py

#!/bin/python3.6

from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello from FLASK"

if __name__ == "__main__":
    app.run(host='127.0.0.1')

======================================

Apache Proxy Setting

proxy.conf

<VirtualHost *:80>
    <Proxy *>
        Order deny,allow
          Allow from all
    </Proxy>
    ProxyPreserveHost On
    <Location "/test">
          ProxyPass "http:///127.0.0.1:5000"
          ProxyPassReverse "http://127.0.0.1:5000"
    </Location>
</VirtualHost>

===========================================

https://www.pyinstaller.org/

PyInstaller Quickstart
Install PyInstaller from PyPI:

pip install pyinstaller

Go to your program’s directory and run:

pyinstaller yourprogram.py


This will generate the bundle in a subdirectory called dist.

For a more detailed walkthrough, see the manual.