565 tutoriels disponibles
Chercher un tutoriel
Bienvenue
sur Shareannonce
 
Alert by push notification load server cpu high
Ecrit par: Shareannonce
Date création:  11-03-2020
Nombre de vues:  1644
Catégorie:  informatique > developpement > linux
Note: 
 
   Tutoriel N° 2e6

Alert by push notifications on iphone or android if your load server cpu high


1000 push notification free / month


This script need a web server with php


1/ Install Pushed apps

https://pushed.co/



2/ Create the shell script to execute with cron


nano /root/send_alert.sh

#!/bin/sh

load=$(cat /proc/loadavg | awk '{print $1}');
echo $load;

if [ "`echo "${load} > 2.0" | bc`" -eq 1 ]; then
echo "load > 2"
/bin/sh /home/push.sh

else
echo "load < 2"
fi




3/ Add in Cron daemon your shell script to execute all the 10 minutes


crontab -e

*/10 * * * * /bin/bash /root/send_alert.sh


nano /root/push.sh


#!/bin/sh

load=$(cat /proc/loadavg | awk '{print $1}');

# install pushed apps andget your code
curl -X POST -s
--form-string "app_key=XXXXXXXXXXXXXXX"
--form-string "app_secret=XXXXXXXXXXXXXXXXXX"
--form-string "target_type=app"
--form-string "content=Alert cpu: $load"
https://api.pushed.co/1/push


chmod 777 /root/push.sh




 
 
   Autres tutoriels de la même catégorie >
 
ShareAnnonce version 2.0 Tous droits reserves. | Condition d'utilisation | Contact