-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from newrelic/linuxMySql
Linux recipes for MySQL
- Loading branch information
Showing
9 changed files
with
817 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: MySQL Open Source Integration | ||
description: New Relic install recipe for default MySQL Open Source on-host integration (via Infra-Agent) | ||
repository: https://github.com/newrelic/nri-mysql | ||
|
||
installTargets: | ||
- type: host | ||
os: linux | ||
platform: "debian" | ||
- type: host | ||
os: linux | ||
platform: "ubuntu" | ||
|
||
# keyword convention for dealing with search terms that could land someone on this instrumentation project | ||
keywords: | ||
- Infrastructure | ||
- Integration | ||
- mysql | ||
|
||
# Examine Infrastructure events for correlated data | ||
processMatch: | ||
- mysql | ||
- mysqld | ||
|
||
# Matches partial list of the Log forwarding parameters | ||
# https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/forward-your-logs-using-infrastructure-agent#parameters | ||
logMatch: | ||
- name: mysql | ||
file: /var/log/mysql/mysqld.log | ||
- name: mysql-error | ||
file: /var/log/mysql/error.log | ||
attributes: | ||
logtype: mysql-error | ||
|
||
# NRQL the newrelic-cli will use to validate the agent/integration this recipe | ||
# installed is successfully sending data to New Relic | ||
validationNrql: "SELECT count(*) from MysqlSample where hostname like '{{.HOSTNAME}}' FACET entityGuid SINCE 10 minutes ago" | ||
|
||
# Prompts for input from the user. These variables then become | ||
# available to go-task in the form of {{.VAR_NAME}} | ||
inputVars: | ||
- name: "NR_CLI_DB_USERNAME" | ||
prompt: "Please enter your NR username below." | ||
- name: "NR_CLI_DB_PASSWORD" | ||
prompt: "Please enter your NR password below." | ||
secret: true | ||
- name: "NR_CLI_DB_HOSTNAME" | ||
prompt: "Please enter your MySQL hostname below. If none is provided, the default value: localhost, will be used." | ||
default: "localhost" | ||
- name: "NR_CLI_DB_PORT" | ||
prompt: "Please enter your MySQL port below. If none is provided, the default value: 3306, will be used." | ||
default: 3306 | ||
- name: "NR_CLI_DATABASE" | ||
prompt: "Please enter your MySQL database name below." | ||
|
||
install: | ||
version: "3" | ||
|
||
silent: true | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: create_user_notification | ||
- task: assert_pre_req | ||
- task: setup | ||
- task: restart | ||
|
||
create_user_notification: | ||
cmds: | ||
- | | ||
echo "_ Note: __ You need to have a MySQL user with replication permissions for enabling this integration. If you’d like to create a new user please use these commands as reference. _\n | ||
sudo mysql -e \"CREATE USER 'newrelic'@'localhost' IDENTIFIED BY 'YOUR_SELECTED_PASSWORD';\"\n | ||
sudo mysql -e \"GRANT REPLICATION CLIENT ON *.* TO 'newrelic'@'localhost' WITH MAX_USER_CONNECTIONS 5;\"\n | ||
sudo mysql -e \"GRANT SELECT ON *.* TO 'newrelic'@'localhost' WITH MAX_USER_CONNECTIONS 5;\"" | ||
assert_pre_req: | ||
cmds: | ||
- | | ||
SERVICE_EXIST=$(sudo systemctl status newrelic-infra.service | grep "Active" | wc -l) | ||
if [ $SERVICE_EXIST -eq 0 ]; then | ||
echo "The newrelic-infra agent service is NOT installed on the host, but is required to install this integration." >> /dev/stderr | ||
exit 1 | ||
fi | ||
- | | ||
CHECK_DB=$(mysql -u{{.NR_CLI_DB_USERNAME}} -p{{.NR_CLI_DB_PASSWORD}} -e "SHOW GRANTS FOR CURRENT_USER" | grep 'GRANT SELECT' | awk '{print $2, $3}') | ||
EXPECTED=$(echo 'SELECT, REPLICATION') | ||
if [ "$CHECK_DB" != "$EXPECTED" ] ; then | ||
echo -e "[Error]: Provided user has no access to the desired database.\n - See https://docs.newrelic.com/docs/integrations/host-integrations/host-integrations-list/mysql-monitoring-integration#config for more info." | ||
exit 2 | ||
fi | ||
setup: | ||
label: "Installing mysql integration..." | ||
cmds: | ||
- | | ||
sudo mkdir -p "/etc/newrelic-infra/integrations.d" | ||
- | | ||
sudo apt-get update | ||
- | | ||
sudo apt-get install nri-mysql -y | ||
- | | ||
if [ -f /etc/newrelic-infra/integrations.d/mysql-config.yml ]; then | ||
sudo rm /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
fi | ||
sudo cp /etc/newrelic-infra/integrations.d/mysql-config.yml.sample /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
- | | ||
sudo tee /etc/newrelic-infra/integrations.d/mysql-config.yml > /dev/null <<"EOT" | ||
integration_name: com.newrelic.mysql | ||
instances: | ||
- name: mysql-status | ||
command: status | ||
arguments: | ||
hostname: {{.NR_CLI_DB_HOSTNAME}} | ||
port: {{.NR_CLI_DB_PORT}} | ||
username: {{.NR_CLI_DB_USERNAME}} | ||
password: {{.NR_CLI_DB_PASSWORD}} | ||
database: {{.NR_CLI_DATABASE}} | ||
extended_metrics: true | ||
extended_innodb_metrics: true | ||
extended_myisam_metrics: true | ||
remote_monitoring: true | ||
EOT | ||
restart: | ||
cmds: | ||
- sudo systemctl restart newrelic-infra.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: MySQL Open Source Integration | ||
description: New Relic install recipe for default MySQL Open Source on-host integration (via Infra-Agent) | ||
repository: https://github.com/newrelic/nri-mysql | ||
|
||
installTargets: | ||
- type: host | ||
os: linux | ||
platform: amazonLinux | ||
platformVersion: "2" | ||
- type: host | ||
os: linux | ||
platform: "redhat" | ||
- type: host | ||
os: linux | ||
platform: "centos" | ||
|
||
# keyword convention for dealing with search terms that could land someone on this instrumentation project | ||
keywords: | ||
- Infrastructure | ||
- Integration | ||
- mysql | ||
|
||
# Examine Infrastructure events for correlated data | ||
processMatch: | ||
- mysqld | ||
|
||
# Matches partial list of the Log forwarding parameters | ||
# https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/forward-your-logs-using-infrastructure-agent#parameters | ||
logMatch: | ||
- name: mysql | ||
file: /var/log/mysqld.log | ||
|
||
# NRQL the newrelic-cli will use to validate the agent/integration this recipe | ||
# installed is successfully sending data to New Relic | ||
validationNrql: "SELECT count(*) from MysqlSample where hostname like '{{.HOSTNAME}}%' FACET entityGuid SINCE 10 minutes ago" | ||
|
||
# Prompts for input from the user. These variables then become | ||
# available to go-task in the form of {{.VAR_NAME}} | ||
inputVars: | ||
- name: "NR_CLI_DB_USERNAME" | ||
prompt: "Please enter your NR username below." | ||
- name: "NR_CLI_DB_PASSWORD" | ||
prompt: "Please enter your NR password below." | ||
secret: true | ||
- name: "NR_CLI_DB_HOSTNAME" | ||
prompt: "Please enter your MySQL hostname below. If none is provided, the default value: localhost, will be used." | ||
default: "localhost" | ||
- name: "NR_CLI_DB_PORT" | ||
prompt: "Please enter your MySQL port below. If none is provided, the default value: 3306, will be used." | ||
default: 3306 | ||
- name: "NR_CLI_DATABASE" | ||
prompt: "Please enter your MySQL database name below." | ||
|
||
install: | ||
version: "3" | ||
|
||
silent: true | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: create_user_notification | ||
- task: assert_pre_req | ||
- task: setup | ||
- task: restart | ||
|
||
create_user_notification: | ||
cmds: | ||
- | | ||
echo "_ Note: __ You need to have a MySQL user with replication permissions for enabling this integration. If you'd like to create a new user please use these commands as reference. _\n | ||
sudo mysql -e \"CREATE USER 'newrelic'@'localhost' IDENTIFIED BY 'YOUR_SELECTED_PASSWORD' WITH MAX_USER_CONNECTIONS 5;\"\n | ||
sudo mysql -e \"GRANT REPLICATION CLIENT ON *.* TO 'newrelic'@'localhost';\"\n | ||
sudo mysql -e \"GRANT SELECT ON *.* TO 'newrelic'@'localhost';\"" | ||
assert_pre_req: | ||
cmds: | ||
- | | ||
SERVICE_EXIST=$(sudo systemctl status newrelic-infra.service | grep "Active" | wc -l) | ||
if [ $SERVICE_EXIST -eq 0 ]; then | ||
echo "The newrelic-infra agent service is NOT installed on the host, but is required to install this integration." >> /dev/stderr | ||
exit 1 | ||
fi | ||
- | | ||
CHECK_DB=$(mysql -u{{.NR_CLI_DB_USERNAME}} -p{{.NR_CLI_DB_PASSWORD}} -e "SHOW GRANTS FOR CURRENT_USER" | grep 'GRANT SELECT' | awk '{print $2, $3}') | ||
EXPECTED=$(echo 'SELECT, REPLICATION') | ||
if [ "$CHECK_DB" != "$EXPECTED" ] ; then | ||
echo -e "[Error]: Provided user has no access to the desired database.\n - See https://docs.newrelic.com/docs/integrations/host-integrations/host-integrations-list/mysql-monitoring-integration#config for more info." | ||
exit 2 | ||
fi | ||
setup: | ||
label: "Installing mysql integration..." | ||
cmds: | ||
- | | ||
sudo mkdir -p "/etc/newrelic-infra/integrations.d" | ||
- | | ||
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra' | ||
- | | ||
sudo yum install nri-mysql -y | ||
- | | ||
if [ -f /etc/newrelic-infra/integrations.d/mysql-config.yml ]; then | ||
sudo rm /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
fi | ||
sudo cp /etc/newrelic-infra/integrations.d/mysql-config.yml.sample /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
- | | ||
sudo tee /etc/newrelic-infra/integrations.d/mysql-config.yml > /dev/null <<"EOT" | ||
integration_name: com.newrelic.mysql | ||
instances: | ||
- name: mysql-status | ||
command: status | ||
arguments: | ||
hostname: {{.NR_CLI_DB_HOSTNAME}} | ||
port: {{.NR_CLI_DB_PORT}} | ||
username: {{.NR_CLI_DB_USERNAME}} | ||
password: {{.NR_CLI_DB_PASSWORD}} | ||
database: {{.NR_CLI_DATABASE}} | ||
extended_metrics: true | ||
extended_innodb_metrics: true | ||
extended_myisam_metrics: true | ||
remote_monitoring: true | ||
EOT | ||
restart: | ||
cmds: | ||
- sudo systemctl restart newrelic-infra.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
name: MySQL Open Source Integration | ||
description: New Relic install recipe for default MySQL Open Source on-host integration (via Infra-Agent) | ||
repository: https://github.com/newrelic/nri-mysql | ||
|
||
installTargets: | ||
- type: host | ||
os: linux | ||
platformFamily: "suse" | ||
|
||
# keyword convention for dealing with search terms that could land someone on this instrumentation project | ||
keywords: | ||
- Infrastructure | ||
- Integration | ||
- mysql | ||
|
||
# Examine Infrastructure events for correlated data | ||
processMatch: | ||
- mysql | ||
- mysqld | ||
|
||
# Matches partial list of the Log forwarding parameters | ||
# https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/forward-your-logs-using-infrastructure-agent#parameters | ||
logMatch: | ||
- name: mysql | ||
file: /var/log/mysql/mysqld.log | ||
- name: mysql-error | ||
file: /var/log/mysql/error.log | ||
attributes: | ||
logtype: mysql-error | ||
|
||
# NRQL the newrelic-cli will use to validate the agent/integration this recipe | ||
# installed is successfully sending data to New Relic | ||
validationNrql: "SELECT count(*) from MysqlSample where hostname like '{{.HOSTNAME}}%' FACET entityGuid SINCE 10 minutes ago" | ||
|
||
# Prompts for input from the user. These variables then become | ||
# available to go-task in the form of {{.VAR_NAME}} | ||
inputVars: | ||
- name: "NR_CLI_DB_USERNAME" | ||
prompt: "Please enter your NR username below." | ||
- name: "NR_CLI_DB_PASSWORD" | ||
prompt: "Please enter your NR password below." | ||
secret: true | ||
- name: "NR_CLI_DB_HOSTNAME" | ||
prompt: "Please enter your MySQL hostname below. If none is provided, the default value: localhost, will be used." | ||
default: "localhost" | ||
- name: "NR_CLI_DB_PORT" | ||
prompt: "Please enter your MySQL port below. If none is provided, the default value: 3306, will be used." | ||
default: 3306 | ||
- name: "NR_CLI_DATABASE" | ||
prompt: "Please enter your MySQL database name below." | ||
|
||
install: | ||
version: "3" | ||
|
||
silent: true | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: create_user_notification | ||
- task: assert_pre_req | ||
- task: setup | ||
- task: restart | ||
|
||
create_user_notification: | ||
cmds: | ||
- | | ||
echo "_ Note: __ You need to have a MySQL user with replication permissions for enabling this integration. If you’d like to create a new user please use these commands as reference. _\n | ||
sudo mysql -e \"CREATE USER 'newrelic'@'localhost' IDENTIFIED BY 'YOUR_SELECTED_PASSWORD';\"\n | ||
sudo mysql -e \"GRANT REPLICATION CLIENT ON *.* TO 'newrelic'@'localhost';\"\n | ||
sudo mysql -e \"GRANT SELECT ON *.* TO 'newrelic'@'localhost';\"" | ||
assert_pre_req: | ||
cmds: | ||
- | | ||
SERVICE_EXIST=$(sudo systemctl status newrelic-infra.service | grep "Active" | wc -l) | ||
if [ $SERVICE_EXIST -eq 0 ]; then | ||
echo "The newrelic-infra agent service is NOT installed on the host, but is required to install this integration." >> /dev/stderr | ||
exit 1 | ||
fi | ||
- | | ||
CHECK_DB=$(mysql -u{{.NR_CLI_DB_USERNAME}} -p{{.NR_CLI_DB_PASSWORD}} -e "SHOW GRANTS FOR CURRENT_USER" | grep 'GRANT SELECT' | awk '{print $2, $3}') | ||
EXPECTED=$(echo 'SELECT, REPLICATION') | ||
if [ "$CHECK_DB" != "$EXPECTED" ] ; then | ||
echo -e "[Error]: Provided user has no access to the desired database.\n - See https://docs.newrelic.com/docs/integrations/host-integrations/host-integrations-list/mysql-monitoring-integration#config for more info." | ||
exit 2 | ||
fi | ||
setup: | ||
label: "Installing mysql integration..." | ||
cmds: | ||
- | | ||
sudo mkdir -p "/etc/newrelic-infra/integrations.d" | ||
- | | ||
sudo zypper -n ref -r newrelic-infra | ||
- | | ||
sudo zypper -n install nri-mysql | ||
- | | ||
if [ -f /etc/newrelic-infra/integrations.d/mysql-config.yml ]; then | ||
sudo rm /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
fi | ||
sudo touch /etc/newrelic-infra/integrations.d/mysql-config.yml; | ||
- | | ||
sudo tee -a /etc/newrelic-infra/integrations.d/mysql-config.yml > /dev/null <<"EOT" | ||
integration_name: com.newrelic.mysql | ||
instances: | ||
- name: mysql-status | ||
command: status | ||
arguments: | ||
hostname: {{.NR_CLI_DB_HOSTNAME}} | ||
port: {{.NR_CLI_DB_PORT}} | ||
username: {{.NR_CLI_DB_USERNAME}} | ||
password: {{.NR_CLI_DB_PASSWORD}} | ||
database: {{.NR_CLI_DATABASE}} | ||
extended_metrics: true | ||
extended_innodb_metrics: true | ||
extended_myisam_metrics: true | ||
remote_monitoring: true | ||
EOT | ||
restart: | ||
cmds: | ||
- sudo systemctl restart newrelic-infra.service |
Oops, something went wrong.