Difference between revisions of "Scripts"

From Server Knowledge Base
Jump to navigationJump to search
(Created page with "These are also located at http://serverkb.co.uk/tools/ Read the README.txt for further information on these tools. == [http://serverkb.co.uk/tools/accounts.sh Plesk Accounts...")
 
m
Line 12: Line 12:
Written by [[User:Leon_Teale | Leon Teale]], modified by Byron Galietta and Sam Teale.
Written by [[User:Leon_Teale | Leon Teale]], modified by Byron Galietta and Sam Teale.


== [http://serverkb.co.uk/tools/apachemon.sh Apache Monitor] (2) ==
== [http://serverkb.co.uk/tools/apachemon.sh Apache Monitor] (3) ==


This script will start a specific service that you specify. By default it will do Apache, the Linux web server. To use it, do the following:
This script will start a specific service that you specify. By default it will do Apache, the Linux web server. To use it, do the following:
Line 37: Line 37:
And then change all references to that service e.g. change apachedown to mysqldown
And then change all references to that service e.g. change apachedown to mysqldown


== [http://serverkb.co.uk/tools/dbandtarEmailDump.sh Plesk server database backups] (6) ==
== [http://serverkb.co.uk/tools/dbandtarEmailDump.sh Plesk server database backups] (7) ==


This backs up all databases as .sql files and a .tar.gz containing all excluding information_schema, atmail and horde on a '''Plesk''' Linux server and emails you them.
This backs up all databases as .sql files and a .tar.gz containing all excluding information_schema, atmail and horde on a '''Plesk''' Linux server and emails you them.


=== [http://serverkb.co.uk/tools/dbonlyEmailDump.sh Only .sql files] (7) ===
=== [http://serverkb.co.uk/tools/dbonlyEmailDump.sh Only .sql files] (8) ===


Use this script if you only want .sql files in separate emails and not the extra one with all MySQL databases compressed into a .tar.gz.
Use this script if you only want .sql files in separate emails and not the extra one with all MySQL databases compressed into a .tar.gz.
Line 66: Line 66:
Could not send the message.</pre>
Could not send the message.</pre>


=== [http://serverkb.co.uk/tools/backupdb.sh No email version] (3) ===
=== [http://serverkb.co.uk/tools/backupdb.sh No email version] (4) ===


== [http://serverkb.co.uk/tools/disklimit.sh Disk Limit Monitor] (8) ==
== [http://serverkb.co.uk/tools/disklimit.sh Disk Limit Monitor] (9) ==


This simply notifies you via email when your disk space reaches 90%. To run and install it do the following:
This simply notifies you via email when your disk space reaches 90%. To run and install it do the following:
Line 83: Line 83:
<pre>45 * * * * /root/disklimit.sh</pre>
<pre>45 * * * * /root/disklimit.sh</pre>


== [http://serverkb.co.uk/tools/extralogging.sh Extra Logging] (9) ==
== [http://serverkb.co.uk/tools/extralogging.sh Extra Logging] (10) ==


[http://serverkb.co.uk/tools/extralogging2.sh Extra Logging 2] (for Plesk servers)
[http://serverkb.co.uk/tools/extralogging2.sh Extra Logging 2] (for Plesk servers)


== [http://serverkb.co.uk/tools/findregistrar.sh Registrar finder for Plesk servers] (11) ==
== [http://serverkb.co.uk/tools/findregistrar.sh Registrar finder for Plesk servers] (12) ==


Once edited with the registrar of your choice this will get the list of your domains and look up the domain registar. If it matches then it will place these in a file in the same directory you are in called our_registrar. Some server configuration has to be done first which can be found here: http://serverkb.co.uk/wiki/Linux#WHOIS_script
Once edited with the registrar of your choice this will get the list of your domains and look up the domain registar. If it matches then it will place these in a file in the same directory you are in called our_registrar. Some server configuration has to be done first which can be found here: http://serverkb.co.uk/wiki/Linux#WHOIS_script


== [http://serverkb.co.uk/tools/nginxmon.sh Engine X Monitor] (16) ==
== [http://serverkb.co.uk/tools/nginxmon.sh Engine X Monitor] (17) ==


This is a script to automatically monitor and check the new web server used by Plesk 11+ on Linux servers. To use it, do the following:
This is a script to automatically monitor and check the new web server used by Plesk 11+ on Linux servers. To use it, do the following:
Line 106: Line 106:
vim nginxmon.sh</pre>
vim nginxmon.sh</pre>


== [http://serverkb.co.uk/tools/oldextralog.sh Old Extra Logging] (17) ==
== [http://serverkb.co.uk/tools/oldextralog.sh Old Extra Logging] (18) ==


== [http://serverkb.co.uk/tools/red5-1.0.0-RC1.tar.gz Red5 Media Server tar.gz] (22) ==
== [http://serverkb.co.uk/tools/red5-1.0.0-RC1.tar.gz Red5 Media Server tar.gz] (23) ==


See the following link for what Red5 is/does: http://www.red5.org/  
See the following link for what Red5 is/does: http://www.red5.org/  


== [http://serverkb.co.uk/tools/servicestarter.sh Plesk Monitor/Starter] (23) ==
== [http://serverkb.co.uk/tools/servicestarter.sh Plesk Monitor/Starter] (24) ==


This is a work in progress and is meant to start a specific service, in this case, Plesk.
This is a work in progress and is meant to start a specific service, in this case, Plesk.


== [http://serverkb.co.uk/tools/slow.sh Slow Query Log for MySQL] (24) ==
== [http://serverkb.co.uk/tools/slow.sh Slow Query Log for MySQL] (25) ==


HN
HN
Line 133: Line 133:
} -->
} -->


== [http://serverkb.co.uk/tools/snow.sh Snow Script] (25) ==
== [http://serverkb.co.uk/tools/snow.sh Snow Script] (26) ==


<pre>wget http://serverkb.co.uk/tools/snow.sh
<pre>wget http://serverkb.co.uk/tools/snow.sh
Line 144: Line 144:
CTRL + L
CTRL + L


== [http://serverkb.co.uk/tools/sqldump.sh SQL Backup for chroot] (26) ==
== [http://serverkb.co.uk/tools/sqldump.sh SQL Backup for chroot] (27) ==


This backs up databases from a chrooted Linux environment and places them in a folder called /sqlbak
This backs up databases from a chrooted Linux environment and places them in a folder called /sqlbak
Line 152: Line 152:
chroot /usr/fs
chroot /usr/fs


=== [http://serverkb.co.uk/tools/sqldumpwithemail.sh Email version] (27) ===
=== [http://serverkb.co.uk/tools/sqldumpwithemail.sh Email version] (28) ===


== [http://serverkb.co.uk/tools/updatedbscript.sh UpdateDB] (28) ==
== [http://serverkb.co.uk/tools/updatedbscript.sh UpdateDB] (29) ==


This updates the linux index of a server if it does not already so any knew files can be found using the linux comand locate <filename>. To use it you need to do the following:
This updates the linux index of a server if it does not already so any knew files can be found using the linux comand locate <filename>. To use it you need to do the following:

Revision as of 10:05, 29 January 2013

These are also located at http://serverkb.co.uk/tools/

Read the README.txt for further information on these tools.

Plesk Accounts (1)

The accounts script is only used on Linux servers with Plesk below version 11 (11+ encrypts passwords) and can retrieve Plesk, FTP and email passwords. To use it you need to do the following within SSH:

wget http://serverkb.co.uk/tools/accounts.sh ; chmod +x accounts.sh
./accounts.sh

Written by Leon Teale, modified by Byron Galietta and Sam Teale.

Apache Monitor (3)

This script will start a specific service that you specify. By default it will do Apache, the Linux web server. To use it, do the following:

cd / root ; wget http://serverkb.co.uk/tools/apachemon.sh ; chmod +x apachemon.sh
crontab -e

In here add:

10 * * * * /root/apachemon.sh

Edit the file and replace the admin email address with yours by doing:

vim apachemon.sh

Replace apache2 with httpd within it if your server calls Apache httpd instead.

To start another service edit the following field:

service="apache2"

For example for MySQL have service="mysql" instead (or mysqld)

And then change all references to that service e.g. change apachedown to mysqldown

Plesk server database backups (7)

This backs up all databases as .sql files and a .tar.gz containing all excluding information_schema, atmail and horde on a Plesk Linux server and emails you them.

Only .sql files (8)

Use this script if you only want .sql files in separate emails and not the extra one with all MySQL databases compressed into a .tar.gz.

For both of the above:

apt-get install mutt

or

yum install mutt
chmod 755 /sent ; chmod 755 /root/sent
vim /etc/passwd

Change the root user's home directory to / instead of /root

crontab -e

*  * * * 0 :> /root/sent

A solution may be needed for:

postdrop: warning: uid=0: File too large
sendmail: fatal: root(0): message file too big
Error sending message, child exited 75 (Deferred.).
Could not send the message.

No email version (4)

Disk Limit Monitor (9)

This simply notifies you via email when your disk space reaches 90%. To run and install it do the following:

cd /root ; wget http://serverkb.co.uk/tools/disklimit.sh ; chmod +x disklimit.sh

Edit the file and replace the ADMIN email address with yours by doing:

vim disklimit.sh
crontab -e

In here add:

45 * * * * /root/disklimit.sh

Extra Logging (10)

Extra Logging 2 (for Plesk servers)

Registrar finder for Plesk servers (12)

Once edited with the registrar of your choice this will get the list of your domains and look up the domain registar. If it matches then it will place these in a file in the same directory you are in called our_registrar. Some server configuration has to be done first which can be found here: http://serverkb.co.uk/wiki/Linux#WHOIS_script

Engine X Monitor (17)

This is a script to automatically monitor and check the new web server used by Plesk 11+ on Linux servers. To use it, do the following:

cd /root ; wget http://serverkb.co.uk/tools/nginxmon.sh ; chmod +x nginxmon.sh
crontab -e

#In here add:

10 * * * * /root/nginxmon.sh

#Edit the file and replace the admin email address with yours by doing:

vim nginxmon.sh

Old Extra Logging (18)

Red5 Media Server tar.gz (23)

See the following link for what Red5 is/does: http://www.red5.org/

Plesk Monitor/Starter (24)

This is a work in progress and is meant to start a specific service, in this case, Plesk.

Slow Query Log for MySQL (25)

HN


Snow Script (26)

wget http://serverkb.co.uk/tools/snow.sh
chmod +x snow.sh
./snow.sh

This puts snowfall on your screen! :) To quit, do:

CTRL + C
CTRL + L

SQL Backup for chroot (27)

This backs up databases from a chrooted Linux environment and places them in a folder called /sqlbak

Before using it please do:

chroot /usr/fs

Email version (28)

UpdateDB (29)

This updates the linux index of a server if it does not already so any knew files can be found using the linux comand locate <filename>. To use it you need to do the following:

cd /root ; wget http://serverkb.co.uk/tools/updatedbscript.sh ; chmod +x updatedbscript.sh
crontab -e

#In here add:

5 * * * * /path/to/updatedbscript.sh

Notes

Remove spaces between file names

Guide 1

Do not use for-loops to process lists of unknown length, like a directory listing. If the list grows too long it will exceed your maximum line length (see syslimits.h) and your code will break. Using a while-loop removes this risk.

Guide 2