Monitoring Windows Servers Agentlessly – WMI plugin

Tech Down Under: Part 1: Monitoring Windows Servers Agentlessly via…:

This how to will show how to install the open source software NAGIOS to monitor network devices such as switches, routers, servers, firewall…etc.

The detail instruction for installing WMI is found here

A good detail of installing wmi client and wmi plugin is available at interwebplus.com

Note : if your few of the perl modules were outdated, The check_wmi plugin will not work.

in that case you can use –IgnoreMyOutDatedPerlModuleVersions  case. 

mysql dump of data only – no table and database schema

Mates, I want to dump the data from the tables only rather than its definition and data.

The problem with mysqldump is it checks if database/table exist  or not. if the table exist it drops the table create the blank table and then enters the insert into statements. I don’t want to use this.

goggled and found

dump the database with options –no-create-db and –no-create-info

Mysql Database Backup script

Create a file called database_backup.sh and also an empty directory called mysql_backup.

The database_backup.sh script should have the following info :

#!/bin/sh 
date=`date '+%m-%d-%y'`
PATH="~/mysql_backup/database_name.$date"
mysqldump -u database_username -pdatabase_password database_name > $PATH


Run the script that performs the backup job.

Using Cron  :

Set this script up to run every night, etc. as a cron job. It will save an sql dump of your database every night in the mysql_backup.
e.g

* 23 * * * your_userid /path/to/backup/script

Backing Up MySQL Database

MySQL database backup can be accomplished in two ways:

a) Copying the raw mysql database files &
b) Exporting tables to text files



Copying the Mysql database Files :

MySQL uses the same table format on different platforms, so it’s possible to copy MySQL table and index files from one platform and use them on another without any difficulties (assuming, of course, that you’re using the same version of MySQL on both platforms).

Exporting tables to text files.

The MySQLDump is handy utility that can be used to quickly backup the MySQL Database to the text files. To use the MySQLDump utility it is required to logon to the System running the MySQL Databse. You can use Telnet to remotely logon to the system if you don’t have the physical access to the machine.
The syntax for the command is as follows.

mysqldump -u [Username] -p [password] [databasename] > [backupfile.sql]

[username] – this is your database username
[password]- this is the password for your database
[databasename] – the name of your database
[backupfile.sql] – the filename for your database backup

Let’s discuss the example of backing up MySQL Database named “accounts” into text file accounts.sql. Here are the scenarios of taking the backup assuming that both user name and password of the database is “admin”.

a) Taking the full backup of all the tables including the data.

Use the following command to accomplish this:
mysqldump -u admin -p admin accounts > accounts.sql

b) Taking the backup of table structures only.

Use the following command to accomplish this:
mysqldump -u admin -p admin –no-data accounts > accounts.sql

c) Taking the backup data only.

Use the following command to accomplish this:
mysqldump -u admin -p admin –no-create-info accounts > accounts.sql

Restoring MySQL Database

Restoring the MySQL is very easy job. You can use the following to command to restore the accounts database from accounts.sql backup file.

mysql – u admin -p admin accounts < accounts.sql

In this tutorial you learned how to take the backup of your MySQL Database and restore the same in the event of some database crash or on some other machine.

How to check how much free space we have in Mysql database

fire the query
show table status like ‘org’;

The last column Comments gives the size of the database.

If you need to have a shell script to check InnoDB_free space of Mysql database here is the code

Query="show table status like 'org';"
#freespace=${echo "$Query" | mysql -t --host=tiber4 mvc | /bin/awk '/InnoDB free:/ {print $38}' }
freespace=$(echo "$Query" | mysql -t --host=$host $db | /bin/awk '/InnoDB free:/ {print $38}' )

echo $host has $freespace kB free

basic postgresql tips

Start and stop postgresql

Service postgres start

Add to the chkconfig
Chkconfig –level 3 postgres on

to create a first user in kubuntu/ubuntu linux, type the following:
~$ sudo su postgres -c createuser *USERNAME*

Then create a db:
~$ sudo su postgres -c createdb *DBNAME*

Then create a password for the user by connecting using psql:
~$ sudo su postgres -c psql *DBNAME*

Then alter the password:
=#ALTER USER *username* WITH PASSWORD ‘*password*‘;
=#\q

TRIMMIG IN MYSQL

Some time back I got stuck at the point in Mysql task ,I wanted to trip a part of already existing column in table and then insert into other column.

Reference is the column that contains the Reference number e.g. ‘090216-000016’
RDate is the column is which stores the date of the reference,  and first part of Reference contains the date. So I wanted to trip the Reference number to get the data for RDate column.

Here is how I did it,

mysql> select Reference from RNS  where Reference=’090216-000016′;
+—————+
| Reference     |
+—————+
| 090216-000016 |
+—————+
1 row in set (0.00 sec)

mysql> select LEFT (Reference,6) from RNS  where Reference=’090216-000016′;
+——————–+
| LEFT (Reference,6) |
+——————–+
| 090216             |
+——————–+
1 row in set (0.01 sec)

mysql> update RNS set RDATE=LEFT(Reference,6) where Reference=’090205-000154′;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select Reference,RDATE from RNS  where Reference=’090205-000154′;
+—————+————+
| Reference     | RDATE      |
+—————+————+
| 090205-000154 | 2009-02-05 |
+—————+————+

Hope it will be useful.