Servers (*ix , scripting)

Not bad for a setup on an old IBM thinkcenter A50

The server I describe in links 1) and 2) up for 52 days 🙂 . Not bad for a setup on an old IBM thinkcenter A50.

1) http://mbakopoulos.wordpress.com/2012/02/23/raid-6-backup-server-with-samba-windows-sharing-e-mail-monitoring-ubuntu-and-remote-desktop/
2)http://mbakopoulos.wordpress.com/2012/03/07/how-to-totally-disable-suspendhibernation-in-ubuntu-if-all-else-fails/

Update (September 8, 2012):

Now going on 83 days… call me a happy kid =)

Limiting TOP command to a specific process name and keeping interactivity

Introduction

In this post we analyze the following command which allows you to run “top interactively without having to look up the pids” your interested in.

top -p `pgrep process-name | tr "\\n" "," | sed 's/,$//'`

 Analysis

The command is split into multiple sub commands.

  • top: displays running processes. With -p option  means monitor specific process IDs.
  • pgrep: Looks through the currently running processes and lists the process IDs which matches the selection criteria (proccess-name).
  • pipe (|): The pipe operator. It is used to direct the stdout of the first command to the stdin of the second command.
  • tr (translate): Is used for replacing or removing specific characters in its input data set. Above: linefeed(\n) is replaced with comma(,) .
  • sed: sed is used to remove the last comma(,) for the list. Sed is a stream editor which are used to perform basic text transformations on an input stream (a file or input from a pipeline). sed‘s ability to filter text in a pipeline particularly distinguishes it from other types of editors.

More

Killing CouchDB on Ubuntu 10.04

I Wanted to do some maintenance and move my couchdb data files to another partition but couchdb would not stop when I called the usual stop commands:

1)sudo /etc/init.d/couchdb stop
2)sudo service couchdb stop

Found a lot of posts and out of all of them found this nice tidbit below:

ps -U couchdb -o pid= | xargs kill -9

 

Note: It’s not the best thing to viciously kill a process. I imagine databases usually have shutdown tasks to do, must end with current insertions, etc. I’ll post if I find a bug fix.

 

Reverse Proxy in Apache2 (Ubuntu 10.04) for CouchDB

Installing Modules

There are various sites with instructions that did not work.
However, following the instructions here> http://abhirama.wordpress.com/2008/11/03/apache-mod_proxy-in-ubuntu/ did the trick.

The reverse proxy module was installed:

sudo apt-get install libapache2-mod-proxy-htm

Libxml was installed:

apt-get install libxml2-dev

More

Backup on Bash Login from other server using SSHFS and RSYNC

Dear All,

Quick little post about a small script I made for backing up some files from a webserver (hosting apache+mysql).

I wanted a script which would remind me to backup whenever I would log onto the specific machine.

I would have preferred automated but I’m a little paranoid about security. Why?
I don’t want to automatically compromise the security of a public webserver if another computer is hacked…so even if the backup server is hijacked no certificate/password will be stored.

Hence running the backup script required an actual user to type in the password.

More

Combine FLV/MP4 Videos Together

Hey, a quick post about a script I wrote for combining together multiple video files.
It’s based on a post from: http://www.webupd8.org/2009/05/join-and-split-files-including-video-in.html

 

Steps during execution

1) The script converts all mp4 and flv files to MPG files.

2) This is done in order to use the CAT command with > to send all the bytes from all files into one location output.mpg.

3) Finally we convert output.mpg  to MP4 and have the final file.

NOTE: I will check into using possible shortcuts to speed up the process.

#!/bin/bash
echo
echo
echo Combine Videos Together
echo based on http://www.webupd8.org/2009/05/join-and-split-files-including-video-in.html
echo ----------------------------------------------------------
sleep 3
for i in *.mp4; do
 if [ -e "$i" ]; then
   file=`basename "$i" .mp4`
   echo converting "$i" to "$file.mpg"
   ffmpeg -i "$i" -sameq "$file.mpg"
 fi
done

for i in *.flv; do
 if [ -e “$i” ]; then
   file=`basename “$i” .flv`
   echo converting “$i” to “$file.mpg”
   ffmpeg -i “$i” -sameq “$file.mpg”
 fi
done

mkdir temp
mv *.mpg temp
cd temp
cat * > output.mpg
ffmpeg -i output.mpg -sameq final.mp4

Samba in Ubuntu 10.04 – file audit log with full_audit

I am going to talk about how to setup auditing on your samba server in order to be able to view logs in case files disappear from shares (etc).
I’m not aware if anyone has written a tutorial for the specific task on a similar setup so I’ll post about what I did.

This is essentially an update to the blog post:  Samba – file audit log with full_audit by Constantin Bosneaga written in October 2009 but Ubuntu 10.04 uses RSYSLOG instead of SYSLOG. If this works in later versions as well I’d appreciate if someone dropped me a line.

Step 1) Configuring Samba

Instructions from here up to Configuring syslog.

“I have samba-3.0.33 on Gentoo machine. File audit will be done using samba module full_audit. More

How to totally disable suspend/hibernation in ubuntu (If all else fails)

Just wanted to share my own experience and the hack I found to deal with it.

If anyone else needs a temporary solution I think it may work for them if there’s a serious problem with ubuntu linux.I set up ubuntu 10.04 on an IBM thinkcenter A50…(OK, that’s what I was given so I made the best of it).Anyway, I would come back to the lab every morning and find the computer in something like sleep but it would not wake up at all. As I had installed a raid array and had a share this was not good….it was a serious problem. More

RAID 6 Backup Server with SAMBA (windows sharing), E-MAIL Monitoring (Ubuntu), and Remote Desktop

This is in need of an update due to dead links and deprecated content.

Today I’m posting to list the tutorials / steps I used to create the a backup server for the Multimedia, Knowledge, and Web Technologies Group at Athens Information Technology – Athens.

A server resulting from the use of the tutorials below will:

  • be accessible from windows PCs.
  • be able to withstand two disk failures without loss of data.
  • e-mail the administrator upon disk failure within the RAID array to take preventive steps.
  • e-mail the administrator on a scheduled basis with disk statuses outlining bad sectors.

So on to the actual good stuff… More