Fun BASH script to fool(maybe) people that they are hacking a website.

By Seth Leedy on May 17, 2012

This could be expanded upon. Have fun and submit back your changes..
See the rest of this entry…

Topics: BASH | No Comments »

Command Line Matrix screen effect

By Seth Leedy on May 17, 2012

From: http://www.asty.org/cmatrix/

CMatrix
CMatrix
cmatrix-1.2a.tar.gz
Version: 1.2a
72.6 KiB
1 Downloads
Details...


NOTE: I never got this to compile. Somewhere in the code it was not linking to the ncurses library.


What is CMatrix? =-)

CMatrix is a program I wrote one evening because I didn’t want to have to run Wind*ws to see the cool scrolling lines from ‘The Matrix’, my fave movie. If you haven’t seen this movie and you are a fan of computers or sci-fi in general, go see this movie!!! I have seen it twice, and I’m pondering seeing it again before it comes out on VHS.

Cmatrix is written in ncurses under Linux, and should compile on other OSes with few modifications. I am always interested to hear from people who use this program and any modifications they make to it!
CMatrix is distributed via the GNU GPL, please see the COPYING file or the GNU Project homepage for more information.

Options:
-a: Asynchronous scroll, more like the movie/original screensaver
-b: Partial bold text mode
-B: All bold text mode
-f: Force the linux $TERM type to on
-l: Linux support for linux console matrix.fnt font
-n: No bold text mode
-o: Use “old-style” scrolling – less like the movie, more like the Win/Mac screensaver.
-s: “Screen saver” mode. Any key aborts (default is “eye candy” mode, must abort with control C)
-x: X window mode, use if your xterm is using mtx.pcf
-u [update]: Update delay (0-9, default 4).
-C [color]: Use color for matrix (default green).

Keystrokes available while running (not available in -s mode):
a: Toggle asynch mode
b: Enable partial bold text
B: Enable all bold text
n: Disable bold text
0-9: Change update delay
! @ # $ % ^ & ): Change the color of the matrix to the corresponding color: ! – red, @ – green, # – yellow, $ – blue, % – magenta, ^ – cyan, & – white, ) – black.

A sample screenshot:

and…

CMatrix with mtx.pcf font loaded in a transparent aterm…a console font is also included in the distribution =-)
Download!

The current version of CMatrix is 1.2a. Please click the link below to download it, or check here for versions that I may not have had time to update this link to:
cmatrix-1.2a.tar.gz. Changelog is here.
News

03/31/2002 – Happy Easter! Well, it’s been forever. I’ve tried give CMatrix away, but looking at SourceForge, there are two derivatives of CMatrix. One is complete vaporware, and the other is run by a person from Poland who I tried to turn CMatrix over to; unfortunately the tarball that’s there seems corrupted. I decided to knuckle under and make a new release. CMatrix can now be resized on the fly, and allocates space for characters dynamically, no more limit of 132×300! Have fun with it!
11/21/2000 – CMatrix needs a new mommy or daddy! While I love the program, I no longer have time to maintain CMatrix as I spend all my free time on nano. This page recieved over 200 hits a week, I know there are people reading this =) If you would like to take owner as maintainer of CMatrix, drop me a line with your qualifications or similar projects (especially ncurses based) that you have worked on.
04/09/2000 – CMatrix 1.1b now has RPMs to choose from. Please see the dist/RPMS directory to download them. Note that this is my first attempt at making an RPM spec file, so if something doesn’t work right just let me know.
04/03/2000 – At long last! Development has resumed on CMatrix thanks to a new job and a renewed interest by the Open Source community in my humble little program. CMatrix now has a page at SourceForge (at http://sourceforge.net/project/?group_id=4055) and that will be its primary location for releases and development.
7/11/99 – Well, it seems that versin 1.0 b is fairly stable, and I haven’t heard many requests for new features (with a few exceptions). Since this is the busy season at my job, there will probably not be any new versions of CMatrix for the remainder of the summer, unless I get some major bug report. If you do have any ideas for improvements for CMatrix, I’d still like to get any patches of ideas you have… as always my mailbox is always open.
6/6/99 – RedHat 6 should be fully supported as of version 1.0 b. Please let me know if you have any difficulties getting cmatrix to work on your RH6 system. Be sure to be as specific as possible =-)
5/4/99 – The funky “matrix” font is now working in cmatrix! To get the font working, make sure you run make install as root, and make install.x in X window as root. Just use the -l option, and you should get the funky characters! If using X window, make sure you call your xterm or rxvt with -font mtx or -fn mtx and use cmatrix -x. I have heard reports that this option does not work with Redhat 6.0 right now in the console, and I’m investigating it.
Programs based on CMatrix

