FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

 
Thread Tools Display Modes
Old 03-28-2004, 05:26 PM   Postid: 109601
Javier Mosqueda
Registered User

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: Querétaro México
Posts: 147
Script to warn about disk usage

Hi, I've had a couple of issues with my clients regarding the disk usage and automatic disk allocation.

I've played around with calls to the shell from Perl, to execute "du --max-depth=10" and it works just fine as far as web space, but I also need to know how to retrieve the space used by email (either box by box and/or all the e-mail space together).

My intention is to monitor the usage with a crontab once every 12 hours, and if high usage (say over 150 MB in total=auto extra space triggered), start e-mailing to the responsible and to me every 12 hours as well. Once the usage reduces, the later mailing stops, and my script mails to me a notice so I request to you to cancel the extra space.

That's ok with me, unless you have a better way I can use to do the same, the bottom line is to avoid the charge for the extra space.

Regards
__________________
[b]Javier Mosqueda[/b]
Javier Mosqueda is offline  
Old 03-28-2004, 05:39 PM   Postid: 109604
 sheila
Service Rep
 
sheila's Avatar
 
Join Date: Aug 1999
Location: Metro Los Angeles Area
Posts: 7,302
Hello Javier,

To find the disk usage for email, you need to use the vdu command.

It is discussed in the following forum posts:
http://www.aota.net/forums/showthrea...&highlight=vdu
http://www.aota.net/forums/showthrea...&highlight=vdu
http://www.aota.net/forums/showthrea...&highlight=vdu

Hope that helps to point the way...
sheila is offline  
Old 03-29-2004, 09:40 AM   Postid: 109645
Javier Mosqueda
Registered User

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: Querétaro México
Posts: 147
Good!!!

Thanks Sheila,

I read the links you show; that's what I need. Thanks for the meaning of the numbers and (disabled) message, next to each account name.

On a background question. I've typed man vdu and vdu --help. The first one is not available. The second one gives a very brief information. Google shows links to some vdu that relates to "video".

Is this vdu a command "created" by FQ or is it a new GNU command, etc.?
__________________
[b]Javier Mosqueda[/b]
Javier Mosqueda is offline  
Old 03-30-2004, 04:35 PM   Postid: 109731
 Bruce
Developer
 
Bruce's Avatar
 
Join Date: Apr 2001
Location: Saskatoon, SK, Canada
Posts: 1,121
Re: Good!!!

Quote:
Originally posted by Javier Mosqueda:
Is this vdu a command "created" by FQ or is it a new GNU command, etc.?
vdu is indeed a command created by FQ to communicate with the POP toaster and determine how much disk space is in use, similar to how the standard du command works. The single option (-a or --all) was also copied from the du command.
__________________
Bruce Guenter, FutureQuest http://www.FutureQuest.net/ http://untroubled.org/
Bruce is offline  
Old 03-30-2004, 08:26 PM   Postid: 109747
Javier Mosqueda
Registered User

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: Querétaro México
Posts: 147
Very nice, thanks Bruce

With the given help, I prepared 2 Perl scripts. A crontab configured to run a script every 3 hours calls the firstone which does a couple of "system" calls, one to du, and a second to vdu. The output of this first script is piped to a second one that parses the information in an easy-to-read way. Finally, the parsed information is redirected (>) to a textfile, (consumo.txt) located at root directory of my domain (the same scripts installed in my clients' cgi-bin)

The parser script (second one) also calculates a total of kb in mails (showing total messages inside parentheses) and subdirectories under the www (not including www itself, which I try to keep at 0.5 MB as the maximum, and not including stats).

Not done yet, still pending is the warning using a sendmail when total goes near 150 MB.

Thanks to all.
__________________
[b]Javier Mosqueda[/b]

Last edited by Javier Mosqueda : 03-30-2004 at 08:41 PM.
Javier Mosqueda is offline  
Old 03-31-2004, 01:09 PM   Postid: 109790
Javier Mosqueda
Registered User

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: Querétaro México
Posts: 147
Problem with this...

A small problem appeared with the report (consumo.txt) placed at 3 domains (allow me to write those names with "some symbols" to prevent search engines to list them, just remove the symbols).

come&%$carneÇÇÇÇÇ.org
my&%$infinity&%$glassÇÇÇÇÇÇ.com

and domain shown in signature.

1.- The crontab is working every 3 hours, no problem
2.- In report at 9:00 AM (report is labeled 1 hour earlier for my local hour), and at 12 AM available now, some domains report mailboxes and some domains do not, it seems vdu did not produce an output at that moment.
3.- At 9 and at 12 I went via telnet to every domain's cgi-bin and typed

./alldu.pl|./allduprocess.pl

which reported correctly both directories and mailboxes, so both du and vdu worked ok.

(alldu.pl just does a "system" to du and another to vdu, allduprocess.pl parses the piped listing to make the consumo.txt report)

(scripts don't have the content-type clause, since they are not intended to be called via web, but called just internally to produce the consumo.txt file, that can be seen vía web at "http://domain.tld/consumo.txt")

The question is why sometimes allduprocess.pl does not receive the vdu listing to parse it as usual?
__________________
[b]Javier Mosqueda[/b]
Javier Mosqueda is offline  
Old 03-31-2004, 01:17 PM   Postid: 109791
 Bruce
Developer
 
Bruce's Avatar
 
Join Date: Apr 2001
Location: Saskatoon, SK, Canada
Posts: 1,121
Re: Problem with this...

Quote:
Originally posted by Javier Mosqueda:
The question is why sometimes allduprocess.pl does not receive the vdu listing to parse it as usual?
If the POP toaster cannot produce the report in a timely fashion (within 15 seconds), vdu will time out and drop the connection. If this happens, vdu will exit non-zero so you can test this from your script.
__________________
Bruce Guenter, FutureQuest http://www.FutureQuest.net/ http://untroubled.org/
Bruce is offline  
Old 03-31-2004, 01:45 PM   Postid: 109794
Javier Mosqueda
Registered User

Forum Notability:
26 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: Querétaro México
Posts: 147
Thanks Bruce:

I put the $exitcode = system 'vdu' call inside a while loop, limited to 20 calls or $exitcode == 0

Regards
__________________
[b]Javier Mosqueda[/b]
Javier Mosqueda is offline  


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 02:18 PM.


Running on vBulletin®
Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2010 FutureQuest, Inc.
FutureQuest, Inc.