CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;複製代碼
2.2.SonarQube安裝
php
cd /data/package/
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.6.zip
mkdir /data/service/sonar/
unzip sonarqube-6.6.zip -d /data/service/sonar/複製代碼
[root@c7-node1 ~]# cat /etc/init.d/sonar
#!/bin/sh
#
# rc file for SonarQube
#
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
#
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO
/usr/bin/sonar $*複製代碼
chmod +x /etc/init.d/sonar
ln -s /data/service/sonar/sonarqube-6.6/bin/linux-x86-64/sonar.sh /usr/bin/sonar
chkconfig sonar on複製代碼
[root@c7-node1 ~]# cd /data/service/sonar/sonarqube-6.6/conf/
[root@c7-node1 conf]# cp sonar.properties{,.bak}
sonar.jdbc.username=sonar
sonar.jdbc.password=123456
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false複製代碼
cd /data/package/
wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip
unzip sonar-scanner-2.8.zip -d /data/service/sonar/
ln -s /data/service/sonar/sonar-scanner-2.8/bin/sonar-scanner /usr/bin/sonar-scanner複製代碼
[root@c7-node1 ~]# cd /data/service/sonar/sonar-scanner-2.8/conf/
[root@c7-node1 conf]# cp sonar-scanner.properties{,.bak}
[root@c7-node1 conf]# vim sonar-scanner.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=123456
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8複製代碼
cd /data/service/
wget http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip
unzip sonar-runner-dist-2.4.zip -d /data/service/sonar/
ln -s /data/service/sonar/sonar-runner-2.4/bin/sonar-runner /usr/bin/sonar-runner複製代碼
[root@c7-node1 ~]# cd /data/service/sonar/sonar-runner-2.4/conf/
[root@c7-node1 conf]# cp sonar-runner.properties{,.bak}
[root@c7-node1 conf]# vim sonar-runner.properties
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.username=sonar
sonar.jdbc.password=123456複製代碼
[root@c7-node1 ~]# vim /etc/profile.d/sonar.sh
export SONAR_HOME=/data/service/sonar/sonarqube-6.6
export SONAR_RUNNER_HOME=/data/service/sonar/sonar-runner-2.4
export PATH=$SONAR_RUNNER_HOME/bin:$PATH
[root@c7-node1 ~]# source /etc/profile.d/sonar.sh複製代碼
[root@c7-node1 ~]# useradd sonar
[root@c7-node1 ~]# chown -R sonar:sonar /data/service/sonar/
[root@c7-node1 ~]# su sonar
[sonar@c7-node1 root]$ /etc/init.d/sonar start複製代碼
git clone https://github.com/SonarQubeCommunity/sonar-l10n-zh.git
cd sonar-l10n-zh/
git checkout sonar-l10n-zh-plugin-1.18
mvn package
cp target/sonar-l10n-zh-plugin-1.18-SNAPSHOT.jar /data/service/sonar/sonarqube-6.6/extensions/plugins/複製代碼
[sonar@c7-node1 ~]$ cat python_test/sendEmail.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import smtplib
from email.mime.text import MIMEText
from email.header import Header
# 第三方 SMTP 服務
mail_host="xxx" #設置服務器
mail_user="xxx" #用戶名
mail_pass="xxx" #口令
sender = 'bigdata_monitor@xueleyun.com'
receivers = sys.argv[1]
content=sys.argv[3]
message = MIMEText(content, 'plain', 'utf-8')
message['From'] = Header(sender, 'utf-8')
message['To'] = Header(receivers, 'utf-8')
subject = sys.argv[2]
message['Subject'] = Header(subject, 'utf-8')
try:
smtpObj = smtplib.SMTP()
smtpObj.connect(mail_host, 25) # 25 爲 SMTP 端口號
smtpObj.login(mail_user,mail_pass)
smtpObj.sendmail(sender, receivers, message.as_string())
print "郵件發送成功"
except smtplib.SMTPException:
print "Error: 沒法發送郵件"複製代碼
[sonar@c7-node1 ~]$ cat python_test/sonar-project.properties
sonar.projectKey=python_test
sonar.projectName=python_test
sonar.projectVersion=1.0
sonar.sources=.
sonar.sourceEncoding=UTF-8複製代碼
|
sonar-scanner複製代碼
|
文章系做者原創投稿。做者:西門飛冰,一名90後it男,一直在北京工做,熱愛運動,熱愛冒險,熱愛旅行。 原文地址:http://www.fblinux.com/?p=1155。
使用 zabbix 監控 tomcat(包含jvm監控)python
怎麼選?畢竟能夠上網的瀏覽器只剩下四款了...mysql
想要高可用?搞定負載均衡架構是關鍵linux