Shell Script to Delete Empty Files in Directory

Script to delete all empty files in a directory. This was specially designed for directories that have hundreds of thousands of files in them (ls has a limitation for directories with a large number of files in them, so find must be used)



#!/bin/bash
# Example: ./delete_empty_files.sh /home/random_files/

usage()
{
        echo "Usage: $0 Directory_Name"
        exit 1;
}

test -d "$1" || usage

function test_and_delete()
{
  while read line1; do
     size=`stat -c %s $line1`
     if [ $size -lt 1 ]; then
     #echo "$line1 is $size ( This one is empty ) "
     rm -f $line1
  else
     #echo "$line1 is $size "
  fi
  done
}
cd $1
find -name "*" | test_and_delete



Provisioning WS-C3550-24PWR-SMI For Use With Polycoms

Provisioning WS-C3550-24PWR-SMI From Default Settings

Connect via console cable and configure hostname, telnet access and passwords using wizard at boot first time

Create voice and data vlan
3550(config)#vlan 2
3550(config-vlan)#name data
3550(config-vlan)# 790
3550(config-vlan)#name voice
Configure IP address on voice vlan
3550(config)#interface Vlan 790
3550(config-if)#ip address 192.168.16.2 255.255.255.0
Configure the default gateway
3550(config)# ip default-gateway 192.168.16.1
Configure gigbit ports as trunk ports to router or downstream switches
3550(config)#interface range gigabitEthernet 0/1 - 2
3550(config-if)# switchport trunk encapsulation dot1q
3550(config-if)# switchport trunk allowed vlan 2,790
3550(config-if)# switchport mode trunk
Configure 24 fastethernet ports as trunk ports for phones and/or computers. Vlan 790 will be tagged and vlan 2 (the native vlan) will be untagged. Note: the untagged vlan is called the "native vlan" when the switchport mode is "trunk". The untagged vlan is called the "access vlan" when the switchport mode is "access".
3550(config)#int range fastEthernet 0/1 - 24
3550(config-if-range)# switchport trunk encapsulation dot1q
3550(config-if-range)# switchport trunk native vlan 2
3550(config-if-range)# switchport mode trunk

Resolving Inline Power Issue

When using a WS-C3550-24PWR-SMI with a default config a Polycom 335 using POE cannot successfully boot up. During the bootup process just before the Polycom typically displays the networking information on the screen, the Polycom restarts its ethernet interface. By default the Cisco 3550 stops sending power to the port when it detects the link is down which causes the phone to lose power and restart. To remedy this problem the 3550 interface can be configured to delay turning off power to port for a defined number of seconds after it detects the link is down.

power inline delay {shutdown seconds initial seconds}

The initial time period begins when the powered device is detected by the switch. If linkdown occurs
on the connected device during the initial time period, the shutdown time determines
how long the switch continues to provide power to the device.
3550(config)# int range fastEthernet 0/1 - 24
3550(config-if-range)# power inline delay shutdown 20 initial 300
By applying the above command to an interface the switch will continue to provide power to the device 20 seconds after linkdown and the power shutdown delay will be in effect for the first 300 seconds. It may be necessary to upgrade IOS image to c3550-ipservicesk9-mz.122-44.SE6.bin as the power inline command is not available in older versions.


Upgrading the IOS image

Obtain a copy of the new IOS image and place on TFTP server. c3550-ipservicesk9-mz.122-44.SE6.bin will be used as an example. Note: an EMI image (enhanced software) can run on SMI hardware.

Show contents of flash and the space left (listed at the bottom)
Make sure there is enough room for the new ISO image
3550# dir flash:
Directory of flash:/
    2  -rwx        2177   Mar 01 1993 00:07:02  config.text
    3  -rwx           5   Mar 01 1993 00:07:02  private-config.text
    4  -rwx         676   Mar 01 1993 00:41:24  vlan.dat
   21  -rwx     3334765   Mar 02 1993 03:09:04  c3550-i9q3l2-mz.121-14.EA1a.bin
15998976 bytes total (6278656 bytes free)
To delete a file
3550# delete flash:c3550-i9q3l2-mz.121-14.EA1a.bin
Delete filename [c3550-i9q3l2-mz.121-14.EA1a.bin]?
Delete flash:c3550-i9q3l2-mz.121-14.EA1a.bin? [confirm]
 To see contents of a folder
3550# dir c3550-i5q3l2-mz.121-11.EA1
To delete a folder
3550# delete /force /recursive c3550-i5q3l2-mz.121-11.EA1
3550# Delete filename [c3550-i5q3l2-mz.121-11.EA1]?

Download and install IOS image. It should also update the boot statement
3550#copy tftp://tftp-server-ip/c3550-ipservicesk9-mz.122-44.SE6.bin flash://c3550-ipservicesk9-mz.122-44.SE6.bin
Verify the image was corrupted in transfer
3550#verify /md5 flash:c3550-ipservicesk9-mz.122-44.SE6.bin
..........................Done!
verify /md5 (flash:c3550-ipservicesk9-mz.122-44.SE6.bin) = a829d14ab1ccd3ecf77b99d025d188ce
Tell the switch to use the new IOS image
3550(config)#boot system flash:c3550-ipservicesk9-mz.122-44.SE6.bin
Confirm the new boot statement is correct
3550 # show boot
BOOT path-list:       flash:c3550-ipservicesk9-mz.122-44.SE6.bin
Config file:          flash:/config.text
Private Config file:  flash:/private-config.text
Enable Break:         no
Manual Boot:          no
HELPER path-list:  
NVRAM/Config file
      buffer size:    393216
