Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a running script which is inserting data into a MySQL database.

I want to know how many rows are getting inserted per second and per minute. If the count of rows inserted per second or per minute goes beyond a certain count, I need to stop executing the script.

How can I monitor this?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You should be able to derive that information from the output of

mysqladmin extended-status

Or

show status like 'Innodb_rows_inserted';

in MySQL, run every minute.

Or for individual databases or tables, you could use information from information_schema.TABLES:

select TABLE_NAME, TABLE_ROWS from information_schema.TABLES 
    where TABLE_SCHEMA = 'my-database';
share|improve this answer
    
That sounds about right. I also found out a command called watch, which lets me monitor the amount of records inserted per sec. –  The Dark Knight Feb 21 '13 at 6:54
add comment

There are ways to do this via some count() on the db, but i think this will always be kind of ugly and just slow the execution of your script down. So the best way to do it is inside the script itself.

For example after every 1000 inserts you check the time since the last 1000 and then decide what to do.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.