Page 1 of 1

Setting up RAM Drive

PostPosted: Tue Feb 26, 2008 9:44 pm
by gerski
Guys, Have you tried installing RAM DRIVE? how can it help recordings to process? We are planning to buy one like this:

http://techreport.com/articles.x/9312

Thanks...

PostPosted: Wed Feb 27, 2008 12:05 am
by mflorell
I've just used system RAM for a RAM drive in Linux, very easy to set up and it reduced load and hard drive fragmentation tremendously.

PostPosted: Wed Feb 27, 2008 8:14 am
by DarknessBBB
mflorell wrote:I've just used system RAM for a RAM drive in Linux, very easy to set up and it reduced load and hard drive fragmentation tremendously.


Hello Matt, where can I find documentation about setting up a ram drive using linux system ram? :oops:
Do I need a cron script that transfers recordings every n minutes from ramdrive to HD?

PostPosted: Wed Feb 27, 2008 9:20 am
by mflorell
The info is right in the scratch install doc:
http://astguiclient.sourceforge.net/scr ... stall.html

First you need to set kernel options for a RAM drive when building your Linux Kernel:
Device Drivers --->
Block devices --->
<*> Loopback device support
<*> RAM disk support
(1) Default number of RAM disks
(512000) Default RAM disk size (kbytes)
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(ONLY USE THE ABOVE 4 SETTINGS IF YOU WILL BE SETTING UP A RAM DRIVE FOR RECORDING)

Then you need to activare the RAM drive upon boot(/etc/rc.d/rc.local):
### uncomment If kernel RAM drive is enabled
# mke2fs -m 0 /dev/ram0
# mount /dev/ram0 /var/spool/asterisk/monitor

PostPosted: Fri Mar 07, 2008 2:47 am
by aster1
In linux 2.6 you can also use tmpfs or ramfs .

just mkdir /ramdrive
mount tmpfs /ramdrive -t tmpfs -o size=200M,mode=0777

You can also specify ramfs instead of tmpfs ( i am not sure about difference but from what i have read both use ram for storage ) . After that
edit /etc/fstab
add
tmpfs /ramdisk tmpfs mode=0777,size=200M 0 0

edit /etc/rc.local
mkdir /ramdisk/monitor
mkdir /ramdisk/monitor/ORIG
mkdir /ramdisk/monitor/DONE

end rc.local

make a static directory for holding recordings on hard disk
mkdir /home/voice
mkdir /home/voice/monitor
mkdir /home/voice/monitor/DONE


rm -f /var/spool/asterisk/monitor
ln -s /ramdrive/monitor /var/spool/asterisk/monitor

After that run a script like:
##
perl /usr/share/astguiclient/AST_mix_recordings_BASIC.pl
cd /ramdisk/monitor/ORIG
ls|xargs rm -f
# ( i delete all original files since above script joins files and put them in #DONE folder, ignore this line if you want that )

cd /ramdisk/monitor/DONE
ls|xargs -i mv {} /home/voice/monitor/DONE

##

Run above script every 10 minutes using cron . Also make sure to run the script at server shutdown ( linking in runlevel depending on distribution ) so you wont lose any unmixed files .

I have a few questions :

Is using and formatting /dev/ram0 a better option instead of using tmpfs/ramfs ? By default ubuntu kernel makes ram disk of 65 mb each , i believe this can be changed using kernel parameters . Is above method a proper way of doing this ? :oops:

PostPosted: Sat Mar 08, 2008 12:10 am
by mflorell
I have always had very good results using the instructions I posted in the scratch install doc. There are several ways to set up RAM drives, but that way is most universal for even older systems and seems to not have any downsides.

PostPosted: Mon Mar 17, 2008 2:15 pm
by pylinuxian

PostPosted: Mon Mar 17, 2008 2:51 pm
by pylinuxian
in /boot/grub/grub.conf add ramdisk_size=66000
so that it should look like this :

kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 ramdisk_size=1000000



in /etc/rc.d/rc.local : add or uncomment this :

### start ram drive for recordings
#/sbin/mke2fs -m 0 /dev/ram0
#/bin/mount /dev/ram0 /var/spool/asterisk/monitor
#/bin/mkdir /var/spool/asterisk/monitor/DONE
#/bin/mkdir /var/spool/asterisk/monitor/ORIG

beware you ll have to copy the files to an nfs drive every time the ram drive is full & before any reboot.

PostPosted: Thu Jun 19, 2008 1:22 pm
by Op3r
now the main question is how do you transfer it every 10 minutes or so?

PostPosted: Thu Jun 19, 2008 7:11 pm
by mflorell
On some higher-load systems we will use tmpfs and run transfers of recordings every 1-3 minutes.

PostPosted: Thu Jun 19, 2008 7:17 pm
by Op3r
matt

do you have a script to transfer the said recordings from DONE to any directory?

Im actually bashing my head as I am actually ftp'ing it to localhost but most of the time the script wont work as I am using 2.0.3 (as they dont want to upgrade cos they said if it is not broken dont fix it)

