Cut Squid log data


Use the below to cut some data out of squid log that we dont need. Will cut up to the point added in the quotes (”)

From

squidlog.log.18:94.236.109.235 851 - - [28/Sep/2011:19:01:37 +0100] "GET http://someurl HTTP/1.
1" 200 36921 "-" "-" "-" TCP_MISS:SERVER

To

94.236.109.235 866 - - [28/Sep/2011:19:13:57 +0100] "GET someurl HTTP/1.1" 200 38214 "-" "-" "-" TCP_MISS

Using

cut -d ':' -f2,3,4,5,6, squidlog.txt

Installing PHPmyAdmin


List of steps for Installing PHPmyAdmin, helpful 😀

1. phpMyAdmin Requirements

Need to ensure you have at least the following versions of PHP/Mysql installed on the server. To confirm this check using the below.

–PHP

php -v

–MYSQL

mysql -V

2. Download PHPmyAdmin

Download from the website the copy across to the server http://www.phpmyadmin.net

3. Install in apache root directory

Once downloaded copy the gz file to the apache root directory and unzip. To confirm the directory run the following.

grep DocumentRoot /usr/local/apache2/conf/httpd.conf
tar xvfz phpMyAdmin-3.4.0-all-languages.tar.gz

4. Modify the permissions to the installed directory

Run the below to change the permissions of the phpmyadmin folder.

chown -R apache:apache phpmyadmin/

Then run the following, ensure your in the phpmyadmin folder.

mkdir config
chmod o+rw config
cp config.sample.inc.php config/config.inc.php
chmod o+w config/config.inc.php

5. Add sym link to /var/www/html

Add a symbolic link to the www directory so that its accessible from the server.

ln -s /usr/local/apache2/htdocs/phpmyadmin /var/www/html/apps/phpmyadmin

6. Access PHPmyAdmin configuration page

Go to the server address http://servernamehere/phpmyadmin/setup/index.php, this will allow access to the configuration page so that you can setup access to the DB.

*Note*

You will need to have the root password to the mysql DB. If you dont have this then there is a work around, however this is only to be applied on servers that are not live. If you require access to the root password for non-live server then contact Sysadmins on this.

7. Access PHPmyAdmin page

If its all working when you go to http://servername/phpmyadmin/index.php you should get the usual login prompt and then be able to login.

8. Enable access for remote server access to mysql

Run the following on the server that has mysql installed that you want to connect to

GRANT ALL ON *.* TO usernamehere@'serverhosthere' IDENTIFIED BY 'PASSWORD';

If required..

To increase the memory size if you get the following error

"Fatal error: Allowed memory size of 33554432 bytes exhausted".

Find the php.ini file using the below command

whereis php.ini

Then open up the file and amend the “Memory Limit” and “Post_max_size” parameters.

Check MySQL Connections


Handy commands for checking MySQL connections via command line.

View Connection number

show status like 'Conn%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections   | 500   |
+---------------+-------+

View connections by status

show status like '%onn%';
+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| Aborted_connects         | 4422  |
| Connections              | 17325 |
| Max_used_connections     | 443   |
| Ssl_client_connects      | 0     |
| Ssl_connect_renegotiates | 0     |
| Ssl_finished_connects    | 0     |
| Threads_connected        | 441   |
+--------------------------+-------+

Process list

show processlist;
+----+------+-----------------+--------+---------+------+-------+------------------+
| Id | User | Host            | db     | Command | Time | State | Info             |
+----+------+-----------------+--------+---------+------+-------+------------------+
|  3 | root | localhost       | webapp | Query   |    0 | NULL  | show processlist | 
|  5 | root | localhost:61704 | webapp | Sleep   |  208 |       | NULL             | 
|  6 | root | localhost:61705 | webapp | Sleep   |  208 |       | NULL             | 
|  7 | root | localhost:61706 | webapp | Sleep   |  208 |       | NULL             | 
+----+------+-----------------+--------+---------+------+-------+------------------+
4 rows in set (0.00 sec)

grep multiple files


Nice tip for when you need to look through more than 1 log, however the log names may be changing due to archiving purposes. They could be adding a date/time or number on to the filename, you can also use the * icon as a wildcard.

Added some examples below

 grep stuff some.access.log.[0-9]
 grep stuff some.access.log.*

Time please..


Dates and Times are things that just seem to fly by. Never enough time in a day! Some handy hints for using the getting the date and time with linux which might be useful for all sorts of things…

date
well just…

date
Tue Sep 13 19:29:46 BST 2011

seconds

date "+%s"
1315938728

day

date "+%d"

month

date "+%h"

year

date "+%Y"

time example

date "+%H:%M"

previous hour

TZ=aaa24 date +%H

previous day

TZ=aaa24 date +%d

more?

man date