Merge branch 'sensu_check' into 'master'
cinder-manage check
See merge request !13
diff --git a/sensu/files/checks/check_cinder_services.sh b/sensu/files/checks/check_cinder_services.sh
new file mode 100755
index 0000000..e294869
--- /dev/null
+++ b/sensu/files/checks/check_cinder_services.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+#check cinder service-list on ctls
+
+usage() {
+ echo "usage: ./check_cinder_services.sh -u <openstack.user> -p <openstack.password> -t <openstack.tenant> -h 'http://<openstack.host>:<openstack.port>/v2.0'"
+ exit 1
+}
+
+while getopts ":u:p:t:h:" opt; do
+ case $opt in
+ u)
+ user=${OPTARG};;
+ p)
+ passwd=${OPTARG};;
+ t)
+ tenant=${OPTARG};;
+ h)
+ host=${OPTARG};;
+ \? )
+ echo "Invalid option"
+ usage;;
+ : ) echo "Option -"$OPTARG" requires an argument." >&2
+ usage;;
+ esac
+done
+
+exit_critical() {
+ echo "CRITICAL: $*"
+ exit 2
+}
+
+exit_ok() {
+ echo "OK: $*"
+ exit 0
+}
+read -ra cinder_state <<< $(cinder --os-username $user --os-password $passwd --os-tenant-name $tenant --os-auth-url $host service-list)
+
+if [[ -z ${cinder_state[@]} ]]; then
+ exit_critical "Unknown error."
+fi
+
+read -ra cinder_state_down <<< $(cinder --os-username $user --os-password $passwd --os-tenant-name $tenant --os-auth-url $host service-list | head -n -1 | tr -d "|" | awk '/'down'/ {print "Service " $1 " on " $2 " is DOWN" ";"}')
+
+EXITVAL=0
+
+if [[ -n ${cinder_state_down[@]} ]]; then
+
+ read -ra scheduler_test <<< ${cinder_state_down[@]#cinder-scheduler}
+
+ if [ ${#cinder_state_down[@]} -ne ${#scheduler_test[@]} ]; then
+ EXITVAL=2
+ fi
+
+ read -ra volume_test <<< ${cinder_state_down[@]#cinder-volume}
+
+ if [ ${#cinder_state_down[@]} -ne ${#volume_test[@]} ]; then
+ EXITVAL=2
+ fi
+fi
+
+if [ $EXITVAL != 0 ]; then
+ exit_critical ${cinder_state_down[@]}
+else
+ exit_ok "All cinder services up."
+fi
\ No newline at end of file
diff --git a/sensu/files/checks/check_nova_services.sh b/sensu/files/checks/check_nova_services.sh
index 83347b3..e8dd8cd 100644
--- a/sensu/files/checks/check_nova_services.sh
+++ b/sensu/files/checks/check_nova_services.sh
@@ -1,6 +1,11 @@
#!/bin/bash
#check nova service-list on ctls
+usage() {
+ echo "usage: ./check_nova_services.sh -u <openstack.user> -p <openstack.password> -t <openstack.tenant> -h 'http://<openstack.host>:<openstack.port>/v2.0'"
+ exit 1
+}
+
while getopts ":u:p:t:h:" opt; do
case $opt in
u)
@@ -12,13 +17,33 @@
h)
host=${OPTARG};;
\?)
- echo "Invalid option";exit 1;;
+ echo "Invalid option"
+ usage;;
: ) echo "Option -"$OPTARG" requires an argument." >&2
- exit 1;;
+ usage;;
esac
done
-read -ra nova_state_down <<< $(nova --os-username $user --os-password $passwd --os-tenant-name $tenant --os-auth-url $host service-list | head -n -1 | tr -d "|" | awk '/'down'/ {print "Service " $2 " on " $3 " is DOWN" ";"}')
+exit_ok() {
+ echo "OK: $*"
+ exit 0
+}
+exit_warning() {
+ echo "WARNING: $*"
+ exit 1
+}
+exit_critical() {
+ echo "CRITICAL: $*"
+ exit 2
+}
+
+read -ra nova_state <<< $(nova --os-username $user --os-password $passwd --os-tenant-name $tenant --os-auth-url $host service-list)
+
+if [[ -z ${nova_state[@]} ]]; then
+ exit_critical "Unknown error"
+fi
+
+read -ra nova_state_down <<< $(nova --os-username $user --os-password $passwd --os-tenant-name $tenant --os-auth-url $host service-list | head -n -1 | tr -d "|" | grep enabled | awk '/'down'/ {print "Service " $2 " on " $3 " is DOWN" ";"}')
EXITVAL=0
@@ -45,25 +70,25 @@
read -ra scheduler_test <<< ${nova_state_down[@]#nova-scheduler}
if [ ${#nova_state_down[@]} -ne ${#scheduler_test[@]} ]; then
- EXITVAL=2
+ exit_critical ${nova_state_down[@]}
fi
read -ra conductor_test <<< ${nova_state_down[@]#nova-conductor}
if [ ${#nova_state_down[@]} -ne ${#conductor_test[@]} ]; then
- EXITVAL=2
+ exit_critical ${nova_state_down[@]}
fi
read -ra compute_test <<< ${nova_state_down[@]#nova-compute}
if [ ${#nova_state_down[@]} -ne ${#compute_test[@]} ]; then
- EXITVAL=2
+ exit_critical ${nova_state_down[@]}
fi
fi
-if [ $EXITVAL != 0 ]; then
- echo ${nova_state_down[@]}
+if [ $EXITVAL = 1 ]; then
+ exit_warning ${nova_state_down[@]}
+else
+ exit_ok "All nova services running."
fi
-
-exit $EXITVAL
diff --git a/sensu/files/checks/check_rabbitmq_stuck_nodes.sh b/sensu/files/checks/check_rabbitmq_stuck_nodes.sh
new file mode 100644
index 0000000..ba3d486
--- /dev/null
+++ b/sensu/files/checks/check_rabbitmq_stuck_nodes.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+#checks "rabbitmqctl eval 'rabbit_diagnostics:maybe_stuck().'" command.
+
+exit_critical() {
+ echo "CRITICAL: $*"
+ exit 2
+}
+exit_ok() {
+ echo "OK: $*"
+ exit 0
+}
+
+read -ra rabbit_eval <<< $(sudo rabbitmqctl eval 'rabbit_diagnostics:maybe_stuck().' | grep -o "Found "." suspicious processes.")
+if [[ -n ${rabbit_eval[@]} ]]; then
+ if [[ ${rabbit_eval[1]} -eq 0 ]]; then
+ exit_ok ${rabbit_eval[@]}
+ else
+ exit_critical ${rabbit_eval[@]}
+ fi
+else
+ exit_critical "rabbit_diagnostic failed"
+fi
+
diff --git a/sensu/files/sudoer b/sensu/files/sudoer
index 158af54..a5853df 100644
--- a/sensu/files/sudoer
+++ b/sensu/files/sudoer
@@ -6,3 +6,4 @@
sensu ALL=(ALL) NOPASSWD: /usr/bin/supervisorctl *status
sensu ALL=(ALL) NOPASSWD: /usr/sbin/gluster volume status*
sensu ALL=(ALL) NOPASSWD: /usr/local/sbin/duplicity_salt.sh nagios *
+sensu ALL=(ALL) NOPASSWD: /usr/sbin/rabbitmqctl *rabbit_diagnostics*maybe_stuck()*