:(

PostPosted: Thu Jun 19, 2008 10:29 pm
by gardo
Here's a simple bash script to do it:

#!/bin/sh

cd /var/spool/asterisk/monitor/DONE/
for X in *.gsm
do
mv $X /directory/of/choice
done


Put it in your crontab and run every 10 mins or so. You might also want to integrate "nice" to it so it runs with a lower priority.

PostPosted: Fri Jun 20, 2008 7:07 am
by Op3r
ok I give up

can I just do this?

exten => 8309,1,Answer
exten => 8309,2,MixMonitor(${CALLERIDNAME}.gsm||/root/move_file.sh ${CALLERIDNAME}.gsm)
exten => 8309,3,Wait,3600
exten => 8309,4,Hangup

it will mixmonitor it then the file move_file.sh will be called

this is what on the move_file.sh

#!/bin/sh

cd /var/spool/asterisk/monitor
for X in $1
do
mv $1 /home/recordings
done


so that it will transfer to the hard drive. will this affects anything except the load?

PostPosted: Fri Jun 20, 2008 7:44 am
by Op3r
here's another step im trying

I tried the AST_CRON_mix_recordings_GSM.pl from 2.0.4 to 2.0.3

I guess it was ok but then I get this error

a.gsm': No such file or directory
Net::FTP>>> Net::FTP(2.77)
Net::FTP>>> Exporter(5.58)
Net::FTP>>> Net::Cmd(2.29)
Net::FTP>>> IO::Socket::INET(1.29)
Net::FTP>>> IO::Socket(1.29)
Net::FTP>>> IO::Handle(1.25)
Net::FTP=GLOB(0x8aad2e4)<<< 220 (vsFTPd 2.0.5)
Net::FTP=GLOB(0x8aad2e4)>>> USER recordings
Net::FTP=GLOB(0x8aad2e4)<<< 331 Please specify the password.
Net::FTP=GLOB(0x8aad2e4)>>> PASS ....
Net::FTP=GLOB(0x8aad2e4)<<< 230 Login successful.
Net::FTP=GLOB(0x8aad2e4)>>> CWD RECORDINGS
Net::FTP=GLOB(0x8aad2e4)<<< 550 Failed to change directory.
Net::FTP=GLOB(0x8aad2e4)>>> TYPE I
Net::FTP=GLOB(0x8aad2e4)<<< 200 Switching to Binary mode.
Cannot open Local file /20080620-053339_7920803185_UK_rea.gsm: No such file or directory
at ./AST_CRON_mix_recordings_GSM.pl line 193
Net::FTP=GLOB(0x8aad2e4)>>> QUIT
Net::FTP=GLOB(0x8aad2e4)<<< 221 Goodbye.
mv: cannot move `/var/spool/asterisk/monitor/20080620-053431_2084710327_UK_rea.gsm' to `/ORIG/20080620-053431_2084710327_UK_rea.gsm': No such file or directory
mv: cannot move `/var/spool/asterisk/monitor/20080620-053431_2084710327_UK_rea.gsm' to `/ORIG/20080620-053431_2084710327_UK_rea.gsm': No such file or directory
Net::FTP=GLOB(0x8ad626c)<<< 220 (vsFTPd 2.0.5)
Net::FTP=GLOB(0x8ad626c)>>> USER recordings
Net::FTP=GLOB(0x8ad626c)<<< 331 Please specify the password.
Net::FTP=GLOB(0x8ad626c)>>> PASS ....
Net::FTP=GLOB(0x8ad626c)<<< 230 Login successful.
Net::FTP=GLOB(0x8ad626c)>>> CWD RECORDINGS
Net::FTP=GLOB(0x8ad626c)<<< 550 Failed to change directory.
Net::FTP=GLOB(0x8ad626c)>>> TYPE I
Net::FTP=GLOB(0x8ad626c)<<< 200 Switching to Binary mode.
Cannot open Local file /20080620-053431_2084710327_UK_rea.gsm: No such file or directory
at ./AST_CRON_mix_recordings_GSM.pl line 193
Net::FTP=GLOB(0x8ad626c)>>> QUIT
Net::FTP=GLOB(0x8ad626c)<<< 221 Goodbye.


any hints?

hello

PostPosted: Fri Jun 20, 2008 12:24 pm
by eliasferreyra
i thisnk thats in slackware

how can i do a ramdrive on centos?

does anybody have any document

PostPosted: Fri Jun 20, 2008 1:14 pm
by pylinuxian
i thisnk thats in slackware
how can i do a ramdrive on centos?
does anybody have any document


its a kernel thing not a disto one. so it applies to everywhere.

this was on a CentOS machine.

in /boot/grub/grub.conf add ramdisk_size=1000000
so that it should look like this :

kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 ramdisk_size=1000000
in /etc/rc.d/rc.local : add or uncomment this :
### start ram drive for recordings
#/sbin/mke2fs -m 0 /dev/ram0
#/bin/mount /dev/ram0 /var/spool/asterisk/monitor
#/bin/mkdir /var/spool/asterisk/monitor/DONE
#/bin/mkdir /var/spool/asterisk/monitor/ORIG

beware you ll have to copy the files to an nfs drive every time the ram drive is full & before any reboot.

PostPosted: Fri Jun 20, 2008 1:19 pm
by pylinuxian
Net::FTP=GLOB(0x8aad2e4)<<< 550 Failed to change directory.


wrong directory name, missing directory or wrong permissions.
so check vsftpd.log on host machine.

PostPosted: Sat Jun 21, 2008 1:47 am
by Op3r
I saw the mistake, I have a wrong ftp directory on the astguiclient.conf as the new recording scripts takes a look at that file.

and Im gonna still try to ftp the recordings later.

PostPosted: Sat Jun 21, 2008 2:33 am
by codehaxor
so is it ok to have a 2GB RAM drive and just use the mp3.pl script in the crontab to upload files to a local ftp server once in a while?

PostPosted: Sat Jun 21, 2008 4:19 am
by pylinuxian
so is it ok to have a 2GB RAM drive and just use the mp3.pl script in the crontab to upload files to a local ftp server once in a while?


With two Gigs ... I guess you could wait untill agents are in pause time ;) that way you stay light on the server but yes you can do it.

I would also avoid compressing the recordings on the dialer itself, I would do it on ftp host instead.