Save any changes made to the config
3550#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
Restart the switch
3550#reload
After restart, confirm switch is running new IOS
3550# show version
Cisco IOS Software, C3550 Software (C3550-IPSERVICESK9-M), Version 12.2(44)SE6, RELEASE SOFTWARE (fc1)
...
System image file is "flash:c3550-ipservicesk9-mz.122-44.SE6.bin"
...

Mediatrix 1124 5.0.24.172 MWI Woes

The mediatrix mwi subscription has never seemed to work quite right. Below is a list of the caveats I've noticed.

Caveat 1:
Summary: If the subscription timer (.1.3.6.1.4.1.4935.15.100.1.20 mwiExpirationTime) seems to be anything other than 180 seconds (the minimum) it does not seem to send the re-subscribe before the session expires like it should.
Explanation: When the subscription timer is set to 180, the mediatrix consistently re-subscribes every 120 seconds. When the subscription timer is set to 300 or 600, the mediatrix does not send the re-subscribe message. It instead waits for the subscription to expire producing the syslog message
SipEngine [0204] L2 subscription terminated, server shutting down, will retry subscription in 2 minutes.
All subsequent NOTIFY messages from the switch receive a 487 REQUEST TERMINATED until the mediatrix re-subscribes. It seems that it re-subscribes the next time it registers, or two mins after its subscription expired (which ever comes first)

Caveat 2:
Summary: The mediatrix breaks its subscription if it receives a NOTIFY for a line shortly after the line has been hung up.
Explanation. If the mediatrix receives a NOTIFY for a line just after that line has been hung up, it returns a 400 INVALID MESSAGE-SUMMARY. This causes the switch to drop the subscription and the end user to not get any notifications until later when the mediatrix tries to re-subscribe when it thinks the session expires. At this point the mediatrix tries to re-subscribe but since the switch has already dropped the subscription, it returns a 481 Call/Transaction Does Not Exist. The mediatrix sends a new subscribe a few mins later and succeeds. I suspect this problem has something to do with the state the mediatrix is in just after line is hung up, and the mediatrix just handles it poorly.

Here is summary of the tests I performed


mediatrix is registering with sip server in router every 2 mins for rate pacing purposes, but router only allowing registers to central office every 1800 seconds


Subscription Timer Set for 180 seconds (3 mins) and empty vm box
0  seconds - mediatrix sends SUBSCRIBE receives OK, immediately gets NOTIFY returns OK
2 mins - 120 seconds -mediatrix sends SUBSCRIBE receives OK, immediately gets NOTIFY returns OK
4 mins - 240 seconds - mediatrix sends SUBSCRIBE receives OK, immediately gets NOTIFY returns OK
Continue.



Subscription Timer Set for 300 seconds (5 mins) and empty vm box
0  seconds - mediatrix sends SUBSCRIBE receives OK, immediately gets NOTIFY returns OK
3 mins -180 seconds - gets unsolicited notify from NMS and mediatrix responds with OK
5 mins - 300 seconds - gets unsoliticted notify from NMS and mediatrix responds with 487 Request Terminated
6 mins - 360 seconds - mediatrix sends REGISTER to router (which doesn't make it to nms) and sends SUBSCRIBE (which does make it to nms). Nms responds with NOTIFY and the mediatrix OKs it.
Repeat.

Subscription timer set for 600 seconds (10 mins) and empty vm box
0  seconds - mediatrix sends SUBSCRIBE receives OK, immediately gets NOTIFY returns OK
3 mins - 180 seconds - gets unsolicited NOTIFY from NMS and mediatrix responds with OK
6 mins - 360 seconds - gets unsolicited NOTIFY from NMS and mediatrix responds with OK
9 mins - 540 seconds - gets unsolicited NOTIFY from NMS and mediatrix responds with OK
10 mins - 600 seconds - gets unsoliticted NOTIFY from NMS and mediatrix responds with 487 Request Terminated
12 mins - 720 seconds - mediatrix sends REGITSTER to router (which doesn't make it to nms b/c of rate pacing) and sends SUBSCRIBE (which does make it to nms). Nms responds with NOTIFY and the mediatrix OKs it.
Repeat.

Rsyslog

Wrote a customer Rsyslog.conf file to parse output from edgewater's edgemarc devices.

Things to remember:
using the optimized mysql module ommysql.

The following rule is what writes to the SystemEvents table using the default template
*.*     :ommysql:127.0.0.1,Syslog,syslogwriter,

I need to start rolling /var/log/messages

RT Exchange Loop

When someone submits a reply or ticket from a no-reply email address it is creating an email loop even with RT's StoreLoop enabled.

The email get sent in to create the reply. RT attempts to acknowledge it got the reply by responding to the reply. It delivers an outbound email to exchange which tries to deliver the email to the no-reply email address. Google comes back and says there is no account for that no-reply address. Exchange sends an email to RT saying that it will not continue to attempt to deliver this message. RT responds to this email. Enter loop.

iperf

wget https://downloads.sourceforge.net/project/iperf/iperf-2.0.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fiperf%2F&ts=1306362724&use_mirror=cdnetworks-us-2
tar -xvzf iperf-2.0.5.tar.gz
cd iperf-2.0.5
./configure
make
make install
iperf -c 69.68.5.149 -u -b 10m

fetchmail with RT

edit config for fetchmail in /etc/fetchmail

/etc/init.d/fetchmail start
to start fetchmail


poll remote.tlcl.net    proto pop3:
auth password
username rt                     password *****   mda "/opt/rt3/bin/rt-mailgate --url http://url --queue General --action correspond"