Andrew Arensburger wrote a FreeBSD screensaver based on CMatrix (at least in spirit =). It is available here. I’ll have to give it a try the next time I get FreeBSD installed.
Apparently jwz has made up an xscreensaver module that at least resembles cmatrix. It does have the kooky characters in it and has an interesting “glow effect”. I like it. Xscreensaver is available at www.jwz.org/xscreensaver.
Back to my homepage.
(c) 2000 Chris Allegretta. All right reserved.

Topics: Command Line, Linux, Screen Savers | No Comments »

To reload screen’s configuration without need of screen restart

By Seth Leedy on May 17, 2012

Reload .screenrc without screen restart
To reload screen’s configuration without need of screen restart press:

and type

Topics: Linux, Tips & Tricks | No Comments »

How To Upgrade From Fedora 15 To Fedora 16 or 17 (Desktop & Server)

By Seth Leedy on May 17, 2012

From: http://www.howtoforge.com/how-to-upgrade-from-fedora-15-to-fedora-16-desktop-and-server


How To Upgrade From Fedora 15 To Fedora 16 or 17 (Desktop & Server)

Version 1.0
Author: Falko Timme
Follow me on Twitter
Last edited 11/08/2011

This article describes how you can upgrade your Fedora 15 system to Fedora 16. The upgrade procedure works for both desktop and server installations.

I do not issue any guarantee that this will work for you!

1 Preliminary Note
The commands in this article must be executed with root privileges. Open a terminal (on a Fedora 15 desktop, go to Applications > System Tools > Terminal) and log in as root, or if you log in with a regular user, type

su

to become root.

Please make sure that the system that you want to upgrade has more than 600 MB of RAM – otherwise the system might hang when it tries to reboot with the following message (leaving you with an unusable system):

Trying to unpack rootfs image as initramfs…

2 Upgrading To Fedora 16 (Desktop)
First we must upgrade the rpm package:

yum update rpm

Then we install the latest updates:

yum -y update

Next we clean the yum cache:

yum clean all

If you notice that a new kernel got installed during yum -y update, you should reboot the system now:

reboot

(After the reboot, log in as root again, either directly or with the help of

su

)

Now we come to the upgrade process. We can do this with preupgrade (preupgrade will also take care of your RPMFusion packages).

Install preupgrade…

yum install preupgrade

… and call it like this:

preupgrade

The preupgrade wizard will then start on your desktop. Select Fedora 16 (Verne). Afterwards the system is being prepared for the upgrade.

At the end, click on the Reboot Now button.

During the reboot, the upgrade is being performed. This can take quite a long time, so please be patient.

Afterwards, you can log into your new Fedora 16 desktop.

3 Upgrading To Fedora 16 (Server)
First we must upgrade the rpm package:

yum update rpm

Then we install the latest updates:

yum -y update

Next we clean the yum cache:

yum clean all

If you notice that a new kernel got installed during yum -y update, you should reboot the system now:

reboot

(After the reboot, log in as root again, either directly or with the help of

su

)

Now we come to the upgrade process. We can do this with preupgrade.

Install preupgrade…

yum install preupgrade

… and call it like this:

preupgrade-cli

