forked from prbolla-zz/DevOpsBasics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts for monitoring
More file actions
40 lines (23 loc) · 803 Bytes
/
scripts for monitoring
File metadata and controls
40 lines (23 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#!/bin/bash
service nginx status > output.txt
if grep -q "running" output.txt; then
echo "The Nginx service is running"
else
service nginx start
echo "The Nginx service was stopped, errored, or inactive. The service has been started." | mail -s "The Nginx service was stopped" myemailaddress@mydomain.com;
fi
sudo rm -f output.txt
2nd example
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#!/bin/bash
service nginx status > output.txt
if grep -q "running" output.txt; then
echo "The Nginx service is running"
else
service nginx start
echo "The Nginx service was stopped, errored, or inactive. The service has been started." | mail -s "The Nginx service was stopped" myemailaddress@mydomain.com;
fi
sudo rm -f output.txt