sendmails works, but opens 43 file handles per email -> problem
I'm using Sendmail 8.13.8 on a CentOS 5.5 vServer (Virtuozzo).
I'm using a loop in PHP to send a lot of HTML-mails via sendmail. Each mail is a mail with individual statistics for our users, so its not mass mailing, bcc is not an option.
It all works fine, but when I take a closer look there is a problem heading our way with a high number of mails:
For each mail sendmail opens up 43 files. Sometimes these open files get closed again very fast, sometimes not.
Here is an example using the PHP-script below, it sends 20 mails in a loop:
[root]# php test-mail.php
START: number of open files: 2113
END: number of open files: 2973
This is the worst case. The number of open files (lsof | wc -l) used to send the 20 mails is 860 => 43 open files per mail.
Sometimes the files are closed very fast, so I get results like this, too:
[root]# php test-mail.php
START: number of open files: 2113
END: number of open files: 2242
This shows 129 (3 * 43) open files, so the open files for 17 send mails are already closed, for 3 mails the 129 files are still open.
In the worst case and with lots of mails our server crashes, the numfile limit of 8192 in user_beancounters is reached (our ISP won't give us more than 8192).
Sendmail DeliveryMode is background.
Could it be that sendmail tries to send lots ob mails asyncronously and uses 43 open files for each? I'm only depending on sendmail to deliver the mails, normaly I wouldn't dare to touch the sendmail config (like 'if you don't know what you're doing, don't!').
Any ideas?
BTW: It is not a problem of PHP. I verified this by sending mails via SMTP localhost to sendmail (opened 43 files per mail) and sending mails via SMTP to an ISP-relay (did not open any files per mail).
Thank you very much for reading this,
best,
Andreas
Most of those open files are shared libraries. Some are config files.
Every time you execute a command like mailx -s 'subject' user@my.com < filename
you incur the overhead of loading the shared libraries, and config files.
The beauty of shared libraries is that they are usually memory resident, shared among all processes, so you can actually run several sendmail processes concurrently, and not really impact the system more than if you ran a single instance of it.
root 28089 0.0 0.0 62812 2320 ? Ss Dec10 0:33 sendmail: accepting connections
smmsp 28097 0.0 0.0 57692 1780 ? Ss Dec10 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
Do you think setting the Sendmail DeliveryMode to 'interactice' would help? I read the sendmail documentation, but I'm still not sure what risks it would involve.
This is a strange one.
We have an issue where our system is leaking SCTP file handles. There are people working on this and in the mean time we have a monitoring script that alarms when we need to perform actions to manually clear them. For testing purposes I want to write a script that... (0 Replies)
Hi Thinkers,
On AIX 5.3, we have a monitor program that reads the log file and searching for a certain string pattern that we define(say "transactionException"), if it sees it then it will raise an alert by sending an email.
Because the log file XXX.log is rolling into XXX.log.0, XXX.log.1,... (2 Replies)
Hi there,
If we have 2 apps on our customers machines that can both open files of a certain file extension, is there any way via shell commands to set which application should be the default?
Essentially, I'm hoping to replicate Get Info > Open With > Change All, but using a script.
Thanks... (0 Replies)
Any Idea without entering any keystroke I can go to end of line in vi when I opening the file.
When I am opening Vi I want to goto last line.
when I give vi + filename it does not work.
Any clue why it does not work.
Thanks. (3 Replies)
hello everybody
I´m very new at shell and programming :eek: and i have the following question/problem:
I need a script for framemaker (based on shell) which opens a new document from a template (.fm). Then imports a .doc file and then save it as a .mif.
Actually my script works with one... (3 Replies)
We have a process that is running out of file handles. Is there some command line way to determine this that we can include into a cron script?
Please let me know
JAK (3 Replies)
Hello,
I have a program which opens a pipe for communication using file handle and forks 5 child processes.
@waitlist = (1,2,3,4,5);
foreach $item (@waitlist) {
pipe *{$item},RETHAND;
unless ($pid = fork()) {
# Child process
print RETHAND... (1 Reply)
Hi all
I try to execute SSH commands on several hosts in a while-loop.
There seems to be a problem with file-handle, first cycle works correct but no other one will follow due to the while condition is false even that there are many more host entries (lines) in all_hosts.dat.
... (3 Replies)
Hi,
perhaps you can answer my question.....;)
How can I check, how many file handles are used and how can i increase the value for maximum file handles??? (3 Replies)