It will show you a list of releases that you can upgrade to. If all goes well, it should show something like Fedora 16 (Verne) in the list:

[root@server1 ~]# preupgrade-cli
Loaded plugins: blacklist, langpacks, whiteout
No plugin match for: rpm-warm-cache
No plugin match for: remove-with-leaves
No plugin match for: auto-update-debuginfo
Loaded plugins: langpacks, presto, refresh-packagekit
please give a release to try to pre-upgrade to
valid entries include:
“Fedora 16 (Verne)”
[root@server1 ~]#

To upgrade, append the release string to the preupgrade-cli command:

preupgrade-cli “Fedora 16 (Verne)”

Preupgrade will also take care of your RPMFusion packages, so all you have to do after preupgrade has finished is to reboot:

reboot

During the reboot, the upgrade is being performed. This can take quite a long time, so please be patient. Afterwards, you can log into your new Fedora 16 server.

Topics: Command Line, Linux | No Comments »

Stress test MySQL with mysqlslap

By Seth Leedy on May 17, 2012

From: http://www.techrepublic.com/blog/howdoi/how-do-i-stress-test-mysql-with-mysqlslap/133


How do I… Stress test MySQL with mysqlslap?
By Melonfire
September 17, 2007, 12:12 AM PDT
Takeaway: The mysqlslap utility makes it possible to benchmark and compare MySQL performance on different hardware, as well as accurately quantify the effect of a change in database design. This tutorial shows how you can use mysqlslap to run tests involving multiple clients, custom queries, different table engines, and much more.

One of the interesting new tools in MySQL 5.1.4 is mysqlslap, a load emulator that lets you see how well a particular query set or table engine performs under high-load conditions.

A query that consumes too many database resources may be the result of designing tables incorrectly, choosing the wrong table type, or creating an inefficient query. When a query eats up a lot of database resources, it can negatively affect other application components. By using mysqlslap to stress test a server in a non-public environment, you will discover these errors sooner, allowing you to you avoid a database meltdown once your application goes live.

This tutorial shows how you can use mysqlslap to run stress tests involving multiple clients, custom queries, different table engines, and much more.

Basic usage

This simple (and unrealistic) example uses mysqlslap to test server performance assuming only one client connection:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql

Benchmark

Average number of seconds to run all queries: 0.006 seconds

Minimum number of seconds to run all queries: 0.006 seconds

Maximum number of seconds to run all queries: 0.006 seconds

Number of clients running queries: 1

Average number of queries per client: 0
The –auto-generate-sql switch tells mysqlslap to automatically generate and execute SQL statements, monitor how fast MySQL performs this task, and display the result. The results indicate that MySQL took 0.006 seconds to execute the SQL statements.

The –auto-generate-sql switch creates a table, executes an INSERT query and saves dummy data to it, executes a SELECT query to retrieve the dummy data, and then drops the table. You can see behind-the-scenes action by adding the -v switch to the mysqlslap command line (adding extra ‘v’s increases the verbosity level):

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql -vv

DROP SCHEMA IF EXISTS mysqlslap;

CREATE SCHEMA mysqlslap;

CREATE SCHEMA mysqlslap;

CREATE TABLE t1 (intcol1 INT(32),charcol1 VARCHAR(128));

INSERT INTO t1 VALUES (1804289383,’mxvtvmC9127qJNm06sGB8R92q2j7vTiiITRDGXM9ZLzkd

ekbWtmXKwZ2qG1llkRw5m9DHOFilEREk3q7oce8O3BEJC0woJsm6uzFAEynLH2xCsw1KQ1lT4zg9rdxB

L’);

SELECT intcol1,charcol1 FROM t1;

Benchmark

Average number of seconds to run all queries: 0.007 seconds

Minimum number of seconds to run all queries: 0.007 seconds

Maximum number of seconds to run all queries: 0.007 seconds

Number of clients running queries: 1

Average number of queries per client: 0 DROP SCHEMA IF EXISTS mysqlslap;
It’s unlikely that you’ll have only a single client connecting to the MySQL server at any given time, so you’ll typically also need the –concurrency switch, which lets you simulate multiple simultaneous client connections, like this:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100

Benchmark

Average number of seconds to run all queries: 0.698 seconds

Minimum number of seconds to run all queries: 0.698 seconds

Maximum number of seconds to run all queries: 0.698 seconds

Number of clients running queries: 100

Average number of queries per client: 0
MySQL performance drops pretty significantly (from 0.007 seconds to 0.698 seconds) when it has to deal with 100 clients instead of just one.

See what happens if you increase the number of concurrent connections even more:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=300

Benchmark

Average number of seconds to run all queries: 47.515 seconds

Minimum number of seconds to run all queries: 47.515 seconds

Maximum number of seconds to run all queries: 47.515 seconds

Number of clients running queries: 300

Average number of queries per client: 0
Note: As you increase the number of concurrent connections, you might encounter a “Too many connections” error. You need to adjust MySQL’s ‘max_connections’ variable, which controls the maximum number of concurrent connections allowed by the server.

Running tests more than once

You can force mysqlslap to run a particular test more than once by adding the –iterations switch to the command line. This example runs the same test five times and prints a composite result:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –iterations=5

Benchmark

Average number of seconds to run all queries: 0.714 seconds

Minimum number of seconds to run all queries: 0.682 seconds

Maximum number of seconds to run all queries: 0.753 seconds

Number of clients running queries: 100

Average number of queries per client: 0
Specifying the total number of queries

It’s possible to force each “client” to run a specific number of queries by adding the –number-of-queries switch to the mysqlslap command line. When mysqlslap encounters this switch, it divides the corresponding value by the number of concurrent connections and uses the result to decide how many queries each client should run.

For example, with settings of 500 total queries and five concurrent clients, mysqlslap will run 500/5 = 100 queries per client. Take a look at an example:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=10000

Benchmark

Average number of seconds to run all queries: 0.694 seconds

Minimum number of seconds to run all queries: 0.694 seconds

Maximum number of seconds to run all queries: 0.694 seconds

Number of clients running queries: 100

Average number of queries per client: 100
Using larger tables

The default behavior of mysqlslap when using the –auto-generate-sql switch is to create a two-column table with one integer column and one character column. If this isn’t representative of the kind of tables you typically use, you can adjust these settings to include more integer and/or character columns, with the –number-char-cols and –number-int-cols switches. Here are examples:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=1000 –number-char-cols=4 –number-int-cols=7

Benchmark

Average number of seconds to run all queries: 1.290 seconds

Minimum number of seconds to run all queries: 1.290 seconds

Maximum number of seconds to run all queries: 1.290 seconds

Number of clients running queries: 100

Average number of queries per client: 10 shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-char-cols=4

Benchmark

Average number of seconds to run all queries: 0.968 seconds

Minimum number of seconds to run all queries: 0.968 seconds

Maximum number of seconds to run all queries: 0.968 seconds

Number of clients running queries: 100

Average number of queries per client: 0

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-int-cols=5

Benchmark

Average number of seconds to run all queries: 1.076 seconds

Minimum number of seconds to run all queries: 1.076 seconds

Maximum number of seconds to run all queries: 1.076 seconds

Number of clients running queries: 100

Average number of queries per client: 0
Using custom queries

While the –auto-generate-sql option is fine for general load testing, you may want to test the performance of a specific query on a database that already exists. In these situations, you can bypass the –auto-generate-sql switch and instead tell mysqlslap to use your own custom query with the –query switch. Here’s the next example:

shell> /usr/local/mysql/bin/mysqlslap –user=john –create-schema=world –query=”SELECT City.Name, City.District FROM City, Country WHERE City.CountryCode = Country.Code AND Country.Code = ‘IND’;” –concurrency=100 –iterations=5

Benchmark

Average number of seconds to run all queries: 2.886 seconds

Minimum number of seconds to run all queries: 2.137 seconds

Maximum number of seconds to run all queries: 4.125 seconds

Number of clients running queries: 100

Average number of queries per client: 1
It’s helpful to use mysqlslap in this manner when you need to analyze the effect of a change in your database structure or indexing because it allows you to immediately grasp the impact of, say, an additional index on overall performance. To illustrate, look what happens to the time needed to run the previous query when an index is added to the City table:

mysql> CREATE INDEX idx_ccode ON City(CountryCode);

Query OK, 4079 rows affected (1.06 sec)

Records: 4079 Duplicates: 0 Warnings: 0 mysql> exit

Bye

shell> /usr/local/mysql/bin/mysqlslap –user=john –create-schema=world –query=”SELECT City.Name, City.District FROM City, Country WHERE City.CountryCode = Country.Code AND Country.Code = ‘IND’;” –concurrency=100 –iterations=5

Benchmark

Average number of seconds to run all queries: 1.682 seconds

Minimum number of seconds to run all queries: 1.396 seconds

Maximum number of seconds to run all queries: 2.109 seconds

Number of clients running queries: 100

Average number of queries per client: 1
You can tell mysqlslap to create a custom table for your load testing by using the –create command-line switch with a CREATE TABLE command.

Comparing table engines

A cool feature of mysqlslap is the ability to specify the table engine used in the test. This provides database designers with an easy way to compare the performance of different table types under different load conditions. The –engine switch accepts any of MySQL’s supported table types and creates test tables using the corresponding storage engine. Here’s an example of how it could be used:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=700 –engine=innodb

Benchmark

Running for engine innodb

Average number of seconds to run all queries: 1.240 seconds

Minimum number of seconds to run all queries: 1.240 seconds

Maximum number of seconds to run all queries: 1.240 seconds

Number of clients running queries: 100

Average number of queries per client: 7 shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=700 –engine=myisam

Benchmark

Running for engine myisam

Average number of seconds to run all queries: 0.676 seconds

Minimum number of seconds to run all queries: 0.676 seconds

Maximum number of seconds to run all queries: 0.676 seconds

Number of clients running queries: 100

Average number of queries per client: 7

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=700 –engine=memory

Benchmark

Running for engine memory

Average number of seconds to run all queries: 0.602 seconds

Minimum number of seconds to run all queries: 0.602 seconds

Maximum number of seconds to run all queries: 0.602 seconds

Number of clients running queries: 100

Average number of queries per client: 7
Saving reports

You might wish to save a mysqlslap report so you can compare it to a previous or future test run; you may also want to use the report as a reference when you’re configuring new systems.

The easiest way to save a mysqlslap report is to pipe the output of a mysqlslap run to a file, as below:

shell> /usr/local/mysql/bin/mysqlslap –user=john –auto-generate-sql –concurrency=100 –number-of-queries=1000 –number-char-cols=4 –number-int-cols=7 >> /tmp/output.log
You can force mysqlslap to generate reports in CSV format; this is often useful if you need to import the data into a spreadsheet or database to build graphical reports from it. To do this, add the –csv switch to your mysqlslap command line and specify the output filename as an argument to this switch. Here’s an example:

shell> /usr/local/mysql/bin/mysqlslap –csv=/tmp/output.csv –user=john –auto-generate-sql –concurrency=100 –number-of-queries=1000 –number-char-cols=4 –number-int-cols=7
Here’s what the CSV file would contain if you peeked inside it:

shell> cat /tmp/output.csv

,query,1.070,1.070,1.070,100,10
Trying mysqlslap

The mysqlslap utility makes it possible to benchmark and compare MySQL performance on different hardware, as well as accurately quantify the effect of a change in database design. Try mysqlslap out for yourself and see how well your database server behaves under pressure from thousands of client connections.

Topics: MySQL | No Comments »

Next Entries »

Bad Behavior has blocked 631 access attempts in the last 7 days.