Login

Statistici

Membri: 188
Stiri: 1019
Linkuri: 24
Vizitatori: 1639734

Mirror MYLRo.org

Carti Linux direct de pe mirror-ul MYLRo.org
 
Reporneste MYSQL in mod automat E-mail
  • Currently 4.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rating: 4.0/5 (1 votes cast)

Scris de Cypress   
Saturday, 15 December 2007
#!/bin/bash
# Shell script to restart MySQL server if it is killed or not working # due to ANY causes. # When script detects mysql is not running (it basically sends ping request # to MySQL) it try to start using /etc/init.d/mysql script; and it sends an # email to user indicating the status. # This script must be run from Cron Job so that it can monitor mysql server. # mysql root/admin username MUSER="root" # mysql admin/root password MPASS="SET-ROOT-PASSWORD" # mysql server hostname MHOST="localhost" #Shell script to start MySQL server i.e. path to MySQL daemon start/stop script. # Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS. MSTART="/etc/init.d/mysql start" # Email ID to send notification EMAILID=" Aceasta adresa e-mail este protejata impotriva spamului, JavaScript trebuie activat pentru a putea vizualiza pagina. " # path to mail program MAILCMD="$(which mail)" # path mysqladmin MADMIN="$(which mysqladmin)" #### DO NOT CHANGE anything BELOW #### MAILMESSAGE="/tmp/mysql.fail.$$" # see if MySQL server is alive or not # 2&1 could be better but i would like to keep it simple and easy to # understand stuff :) $MADMIN -h $MHOST -u $MUSER -p${MPASS} ping 2>/dev/null 1>/dev/null if [ $? -ne 0 ]; then echo "" >$MAILMESSAGE echo "Error: MySQL Server is not running/responding ping request">>$MAILMESSAGE echo "Hostname: $(hostname)" >>$MAILMESSAGE echo "Date & Time: $(date)" >>$MAILMESSAGE # try to start mysql $MSTART>/dev/null # see if it is started or not o=$(ps cax | grep -c ' mysqld$') if [ $o -eq 1 ]; then sMess="MySQL Server MySQL server successfully restarted" else sMess="MySQL server FAILED to restart" fi # Email status too echo "Current Status: $sMess" >>$MAILMESSAGE echo "" >>$MAILMESSAGE echo "*** This email generated by $(basename $0) shell script ***" >>$MAILMESSAGE echo "*** Please don't reply this email, this is just notification email ***" >>$MAILMESSAGE # send email $MAILCMD -s "MySQL server" $EMAILID < $MAILMESSAGE else # MySQL is running :) and do nothing : fi # remove file rm -f $MAILMESSAGE
Comments
Add NewSearchRSS
Only registered users can write comments!

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.


 

Ultimele comentarii

Tips & Tricks

Foloseste aceeasi partitie SWAP in Linux si Windows
Daca esti in lipsa de spatiu si doresti sa folosesti aceeasi partitie swap si in Linux si in Windows, poti sa faci urmatorul truc:
1. Formateaza partitia ca si partitie DOS si creaza fisierul SWAP Windows pe ea, dar nu rula inca sistemul de operare.
2. Booteaza in Linux si s alveaza partitia intr-un fisier. Presupunand ca partitia swap se afla pe /dev/hda5, vom face
dd if=/dev/hda5 of=/etc/dosswap
3. Comprima fisierul dosswap:
gzip -9 /etc/dosswap
4. Adauga urmatoarele in fisierul /etc/rc pentru a pregati si instala swap-ul in Linux. XXXXX este numarul de blocuri din partitia swap:
mkswap /dev/hda5 XXXXX
swapon -av   

5. Adauga partitia in /etc/fstab
 

Vizitatori Online

Avem 2 vizitatori online

Doneaza pentru un banner MYLRo.org pe Distrowatch

Introdu o suma de macar 5$ (astfel incat suma donata sa fie cu ceva mai mare decat taxa de transfer PayPal) si trimite-mi un mail cu un link catre site-ul tau. Link-ul va fi afisat pe mainpage-ul MYLRo.org si 90% din paginile aferente site-ului pe intreaga perioada a hostarii bannerului de pe DistroWatch.