0

Abstract: I need a way to monitor cifs mountpoints and I don't know how.

Hello,

I have a virtual machine with 2 CPU and 1Gb RAM running debian 5.

It mounts some of our users cifs shared folders, 200 cifs mountpoints approx.

There is an apache server running which analyses this cifs looking for specific files called cv.html and personal_info.txt. The apache has some php to make it nice. ;)

At the begging I was having some troubles and no time, so a secretary is managing a file with all the usernames and a cron reads it to mount them.

Once a day everything gets remounted, this is because of some kind of 'disconnection issue' I can not figure out how to fix it.

This is my script: (/var/www/fotos/llistat_personal.txt has a list of names)

#!/bin/sh

#############################debug
#set -x
#############################

#############################vars
UMOUNT=/bin/umount
MOUNT=/sbin/mount.cifs
CHOWN=/bin/chown
############################

############################functions
log (){
    /usr/bin/logger -t `basename $0` $1;
}

desmontar () {
    $UMOUNT $1
    log "Umounted $1"
}

montar (){
    [ -a /var/www/$1 ] &&  chown -R www-data.www-data /var/www/$1 || mkdir -p /var/www/$1  &&  chown -R www-data.www-data /var/www/$1 || echo "Error ___ $1"
    $MOUNT //fbmfsu/home$/$1/web_pub/ /var/www/$1/ -o user=webpersonal1,pass=XXXXXXX,dom=FBM,uid=33,gid=33,ro,soft,nocase,noexec  || echo " Error___mount__$1"
    log "Mounted $1 "
}


###########################
###########################main
for i in `ls -l /var/www/personal/|grep ^d|awk '{print $8}'`
do
    desmontar $i
done

for i in ` cat /var/www/fotos/llistat_personal.txt |grep -v '^#'| cut -c 1-20`
do
    montar $i
done

exit 0

I know it's a bad script, but I'm here asking for help on how to improve it.

Thanks.

2
  • What is your goal? You want the script improved somehow? Or you want a better way of monitoring some facet of cifs shares, or servers, or the network?
    – Chris S
    Oct 7, 2010 at 17:49
  • My goad is to improve the script, yes. And I believe that I need a good way to monitorize de cifs mountpoints on the linux side.
    – Marc Riera
    Oct 8, 2010 at 7:38

1 Answer 1

1

You are mounting read-only so I assume you don't need write access.

Why not just mount //fbmfsu/home$ once using a special service account on your fileserver with read-only access into all the user's folders and create lots of symlinks. Or use mod_userdir?

Or as another alternative use something like autofs which will automatically mount/unmount shares on access.

2
  • Yes, read-only, no need to write. I can not mount //fbmfsu/home$/ because of our privacy policy. I can only access directly to the //fbmfsu/home$/user.name/web_pub/.
    – Marc Riera
    Oct 8, 2010 at 7:41
  • mod_userdir: If I use mod_userdir I will have to mount all the cifs anyways because of the privacy policy.
    – Marc Riera
    Oct 8, 2010 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .