PHP uses rdkafka to produce messages that hang for 100ms - php

when i use rdkafka produce message in php, The program will hang 100ms
My code reference is this website https://switchcaseblog.wordpress.com/2017/01/20/how-to-get-php-and-kafka-to-play-nicely-and-not-do-it-slowly/
php version: PHP 7.0.13
rdkafka version:
version => 3.0.5
build date => Dec 23 2017 20:38:03
librdkafka version (runtime) => 0.11.3
produce config:
'request.required.acks' => 0,
'message.timeout.ms' => 300,
'queue.buffering.max.ms' => 1,
'message.max.bytes' => 3000000,
'socket.keepalive.enable' => true
so i strace the php process, The following code:
21:05:07.395746 fcntl(4, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0
21:05:07.395799 fcntl(4, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0
21:05:07.395828 munmap(0x7f9036659000, 1106) = 0
21:05:07.395853 close(5) = 0
21:05:07.396263 futex(0x7f902be5e580, FUTEX_WAKE_PRIVATE, 2147483647) = 0
21:05:07.396484 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.396531 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f900641a000
21:05:07.396577 mprotect(0x7f900641a000, 4096, PROT_NONE) = 0
21:05:07.396614 clone(child_stack=0x7f9006e19e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f9006e1a9d0, tls=0x7f9006e1a700, child_tidptr=0x7f9006e1a9d0) = 22018
21:05:07.396696 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], ~[KILL STOP RTMIN RT_1], 8) = 0
21:05:07.396764 pipe([5, 6]) = 0
21:05:07.396833 fcntl(5, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.396858 fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.396880 fcntl(6, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.396902 fcntl(6, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.396926 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9005a19000
21:05:07.396962 mprotect(0x7f9005a19000, 4096, PROT_NONE) = 0
21:05:07.397013 clone(child_stack=0x7f9006418e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f90064199d0, tls=0x7f9006419700, child_tidptr=0x7f90064199d0) = 22019
21:05:07.397107 rt_sigprocmask(SIG_SETMASK, ~[KILL STOP RTMIN RT_1], NULL, 8) = 0
21:05:07.397137 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.397191 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.397219 pipe([7, 8]) = 0
21:05:07.397245 fcntl(7, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.397268 fcntl(7, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.397290 fcntl(8, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.397311 fcntl(8, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.397335 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9005018000
21:05:07.397372 mprotect(0x7f9005018000, 4096, PROT_NONE) = 0
21:05:07.397421 clone(child_stack=0x7f9005a17e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f9005a189d0, tls=0x7f9005a18700, child_tidptr=0x7f9005a189d0) = 22020
21:05:07.397469 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.397507 rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
21:05:07.397534 pipe([9, 10]) = 0
21:05:07.397560 fcntl(9, F_GETFL) = 0 (flags O_RDONLY)
21:05:07.397582 fcntl(9, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
21:05:07.397604 fcntl(10, F_GETFL) = 0x1 (flags O_WRONLY)
21:05:07.397626 fcntl(10, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
21:05:07.397650 mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f9004616000
21:05:07.397687 mprotect(0x7f9004616000, 4096, PROT_NONE) = 0
21:05:07.397733 clone(child_stack=0x7f9005015e90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f90050169d0, tls=0x7f9005016700, child_tidptr=0x7f90050169d0) = 22021
21:05:07.397781 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:05:07.398147 write(1, "\350\200\227\346\227\2666\346\257\253\347\247\222", 13耗时6毫秒) = 13
21:05:07.398203 write(1, "\n", 1
) = 1
21:05:07.398318 close(2) = 0
21:05:07.398347 close(1) = 0
21:05:07.398372 munmap(0x7f903665a000, 4096) = 0
21:05:07.398433 close(0) = 0
21:05:07.398456 munmap(0x7f903665b000, 4096) = 0
21:05:07.398490 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1514034307, 399482000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
21:05:07.399575 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.399602 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 3, {1514034307, 400596000}, ffffffff) = -1 ETIMEDOUT (Connection timed out)
21:05:07.400684 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.400710 futex(0x212e19c, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 5, {1514034307, 401704000}, ffffffff) = 0
21:05:07.401209 futex(0x212e170, FUTEX_WAKE_PRIVATE, 1) = 0
21:05:07.401268 futex(0x212e25c, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x212e258, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
21:05:07.401316 futex(0x7f9006e1a9d0, FUTEX_WAIT, 22018, NULL) = 0
21:05:07.502855 munmap(0x7f8ff75ff000, 10489856) = 0
21:05:07.503046 fcntl(4, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
21:05:07.503295 munmap(0x7f9006e1b000, 67108864) = 0
21:05:07.503417 close(4) = 0
21:05:07.503530 munmap(0x7f902be63000, 2182736) = 0
21:05:07.503580 munmap(0x7f902bbac000, 2844152) = 0
21:05:07.503662 munmap(0x7f902c078000, 2186600) = 0
21:05:07.503776 munmap(0x7f902c954000, 2129096) = 0
21:05:07.503811 munmap(0x7f902c740000, 2176864) = 0
21:05:07.503842 munmap(0x7f902c503000, 2343352) = 0
21:05:07.503891 munmap(0x7f902c28e000, 2574912) = 0
21:05:07.503939 munmap(0x3e5ea00000, 2109528) = 0
21:05:07.503988 munmap(0x7f902cb5c000, 2111520) = 0
21:05:07.504095 munmap(0x7f902cd60000, 2108464) = 0
21:05:07.504151 munmap(0x7f902cf63000, 2129280) = 0
21:05:07.504242 munmap(0x7f902d7ec000, 2155960) = 0
21:05:07.504277 munmap(0x7f902d581000, 2533392) = 0
21:05:07.504332 munmap(0x7f902d9fb000, 2163080) = 0
21:05:07.504421 munmap(0x7f900ae1b000, 2113976) = 0
21:05:07.504479 munmap(0x7f900b020000, 2113944) = 0
21:05:07.504524 munmap(0x7f900b225000, 2126432) = 0
21:05:07.504560 munmap(0x7f900b42d000, 2113976) = 0
21:05:07.504601 munmap(0x7f900b9a6000, 2117960) = 0
21:05:07.504630 munmap(0x7f900b632000, 3618944) = 0
21:05:07.504668 futex(0x7f902dedc040, FUTEX_WAKE_PRIVATE, 2147483647) = 0
21:05:07.504712 munmap(0x7f902dc0c000, 2956168) = 0
21:05:07.504857 munmap(0x7f902e8b1000, 2514584) = 0
21:05:07.504918 munmap(0x7f902e58d000, 3293152) = 0
21:05:07.504966 munmap(0x7f902e0eb000, 4856016) = 0
21:05:07.505086 munmap(0x7f902dede000, 2150272) = 0
21:05:07.505151 munmap(0x7f902ed31000, 2144104) = 0
21:05:07.505194 munmap(0x7f902eb17000, 2202200) = 0
strace -c php scritp.php
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
95.15 0.001000 59 17 3 futex
4.85 0.000051 0 742 615 open
0.00 0.000000 0 97 read
0.00 0.000000 0 9 write
0.00 0.000000 0 129 close
0.00 0.000000 0 77 49 stat
0.00 0.000000 0 148 fstat
0.00 0.000000 0 57 1 lstat
0.00 0.000000 0 2 poll
0.00 0.000000 0 8 3 lseek
0.00 0.000000 0 259 1 mmap
0.00 0.000000 0 127 mprotect
Futex takes about 100ms, how to solve it
who can help me? thanks
谁能帮忙解答下,哈哈

Related

Find and Replace a Column in CSV1 based on CSV2 in PHP

I am trying replace the values of column "Close" in the first CSV with the values of column "LTP" in the second CSV where the following columns should be same in CSV2 and CSV1:
"Symbol=SYMBOL", "Date=TIMESTAMP", "Expiry=EXPIRY_DT", "Option Type=OPTION_TYP", "Strike Price=STRIKE_PR"
Here is the current structure of CSV1:
INSTRUMENT SYMBOL EXPIRY_DT STRIKE_PR OPTION_TYP OPEN HIGH LOW CLOSE SETTLE_PR CONTRACTS VAL_INLAKH OPEN_INT CHG_IN_OI TIMESTAMP
OPTSTK INFY 26-Apr-18 780 CE 0 0 0 408.6 361.05 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 800 CE 0 0 0 388.95 341.15 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 820 CE 0 0 0 369.35 321.25 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 840 CE 0 0 0 349.75 301.35 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 860 CE 0 0 0 330.2 281.45 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 880 CE 0 0 0 310.75 261.55 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 900 CE 0 0 0 291.35 241.65 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 920 CE 0 0 0 272.15 221.75 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 940 CE 0 0 0 216 201.85 0 0 5400 0 2-Apr-18
OPTSTK INFY 26-Apr-18 960 CE 0 0 0 234.45 181.95 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 980 CE 0 0 0 216.1 162.1 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 1000 CE 0 0 0 136 142.3 0 0 24600 0 2-Apr-18
And the structure of CSV2 is:
Symbol Date Expiry Option Type Strike Price Open High Low Close LTP Settle Price No. of contracts Turnover in Lacs Premium Turnover in Lacs Open Int Change in OI Underlying Value
INFY 2-Apr-18 26-Apr-18 CE 780 0 0 0 408.6 0 361.05 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1380 1 1 1 1 1 1 1 8.29 0.01 600 600 1137.15
INFY 2-Apr-18 26-Apr-18 CE 820 0 0 0 369.35 0 321.25 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 840 0 0 0 349.75 0 301.35 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 860 0 0 0 330.2 0 281.45 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 880 0 0 0 310.75 0 261.55 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 900 0 0 0 291.35 0 241.65 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 920 0 0 0 272.15 0 221.75 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 940 0 0 0 216 216 201.85 0 0 0 5400 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 960 0 0 0 234.45 0 181.95 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 980 0 0 0 216.1 0 162.1 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1000 0 0 0 136 134 142.3 0 0 0 24600 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1020 0 0 0 126 126 122.65 0 0 0 1200 0 1137.15
A few things about CSV and in general any file
I am trying replace the values of column "Close" in the first CSV with the values of column "LTP" in the second CSV where the following columns.
You cannot "replace" anything in the file. You can however pull the data from a file using fgetcsv then change it and write a new file with the changed data using fputcsv.
As you have shown "no code", I won't bother writing much. But I will just go over the process.
read in the file (completely) with the new values in it, creating an array from it
read in the file you wish to change row by row
for each row of the second file, find the correct row in the first one (array) and update the data for that line in file #2 (your file #1)
write a new file that contains the updated data.
you have to read the file you want to change the data in last, because you want to preserve the order of the rows in that file, and well it's just easier that way.
A tip for matching the data. When you read in file #1 take the fields you need to match and hash them using md5. Md5 is really fast on the order of something like 5 million hashes a second (yes I timed it)
$time = microtime(true);
for($i=0; $i <= 5000000; ++$i){
md5("hello world");
}
echo "Complete :".number_format((microtime(true) - $time), 4);
Try it yourself
Output
Complete :1.3057
Now this has nothing to do with security or anything else, I will explain in a second.
When you build you array (Step 1) take the fields you want to match and hash them and use that for the key in your array.
$hash = md5(
$row['Symbol'] .
strtotime($row['Date']) . //convert to timestamp
$row['Expiry'] .
$row['Option Typ'] .
$row['Strike Price']
);
$data[$hash] = $row;
Then do the same when you read in the second file (the file you want to modify)
$newHash = md5(
$row['SYMBOL'] .
TIMESTAMP . //convert to timestamp
$row['EXPIRY_DT'] .
$row['OPTION_TYP'] .
$row['STRIKE_PR'] .
);
Then simply look up the hash in the $data array isset($data[$newHash]) as yo go through the file you are modifying. Once you find the row with that data you need the rest is pretty trivial.
Now the basic way to read a file is
$h = fopen('filename.csv', 'r');
$data = [];
$headers = false;
while(!feof($h)){
$row = fgetcsv($h);
if(!$headers) $headers = $row;
$row = array_combine($headers, $row);
//do the hash "and other stuff"
$data[$hash] = $row;
}
Then read the other file after that one is done, with the same kind of loop, do the hash , match the data you want, update the old data, write the row in a new (3rd) file etc...
For the hashing to work, the data must match from one CSV to the other (obviously), there cannot be duplicate "hashed" rows. Rows who's data hashes the same but which has values in the other fields. Like if you had 2 rows in the same file that hash the same and then the Close value is different. This would cause you trouble no matter what.
Good luck, look up some tutorials on how to process CSV files, there are plenty of them out there.

Unable to send mail through sendmail using neither terminal nor PHP linux

I have installed sendmail on my linux machine(Linux Mint) and I followed : how to configure sendmail on ubuntu on Stack Overflow.
I got no errors till the end and I successfully restarted the sendmail.
To check I tried using telnet. Here's the terminal print
hackathon mail # telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sat, 7 Mar 2015 14:59:26 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
HELO server
250 hackathon Hello localhost [127.0.0.1], pleased to meet you
MAIL from : localhostmailbox#gmail.com
250 2.1.0 localhostmailbox#gmail.com... Sender ok
RCPT to : naveenchaudhary2010#hotmail.com
250 2.1.5 naveenchaudhary2010#hotmail.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Subject : Test mail
.
250 2.0.0 t279TQBC024546 Message accepted for delivery
quit
221 2.0.0 hackathon closing connection
Connection closed by foreign host.
Though telnet says message accepted to deliver, but I see no mail neither in Inbox or Junk of recepient, nor in the sent folder of sender.
I tried using php also.
php.ini settings :
; For Win32 only.
; http://php.net/smtp
SMTP=smtp.gmail.com
; http://php.net/smtp-port
smtp_port=587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = localhostmailbox#gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path =
Here's the PHP code :
<?php
$to = "naveenchaudhary2010#hotmail.com";
$subject = "test";
$body = "This is a text";
$headers = 'From : "localhost" localhostmailbox#gmail.com';
$return_val = mail($to,$subject,$body,$headers);
if($return_val)
echo "sent";
else
echo "Failure :".$return_val;
?>
This is also sending the error.I tried printing the return value of mail() which is null.
Please help, this is my 7th hour wasted since morning and still no success till now.
EDIT
Dump of strace
2558 <... time resumed> NULL) = 1425817211
13250 <... read resumed> "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], <unfinished ...>
13250 close(4 <unfinished ...>
2558 <... rt_sigprocmask resumed> [ALRM], 8) = 0
13250 <... close resumed> ) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 munmap(0xb77a6000, 4096) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 dup(8) = 4
13250 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR)
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getegid32() = 126
13250 setgroups32(1, [126]) = 0
13250 ioctl(8, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0xbf855618) = -1 ENOTTY (Inappropriate ioctl for device)
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)\n# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN\nnameserver 127.0.1.1\nsearch 8.8.8.8\n", 4096) = 187
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 open("/etc/services", O_RDONLY|O_CLOEXEC) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=19558, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "# Network services, Internet style\n#\n# Note that it is presently the policy of IANA to assign a single well-known\n# port number for both TCP and UDP; hence, officially ports have two entries\n# even if"..., 4096) = 4096
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 time(NULL) = 1425817211
13250 rt_sigaction(SIGALRM, {0x80e56d0, [], SA_RESTART}, {0x80e56d0, [], SA_RESTART}, 8) = 0
13250 alarm(5) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
13250 bind(5, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
13250 connect(5, {sa_family=AF_INET, sin_port=htons(113), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
13250 close(5) = 0
13250 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
13250 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
13250 kill(13250, SIGALRM) = 0
13250 --- SIGALRM {si_signo=SIGALRM, si_code=SI_USER, si_pid=13250, si_uid=0} ---
13250 alarm(0) = 5
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 sigreturn() (mask []) = 0
13250 getsockopt(8, SOL_IP, IP_OPTIONS, "", [0]) = 0
13250 time(NULL) = 1425817211
13250 time(NULL) = 1425817211
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/access.db", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(5, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 time(NULL) = 1425817211
13250 open("/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 6
13250 read(6, "0-1\n", 8192) = 4
13250 close(6) = 0
13250 stat64("/etc/mail/access.db", {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 6
13250 fcntl64(6, F_GETFD) = 0
13250 fcntl64(6, F_SETFD, FD_CLOEXEC) = 0
13250 read(6, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 512) = 512
13250 open("DB_CONFIG", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
13250 stat64("/var/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
13250 time(NULL) = 1425817211
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773188844}) = 0
13250 clock_gettime(CLOCK_REALTIME, {1425817211, 773264483}) = 0
13250 open("/etc/mail/access.db", O_RDONLY|O_LARGEFILE) = 7
13250 fcntl64(7, F_GETFD) = 0
13250 fcntl64(7, F_SETFD, FD_CLOEXEC) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\t\0\0\0\0\20\0\0\0\10\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0_\v\20\0\6\10\0\0\321\326B\375\245^\0\0\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\27\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 0) = 4096
13250 close(5) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\22\0C\17\0\r\353\17\351\17\324\17\322\17\306\17\300\17\260\17\251\17\235\17\226\17\212\17\203\17r\17l\17W\17U\17J\17C\17\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 4096) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 pread64(7, "\0\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\34\0\363\16\0\r\361\17\357\17\333\17\331\17\315\17\312\17\273\17\271\17\245\17\243\17\227\17\224\17\204\17}\17k\17e\17V\17T\17#\17>\0172\17-\17%\17\36\17\22\17\v\17\372\16\363\16\0\0\0\0\0\0\0\20\0\0\321\215h^\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096, 8192) = 4096
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 open("/etc/hosts.allow", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=425, ...}) = 0
13250 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb77a6000
13250 read(5, "sendmail: all\n# /etc/hosts.allow: list of hosts that are allowed to access the system.\n# See the manual pages hosts_access(5) and hosts_options(5).\n#\n# Example: ALL: LOCAL #some_n"..., 4096) = 425
13250 close(5) = 0
13250 munmap(0xb77a6000, 4096) = 0
13250 dup2(4, 1) = 1
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 time(NULL) = 1425817211
13250 stat64("/etc/localtime", {st_mode=S_IFREG|0644, st_size=265, ...}) = 0
13250 open("/proc/loadavg", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
13250 read(5, "0.56 0.24 0.22 1/414 13250\n", 1024) = 27
13250 close(5) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 getpeername(8, {sa_family=AF_INET, sin_port=htons(51828), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 getsockname(8, {sa_family=AF_INET, sin_port=htons(25), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
13250 fcntl64(7, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(7, {st_mode=S_IFREG|0640, st_size=12288, ...}) = 0
13250 fcntl64(7, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
13250 fstat64(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 fstat64(8, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "220 hackathon ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Sun, 8 Mar 2015 17:50:11 +0530; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]\r\n", 165) = 165
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817211, 849076}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 time(NULL) = 1425817216
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.60 0.26 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817216
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {292, 398402})
13250 gettimeofday({1425817219, 450896}, NULL) = 0
13250 read(8, "HELO server\r\n", 4096) = 13
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 hackathon Hello localhost [127.0.0.1], pleased to meet you\r\n", 64) = 64
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)
13250 gettimeofday({1425817219, 451708}, NULL) = 0
13250 select(9, [8], NULL, [8], {300, 0} <unfinished ...>
2558 <... select resumed> ) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 time(NULL) = 1425817221
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.25 0.23 1/414 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817221
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 time(NULL) = 1425817226
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.51 0.25 0.22 4/413 13250\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817226
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 time(NULL) = 1425817231
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.55 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817231
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 time(NULL) = 1425817236
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.50 0.26 0.23 1/412 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817236
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0}) = 0 (Timeout)
2558 rt_sigprocmask(SIG_BLOCK, [ALRM], [], 8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 time(NULL) = 1425817241
2558 open("/proc/loadavg", O_RDONLY) = 8
2558 fstat64(8, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
2558 read(8, "0.46 0.25 0.23 1/411 13251\n", 1024) = 27
2558 close(8) = 0
2558 time(NULL) = 1425817241
2558 rt_sigprocmask(SIG_UNBLOCK, [ALRM], [ALRM], 8) = 0
2558 select(7, [4 5 6], NULL, NULL, {5, 0} <unfinished ...>
13250 <... select resumed> ) = 1 (in [8], left {275, 280004})
13250 gettimeofday({1425817244, 171941}, NULL) = 0
13250 read(8, "MAIL from :localhostmailbox#gmail.com\r\n", 4096) = 39
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 stat64("/etc/mail/service.switch", {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
13250 geteuid32() = 0
13250 lstat64("/etc/mail", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, ...}) = 0
13250 geteuid32() = 0
13250 open("/etc/mail/service.switch", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 fcntl64(5, F_GETFL) = 0 (flags O_RDONLY)
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=149, ...}) = 0
13250 read(5, "# /etc/mail/nsswitch.conf\n#\n# This is the format that sendmail expects (no colon after the service)\n# \npasswd\t\tfiles\nhosts\t\tfiles dns\naliases\t\tfiles\n", 4096) = 149
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 open("/etc/hosts", O_RDONLY) = 5
13250 fstat64(5, {st_mode=S_IFREG|0644, st_size=224, ...}) = 0
13250 read(5, "127.0.0.1\tlocalhost\n127.0.1.1\thackathon\n\n# The following lines are desirable for IPv6 capable hosts\n::1 ip6-localhost ip6-loopback\nfe00::0 ip6-localnet\nff00::0 ip6-mcastprefix\nff02::1 ip6-allnodes"..., 4096) = 224
13250 read(5, "", 4096) = 0
13250 close(5) = 0
13250 stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
13250 socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
13250 connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, 16) = 0
13250 gettimeofday({1425817244, 174299}, NULL) = 0
13250 poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
13250 send(5, "*\311\1\0\0\1\0\0\0\0\0\0\5gmail\3com\0\0\34\0\1", 27, MSG_NOSIGNAL) = 27
13250 poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
13250 recvfrom(5, "*\311\201\200\0\1\0\1\0\4\0\4\5gmail\3com\0\0\34\0\1\300\f\0\34\0\1\0\0\0002\0\20$\4h\0#\2\10\2\0\0\0\0\0\0\20\25\300\f\0\2\0\1\0\0\17\0\0\r\3ns4\6google\300\22\300\f\0\2\0\1\0\0\17\0\0\6\3ns3\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns2\300G\300\f\0\2\0\1\0\0\17\0\0\6\3ns1\300G\300\200\0\1\0\1\0\0\2B\0\4\330\357 \n\300n\0\1\0\1\0\0\2B\0\4\330\357\"\n\300\\\0\1\0\1\0\0\2B\0\4\330\357$\n\300C\0\1\0\1\0\0\2B\0\4\330\357&\n", 8192, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.1.1")}, [16]) = 198
13250 close(5) = 0
13250 time(NULL) = 1425817244
13250 time(NULL) = 1425817244
13250 fcntl64(4, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
13250 fcntl64(4, F_SETFL, O_RDWR) = 0
13250 fcntl64(8, F_GETFL) = 0x2 (flags O_RDWR)
13250 fcntl64(8, F_SETFL, O_RDWR|O_NONBLOCK) = 0
13250 select(9, [8], NULL, NULL, {0, 0}) = 0 (Timeout)
13250 write(4, "250 2.1.0 localhostmailbox#gmail.com... Sender ok\r\n", 51) = 51
13250 read(8, 0x8bd35d8, 4096) = -1 EAGAIN (Resource temporarily unavailable)

PHP preg_match strings in between quotations for entire file

I've created a php file that I'm trying to parse data with. The file's content that I'd like to parse looks like this:
[Titles]
hollywoodhd1 1 0 8046 0 919 PG-13 6712 1 identity_hd "(HD) Identity Thief" Disk 0 04/15/13 11/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
hollywoodhd2 3 0 8016 0 930 PG 5347 1 escapep_hd "(HD) Escape from Planet Earth" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
hollywoodhd3 1 0 8012 0 930 PG-13 5828 1 darkski_hd "(HD) Dark Skies" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
The PHP that i've created:
<?php
foreach (glob("*.mov") as $filename)
$theData = file_get_contents($filename) or die("Unable to retrieve file data");
// echo nl2br($theData); //- This will print the entire text-wrapped line breaks.
$Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX']; // - This doesn't do anything yet.
if (preg_match('!"([^"]+)"!', $theData, $m)){
echo $m[1];
}
?>
QUESTION: I'd like to return the MOVIE TITLE : RATING, but the code that I have only returns a single movie title so far, (HD) Identity Thief. I have a long way to go so any guidance would be greatly appreciated. Is there a way to sort Movie Title : Rating, strictly by the Ratings?
Also, is there a way to have the PHP script search a directory, and sub folders for any ".mov" file extension, run the script for each file?
Here is what I have so far, I haven't gotten the sorting part, since you don't say how you want it sorted...
<?php
header("content-type: text/plain");
function getInfo($string){
$Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX']; // Used in the loop below
$split = preg_split("/\"(.+)\"/", $string, -1, PREG_SPLIT_DELIM_CAPTURE);
$string = $split[1];
preg_match("/(".implode("|", $Ratings).")\s/", $split[0], $matches);
$rating = $matches[0];
return ["title" => $split[1], "rating" => $rating];
}
$string = <<<String
[Titles]
hollywoodhd1 1 0 8046 0 919 PG-13 6712 1 identity_hd "(HD) Identity Thief" Disk 0 04/15/13 11/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
hollywoodhd2 3 0 8016 0 930 PG 5347 1 escapep_hd "(HD) Escape from Planet Earth" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
hollywoodhd3 1 0 8012 0 930 PG-13 5828 1 darkski_hd "(HD) Dark Skies" Disk 0 04/01/13 10/01/13 0 0 0 0 0 0 1 1 0 16000000 H3 16:9 0 0
String;
$titles = explode("\n", $string);
// Remove the first line
unset($titles[0]);
foreach($titles as $title){
$info = getInfo($title);
echo "{$info["title"]} : {$info["rating"]}\n";
}
Then, here is the output that is returned:
(HD) Identity Thief : PG-13
(HD) Escape from Planet Earth : PG
(HD) Dark Skies : PG-13

Formatting raw text gathered from another website using php

I am trying to retrieve a table from another website, which is based on several variables passed to it via a form. I have worked out that the url details after the ? correspond to those variables and have created a form on my page to post those variables and create url, which I have then put into a file_get_contents process, whereby I collect the table as data (I have narrowed the get to the div in which the table is housed).
My problem is that the data is shown as a string of plain text on my page with no formatting (i.e. no columns or rows).
Here is the code to retrieve the data:
<?php
$page = file_get_contents($stats_url);
$doc = new DOMDocument();
$doc->loadHTML($page);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
if ($div->getAttribute('id') === 'statstable') {
echo $div->nodeValue;
}
}
?>
Here is a sample of the data returned:
NameGamesInnsNot OutsRunsHigh ScoreAvg50's100'sDucksStrike RateBowled (%)Caught (%)LBW (%)Stumped (%)Run Out (%)Not Out (%)Did Not Bat (%)%Games Won%Games Drawn%Games Lost%Team RunsCatchesStumpingsRun OutsOwais Fareed 1 1 0 72 7272 1 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 42.6 0 0 0 Atif Ali 2 2 0 28 2814 0 0 1 - 2 (100) 0 0 0 0 0 0 0 0 100 11.62 0 0 0 Craig Hills 2 2 0 20 1310 0 0 0 - 0 1 (50) 1 (50) 0 0 0 0 0 0 100 8.3 1 0 0 Dale Skeath 2 2 0 16 128 0 0 0 - 1 (50) 1 (50) 0 0 0 0 0 0 0 100 6.64 1 0 0 ash ashim 2 2 1 16 10*16 0 0 0 - 0 1 (50) 0 0 0 1 (50) 0 0 0 100 6.64 0 0 0 Hussain Dalvi 1 1 0 11 1111 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.51 0 0 0 Azhar Ali 1 1 0 11 1111 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.51 0 0 0 A Hammed 1 1 0 10 1010 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 5.92 0 0 0 M Ali 1 1 0 5 55 0 0 0 - 1 (100) 0 0 0 0 0 0 0 0 100 2.96 0 0 0 Simon Pleasant 1 1 0 5 55 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.94 0 0 0
How can I then take this text and recompile it as a table?
Check out PHP Simple HTML DOM Parser
It works brilliantly for this stuff.
http://simplehtmldom.sourceforge.net/

file_get_contents fails on debian (lenny) server

Not sure if it's because it's out of life, but it has been running a website and working until very recently (1 week) - the server hasn't been updated, so am not sure what happened to break the script.
Here's a test script that I've been running (and fails) on the debian server:
<?php
$url = "http://www.andyloughran.co.uk/test.html";
echo $url."\n";
$test = file_get_contents($url);
echo $test;
That should normally return 'ndy test' or something similar.
However, on the debian box it's just timing out.
I've checked and I can wget the file:
<?php
exec('wget http://www.andyloughran.co.uk/test.html');
so am not sure what is it in file_get_contents that isn't working.
I've checked and allow_fopen_url is set to On.
I could do with advice not just on fixing this problem, but working out how to debug the php in order to be able to identify the problem myself in the future.
Curl is not really an option at the moment, as I'm more interested in working out why it's stopped working, rather than an alternative.
Thanks!
Here's the strace error:
open("/dev/urandom", O_RDONLY) = 3
read(3, "\202\231\320\206"..., 4) = 4
close(3) = 0
open("/dev/urandom", O_RDONLY) = 3
read(3, "cdO\37"..., 4) = 4
close(3) = 0
brk(0x9133000) = 0x9133000
open("http_test.php", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "<?php\n\nini_set('display_errors', "..., 4096) = 187
_llseek(3, 0, [0], SEEK_SET) = 0
time(NULL) = 1348748612
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7836000
_llseek(0, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7835000
_llseek(1, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
_llseek(2, 0, 0xbfae579c, SEEK_CUR) = -1 ESPIPE (Illegal seek)
getcwd("/root"..., 4096) = 6
time(NULL) = 1348748612
lstat64("/root", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/root/http_test.php", {st_mode=S_IFREG|0644, st_size=187, ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfae3798) = -1 ENOTTY (Inappropriate ioctl for device)
read(3, "<?php\n\nini_set('display_errors', "..., 8192) = 187
read(3, ""..., 4096) = 0
read(3, ""..., 8192) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
write(1, "http://www.andyloughran.co.uk/tes"..., 40http://www.andyloughran.co.uk/test.html
) = 40
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3
close(3) = 0
socket(PF_NETLINK, SOCK_RAW, 0) = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=28901, groups=00000000}, [12]) = 0
time(NULL) = 1348748612
sendto(3, "\24\0\0\0\26\0\1\3DEdP\0\0\0\0\0\0\0\0"..., 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"0\0\0\0\24\0\2\0DEdP\345p\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1\10"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 156
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"#\0\0\0\24\0\2\0DEdP\345p\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0DEdP\345p\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=141, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7837000
read(3, "127.0.0.1 localhost.localdomain l"..., 4096) = 141
read(3, ""..., 4096) = 0
close(3) = 0
munmap(0xb7837000, 4096) = 0
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=32850, ...}) = 0
mmap2(NULL, 32850, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7820000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libnss_dns.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220\v\0\0004\0\0\0x"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=17880, ...}) = 0
mmap2(NULL, 20616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xca5000
mmap2(0xca9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0xca9000
close(3) = 0
munmap(0xb7820000, 32850) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748612, 441933}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 442194}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "2k\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [102]) = 0
recvfrom(3, "2k\201\200\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 102
close(3) = 0
gettimeofday({1348748612, 755352}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748612, 755589}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\312-\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 56, MSG_NOSIGNAL) = 56
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [121]) = 0
recvfrom(3, "\312-\201\203\0\1\0\0\0\1\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 121
close(3) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=95, ...}) = 0
gettimeofday({1348748613, 222946}, NULL) = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 28) = 0
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
gettimeofday({1348748613, 223253}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\254Q\1\0\0\1\0\0\0\0\0\0\3www\fandyloughran\2co\2"..., 40, MSG_NOSIGNAL) = 40
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
ioctl(3, FIONREAD, [56]) = 0
recvfrom(3, "\254Q\201\200\0\1\0\1\0\0\0\0\3www\fandyloughran\2co\2"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, [16]) = 56
close(3) = 0
gettimeofday({1348748613, 400717}, NULL) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("85.119.82.243")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=3, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=3, revents=POLLOUT}])
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl64(3, F_SETFL, O_RDWR) = 0
send(3, "GET /test.html HTTP/1.0\r\n"..., 25, MSG_DONTWAIT) = 25
send(3, "Host: www.andyloughran.co.uk\r\n"..., 30, MSG_DONTWAIT) = 30
send(3, "User-Agent: PHP\r\n"..., 17, MSG_DONTWAIT) = 17
send(3, "\r\n"..., 2, MSG_DONTWAIT) = 2
poll([{fd=3, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 60000^C <unfinished ...>
allow_url_fopen = On in php.ini
Check your DNS, ping www.andyloughran.co.uk
Throw the server out of the nearest window.
I had the same problemn a while ago. It was a DNS problem. Restarting the Webserver helped.
file_get_contents won't work with a URI.
Just try this:
$Stuff = file_get_contents($_SERVER['DOCUMENT_ROOT']."path/filename");
file_get_contents will be happy to "see" a local and accessible path. It will present you the file contents as a kind of "function-thank-you" ;)

Categories