-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding customtimeout plugin and mongod and nginx
- Loading branch information
1 parent
e86752b
commit 148df09
Showing
13 changed files
with
200 additions
and
10 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
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,7 @@ | ||
--- | ||
alerta_plugins: | ||
- customtimeout-0.0.2 | ||
|
||
prometheus_ip: "127.0.0.1" | ||
|
||
nginx_version: "1.10.2-1" |
Binary file not shown.
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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
--- | ||
|
||
- name: restart nginx | ||
service: name=nginx state=restarted | ||
service: name=nginx state=restarted enabled=yes | ||
|
||
- name: restart uwsgi | ||
service: name=uwsgi state=restarted enabled=yes | ||
|
||
- name: restart mongod | ||
service: | ||
name: mongod | ||
enabled: yes | ||
state: restarted |
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
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,27 @@ | ||
--- | ||
- name: mongodb | Install pymongo and mongodb | ||
yum: | ||
name: "{{ item }}" | ||
state: present | ||
notify: restart mongod | ||
with_items: | ||
- pymongo | ||
- "https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/3.4/x86_64/RPMS/mongodb-org-3.4.4-1.el7.x86_64.rpm" | ||
- "https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-mongos-3.4.4-1.el7.x86_64.rpm" | ||
- "https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-server-3.4.4-1.el7.x86_64.rpm" | ||
- "https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-shell-3.4.4-1.el7.x86_64.rpm" | ||
- "https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/RPMS/mongodb-org-tools-3.4.4-1.el7.x86_64.rpm" | ||
|
||
- name: mongodb | Create DB directory | ||
file: path=/data/mongodb state=directory owner=mongod group=mongod | ||
|
||
- name: mongodb | Configure mongodb | ||
template: src=mongodb.conf.j2 dest=/etc/mongod.conf owner=mongod group=mongod backup=yes mode=0644 | ||
notify: restart mongod | ||
|
||
- name: start mongod | ||
service: | ||
name: mongod | ||
enabled: yes | ||
state: started | ||
|
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,18 @@ | ||
--- | ||
- name: nginx | Install nginx | ||
yum: | ||
name: | ||
- libselinux-python | ||
- nginx-{{ nginx_version }}.el7.x86_64 | ||
state: present | ||
|
||
- name: nginx | Configure nginx.conf | ||
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf | ||
notify: restart nginx | ||
|
||
- name: nginx | start nginx | ||
service: | ||
name: nginx | ||
enabled: yes | ||
state: started | ||
|
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 @@ | ||
* * * * * root /usr/bin/mongo --quiet monitoring /usr/local/bin/housekeepingAlerts.js |
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
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,25 @@ | ||
// housekeepingAlerts.js | ||
|
||
now = new Date(); | ||
|
||
// mark timed out alerts as EXPIRED and update alert history | ||
db.alerts.aggregate([ | ||
{ $project: { event: 1, status: 1, lastReceiveId: 1, timeout: 1, expireTime: { $add: [ "$lastReceiveTime", { $multiply: [ "$timeout", 1000 ]} ]} } }, | ||
{ $match: { status: { $ne: 'expired' }, expireTime: { $lt: now }, timeout: { $ne: 0 }}} | ||
]).forEach( function(alert) { | ||
db.alerts.update( | ||
{ _id: alert._id }, | ||
{ | ||
$set: { status: 'expired' }, | ||
$push: { | ||
history: { | ||
event: alert.event, | ||
status: 'expired', | ||
text: "alert timeout status change", | ||
id: alert.lastReceiveId, | ||
updateTime: now | ||
} | ||
} | ||
}, false, true); | ||
}) | ||
|
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,12 @@ | ||
auth=False | ||
logpath={{mongodb_conf_logpath | default("/var/log/mongodb/mongodb.log")}} | ||
logappend={{mongodb_conf_logappend | default("true") }} | ||
fork={{mongodb_conf_fork | default("true") }} | ||
dbpath=/data/mongodb | ||
pidfilepath={{mongodb_conf_pidpath | default("/var/run/mongodb/mongod.pid")}} | ||
bind_ip={{mongodb_conf_bind_ip | default("127.0.0.1") }} | ||
nojournal={{mongodb_conf_nojournal | default("false")}} | ||
port={{mongodb_conf_port | default(27017)}} | ||
rest={{mongodb_conf_rest | default("false") }} | ||
smallfiles={{mongodb_conf_smallfiles | default("false")}} | ||
|
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,32 @@ | ||
user nginx; | ||
worker_processes auto; | ||
error_log /var/log/nginx/error.log; | ||
pid /run/nginx.pid; | ||
|
||
# Load dynamic modules. See /usr/share/nginx/README.dynamic. | ||
include /usr/share/nginx/modules/*.conf; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
# Load modular configuration files from the /etc/nginx/conf.d directory. | ||
# See http://nginx.org/en/docs/ngx_core_module.html#include | ||
# for more information. | ||
include /etc/nginx/conf.d/*.conf; | ||
} | ||
|
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