Posts Tagged administration

Sendmail mailq management.

Had to clean out a sendmail mail queue that was huge today. Found a couple of geat ways to locate mail that can be removed from the mail queue using awk and xargs.

Delete files from mqueue by looking for keywords in the queue file:

grep 'error' qf* | grep -v '<your domain>' | awk -F: '{print $1}' | awk -Ff '{print $2}' | xargs -I file rm -f dffile qffile

Delete mail from mail queue that had no sender address:

mailq | grep '<>' | awk '{print $1}' | xargs -I file rm -f qffile dffile

I was also exchanging the xargs part of the command with wc -l to count how many of the problem mails are in the mail queue.

Tags: , , , , , , , ,

Shell Commands for HTTP access log

I had to do some anayalsis of a clients site and verify if it was actually as popular as the data usage and web statistics said it was. Bellow are some of the shell commands that I have used to analyze the access log on the server the site was hosted on:

Unique IP’s and amount of entries in access_log:
======================================
cat <path to log file> | awk ‘{print $1}’ | sort -n | uniq -c

Amount of unique IP’s:
===================
cat <path to log file> | awk ‘{print $1}’ | sort -n | uniq -c | wc -l

Amount of Bytes of data from files logged.
=================================
cat <path to log file> | awk ‘{sum+=$10}END{print sum}’

Unique files and the amount of times accessed
====================================
cat <path to log file> | awk ‘{print $7}’ | sort | uniq -c | sort -n -r

Unique files and there size in bytes
============================
cat <path to log file> | awk ‘{print $10, $7}’ | sort -n -r

Tags: , , , , , ,

SELinuxTroubleshhoting from the command line.

I love SELinux and think it is a great way to assist you to ensure services and users are not accessing files and directories they should not be.

I have found the sealert GUI tool to be a great help when setting up and troubleshooting issues on a system, but have always struggled at the command line. Until I found a solution.

 sealert -a /var/log/audit/audit.log

This outputs the text of the sealert GUI to stdout and assists you in troubleshooting where SELinux is interfering with the system.

This is also handy as you can point any file that has audit log entries in it and it will assess this so if you are emailed the log entries. Dump them in a file and point sealert at it.

Also Checkout the SELinux HowTo on the Centos Wiki for heaps of other tips and tricks on troubleshooting SELinux.

Tags: , , ,