msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

04 Nov 2007 Debian daemon control

In RedHat distributions like RHEL, Fedora and also CentOS you have a tool called ntsysv to manage daemons and their runlevels. In Debian there is an alternative tool that lets you determine what daemon you want to run using a text GUI

sysv-rc-conf

It makes it easy to manage which daemons you would like to run like telnet, ssh etc.

If the tool isn’t installed, install it by running the command

apt-get install sysv-rc-conf

Tags: ,

Posted by

25 Oct 2007 Using TCP Wrappers to deny daemon access in specified hours

By doing the following you can deny certain daemons to be available in specified hours by using hosts.allow and hosts.deny.

In my example I will be using the vsftpd daemon by adding

tcp_wrapper=YES

in /etc/vsftpd.conf.

Make sure that your private network has access all the time by adding this in /etc/hosts.allow

vsftpd: 192.168.0.

Enables access to the whole subnet.

Next you create a /etc/cron.d/vsftpd file

0 16 * * 1-5 root perl -i -p -e s/innhold//ig /etc/hosts.deny
0 8 * * 1-5 root echo "vsfdpt:ALL >> /etc/hosts.deny

Reload the cron daemon and you’re good to go.

The above example will deny all addresses, except those specified in hosts.allow, between 08:00 and 16:00 Monday to Friday and clear the block at other times.

Tags: ,

Posted by

04 Jun 2007 Shell script to monitor running services such as web/http, ssh, mail

Shell script to monitor running services such as web/http, ssh, mail etc. If service fails script will send an Email to ADMIN user

monitor-linux-service.bash

#!/bin/bash
# Shell script to monitor running services such as web/http, ssh, mail etc.
# If service fails it will send an Email to ADMIN user
# -------------------------------------------------------------------------
# Copyright (c) 2006 nixCraft project 
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# See URL for more info
# http://www.cyberciti.biz/tips/processing-the-delimited-files-using-cut-and-awk.html
# ---------------------------------------------------
# service port
ports="22 80 25"

# service names as per above ports
service="SSH WEB MAIL"

# No of services to monitor as per (above ports+1)
SCOUNTER=4

#Email id to send alert
ADMINEMAIL="admin@myispname.com"

# counter
c=1
echo "Running services status:"

# use sudo if you want i.e. sudo /bin/netstat
/bin/netstat -tulpn | grep -vE '^Active|Proto' | while read LINE
do
 sendMail=0
 # get active port name and use : as delimiter
 t=$(echo $LINE | awk '{ print $4}' | cut -d: -f2)
 [ "$t" == "" ] && t=-1 || :
 # get service name from $services and : as delimiter
 sname=$(echo $service | cut -d' ' -f$c)
 sstatus="$sname: No"
 # now compare port
 for i in $ports
 do
  if [ $i -eq $t ]; then
   sstatus="$sname: Ok"
    sendMail=1
  fi
 done
 # display service status as OK or NO
 echo "$sstatus"
 #next service please
 c=$( expr $c + 1 )
 [ "$sendMail" == "0" ] && echo $sstatus | mail -s "service down $sstatus" $ADMINEMAIL || :
 # break afer 3 services
 [ $c -ge $SCOUNTER ] && break || :
done

Tags: ,

Posted by