Posts Tagged sysadmin

Cool Tool: Preyproject

I was watching HAK5 on REV3 last week and they mentioned a tool called the preyroject.

What the prey does is runs a piece of software on your PC/MAC/Linux computer that communicates back to your account at www.preyproject.com so in the event you computer is stollen or lost you can connect to the website and tell your laptop it is lost.

When you set this setting the Prey software starts to send you back information regarding your missin laptop such as LAN and WAN IP addresses, running processes, logged in users, screen shots and a photo from the webcam if you have one.

The software will also try to geotag you location via GPS or wireless acces point. The software will also try to connect to the Internet via open AP’s if it is not already connected to the internet.

You can also have the software place a popup on screen and have a buzzer sound every report interval, but this may just infuriate whoever has stollen you computer and have it end up in the bin.

It installed on my macbook really easily and registers with just a quick submission of your preyproject.com credentials. I have yet to test installing it on Windows or Linux, but plan to when I get a chance.

The awesome bit about the software is that it is written in BASH so it is very portable. It was also announced that there is a version available now for the Aindroid platform, which I am excited about for when I get my new Smartphone in the next few months as it seems like a perfect place for this software on a mobile phone.

Make sure you check out HAK5 as well as it is always full of cool tools like this every week.

Tags: , , , ,

Quick Hack: delete bulk processes reported with ps/grep.

Having qmail running on multiple machines (I know there are better alternatives) we often have to go in and clean up after a crashed qmail service so it will behave again for a while.

Here is a quick and dirty hack to kill processes up that are there when you do a ps aux | grep <process name>

SEARCH='qmail' ; ps -eo pid,cmd | grep $SEARCH | awk '{ print $1 }' | xargs -I pid kill -15 pid

This uses ps and grep to find the processes and awk and xargs to create and execute the kill command for the PID of that process.

This command can easily be adapted to search for whatever process is required by changing the string in the SEARCH variable at the start of the command. The command above is designed as a follow up to using a ps aux | grep to find the search string that identifies the process.

Check out a quick howto on xargs here. I think it is one of the must for all hardcore Linux sys admins out there.

Tags: , , , , , , , ,

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: , , , , , , , ,

Installing yum on Centos-5 VPS

I have been going the way of installing all of the packages on Centos VPS using wget to get the packages. Here is a one line command to install yum:

vzpkg install <CTID> -p yum

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: , , , , , ,