Tsung load test from mac os x - php

I am trying to fire off a Tsung request from my Mac OS X machine and i'm not having much luck.
I have edited the ~/.tsung/tsung.xml config file and even tried changing the location of that file on several occasions with the -f parameter.
When I run tsung start it returns this output
dave:/Applications/MAMP/htdocs/barebonessite/wp-content/themes/barebones $ tsung -f ~/.tsung/tsung.xml -l . start
Starting Tsung
"Log directory is: /Applications/MAMP/htdocs/barebonessite/wp- content/themes/barebones/./20130503-1325"
Config Error, aborting ! {{case_clause,{error,enoent}},
[{xmerl_scan,fetch_DTD,2,
[{file,"xmerl_scan.erl"},{line,1283}]},
{xmerl_scan,scan_doctype2,3,
[{file,"xmerl_scan.erl"},{line,1227}]},
{xmerl_scan,scan_prolog,4,
[{file,"xmerl_scan.erl"},{line,722}]},
{xmerl_scan,scan_document,2,
[{file,"xmerl_scan.erl"},{line,563}]},
{xmerl_scan,file,2,
[{file,"xmerl_scan.erl"},{line,249}]},
{ts_config,read,2,
[{file,"src/tsung_controller/ts_config.erl"},
{line,68}]},
{ts_config_server,handle_call,3,
[{file,
"src/tsung_controller/ts_config_server.erl"},
{line,198}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,588}]}]}
My config file looks like this:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<clients>
<client host='localhost' use_controller_vm='true'/>
</clients>
<servers>
<server host="54.225.212.193" port="80" type="tcp"></server
</servers>
<load>
<arrivalphase phase="1" duration="10" unit="minute">
<users maxnumber="650" arrivalrate="8" unit="second"/>
</arrivalphase>
</load>
<sessions>
<session probability="100" name="ab" type="ts_http">
<for from="1" to="20" var="i">
<request> <http url="/" method="GET" version="1.1"/> </request>
</for>
</session>
</sessions>
</tsung>
Being new to Tsung I cannot work out the problem here and the error reporting is pretty low level stuff and makes little sense.

I used Homebrew to install tsung on osx and was getting this error when using the example xml files.
Config Error, aborting ! dtd_not_found
Replacing the doc type line with this fixed it:
<!DOCTYPE tsung SYSTEM "/usr/local/Cellar/tsung/1.6.0/share/tsung/tsung-1.0.dtd">

This error is related to a dtd file missing, could you check that the file /usr/share/tsung/tsung-1.0.dtd exists, it seems not.
Secondly your xml file seems to contains a syntax error on a non close tag
Regards

There might be another path in case you are using some other Linux distributions (not mac os):
/usr/local/share/tsung/tsung-1.0.dtd
note local part

Related

Apache with PHP: Can't find module?

trying to use LoadFile "C:/ProgramFiles/PostgreSQL/15/bin/libpq.dll" in the httpd.conf file.
I keep getting this from the error logs:
Log Name: Application
Source: Apache Service
Date: 1/24/2023 6:46:09 PM
Event ID: 3299
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: Cedric-PC
Description:
The Apache service named reported the following error:
>>> httpd.exe: Syntax error on line 542 of C:/Apache24/conf/httpd.conf: Cannot load C:/ProgramFiles/PostgreSQL/15/bin/libpq.dll into server: The specified module could not be found. .
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Apache Service" />
<EventID Qualifiers="0">3299</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2023-01-24T23:46:09.4847737Z" />
<EventRecordID>52674</EventRecordID>
<Correlation />
<Execution ProcessID="0" ThreadID="0" />
<Channel>Application</Channel>
<Computer>Cedric-PC</Computer>
<Security />
</System>
<EventData>
<Data>The Apache service named</Data>
<Data>
</Data>
<Data>reported the following error:
>>></Data>
<Data>httpd.exe: Syntax error on line 542 of C:/Apache24/conf/httpd.conf: Cannot load C:/ProgramFiles/PostgreSQL/15/bin/libpq.dll into server: The specified module could not be found.</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
<Data>
</Data>
</EventData>
</Event>
Everything is running x64. Apache is on VC15. PostgreSQL is 15.
I have no idea how to troubleshoot this.
EDIT:
Syntax error. Needed a space between "Program Files"...
There are a couple things I noticed with the information you have provided.
Firstly, "C:/ProgramFiles/" is not a valid directory path.
It is typically "C:/Program Files/" or "C:/Program Files (x86)/"
I recommend copy/paste the folder path from the Windows explorer directory when you need to specify an absolute path like this.
Second, with Apache, you cannot load any arbitrary DLL file.
It must be a compiled library that is built for Apache, typically "mod_" will always be in it's name.
Finally,
Since the tag php is part of your post, I will assume that is what your web application is written in.
Normally, you would load an extension within php, in the php.ini file.
Look for your php.ini file within the installation directory.
Find the lines
extension=php_pgsql.dll
extension=php_pdo_pgsql.dll
Uncomment one, or both of them. Which ever fits your needs.
You may need to direct your PATH environment variable to the location where libpq.dll is located to have php find it.
I have worked in IT my entire life, and have been using Apache and php for most of that time.
Best of luck.

PHP / IIS does not interpret php code correctly -> blank page for phpinfo()

on my Win 10 machine i would like to use PHP on IIS. I went through different tutorials to get it to work but currently when i call the index.php file i got an blank page and the response is only the content of the php file (see this in browser dev tools).
content of the file:
`
<?php
phpinfo();
?>
`
Result
what i have done is:
installed CGI under Windows features
php 8.1.2 x86 Non thread safe unzipped under C:\php
php.ini adjusted like described in the tutorial(s)
linked the directory under environment variables to C:\php
set the handler mapping for php in IIS
checked the fast cgi module in IIS
I also activated the Failed Requested Trace in IIS and the outcoming log had following section:
For me it looks good, or i am wrong? If its helpful i can post the whole .xml, but it is very large.
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="WWW Server" Guid="{3A2A4E84-4C21-4981-AE10-3FDA0D9B0F83}"/>
<EventID>0</EventID>
<Version>1</Version>
<Level>4</Level>
<Opcode>43</Opcode>
<Keywords>0x0</Keywords>
<TimeCreated SystemTime="2022-11-15T15:58:47.038Z"/>
<Correlation ActivityID="{8000000A-0005-FF00-B63F-84710C7967BB}"/>
<Execution ProcessID="5540" ThreadID="1392"/>
<Computer>SRV01</Computer>
</System>
<EventData>
<Data Name="ContextId">{8000000A-0005-FF00-B63F-84710C7967BB}</Data>
<Data Name="OldHandlerName"></Data>
<Data Name="NewHandlerName">PHP_via_FastCGI</Data>
<Data Name="NewHandlerModules">FastCgiModule</Data>
<Data Name="NewHandlerScriptProcessor">C:\php\php-cgi.exe</Data>
<Data Name="NewHandlerType"></Data>
</EventData>
<RenderingInfo Culture="de-DE">
<Opcode>HANDLER_CHANGED</Opcode>
</RenderingInfo>
<ExtendedTracingInfo xmlns="http://schemas.microsoft.com/win/2004/08/events/trace">
<EventGuid>{D42CF7EF-DE92-473E-8B6C-621EA663113A}</EventGuid>
</ExtendedTracingInfo>
</Event>

How do you run a PHP script every 1 minute using a plist file with launchd (launchctl) in MacOS?

So how do you run a PHP script once every 1 minute using a plist file with launchd (launchctl) in MacOS? This was a question I had that took forever to find the answer to, but I did eventually! I'm using my answer to make jobs on a Mac instead of cron or crontab, which is what you would normally use in Linux/Unix. Checkout my answer below!
Answer
Create a new plist file ~/Library/LaunchAgents/com.yourusername.yourscripttype.plist and add the follow code to it, changing everything that should be changed:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.yourusername.yourscripttype</string>
<key>ProgramArguments</key>
<array>
<string>/absolute/path/to/php</string>
<string>/absolute/path/to/app/subfolders/script.php</string>
</array>
<!-- <key>StandardOutPath</key>
<string>/tmp/MoodleError.out</string>
<key>StandardErrorPath</key>
<string>/tmp/MoodleError.err</string> -->
<key>WorkingDirectory</key>
<string>/absolute/path/to/app/</string>
<key>StartInterval</key>
<integer>60</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Set permissions for this plist file:
chmod 644 ~/Library/LaunchAgents/com.yourusername.yourscripttype.plist
Confirm permission for your new file matches the existing plist files:
ls -l ~/Library/LaunchAgents/
Load the new file:
launchctl load com.yourusername.yourscripttype.plist
You should be good to go.
Notes
com.whatevername.whateverscript.plist is convention in MacOS, so use it.
Manually test your PHP script with launchctl start ~/Library/LaunchAgents/com.yourusername.yourscripttype.plist
WARNING: Uncomment the StandardOutPath and/or StandardErrorPath lines in the above file if you want to see script output or errors to confirm your script is running properly, but DON'T LEAVE THEM IN OR ELSE YOU'LL BE ADDING TO THE LOG FILES EVERY MINUTE WHICH WILL QUICKLY DESTROY YOUR SYSTEM'S MEMORY!
<!-- <key>StandardOutPath</key>
<string>/tmp/MoodleError.out</string>
<key>StandardErrorPath</key>
<string>/tmp/MoodleError.err</string> -->

Apache PHP/OSX Mavericks: - failed to open stream: Too many open files

I've recently upgraded to OSX Mavericks and since then, I've started getting the aforementioned error on my development machine. There is no obvious problem in the code (it's an auto generated Yii sample application). What has happened as part of upgrade to Mavericks is:
PHP was upgraded from 5.2.x which bundled with OSX Lion to 5.4.x.
I had to get a Zend Debugger for PHP 5.4 by installing Zend Server, picking up the ZendDebugger.so and uninstalling the Zend Server (all this because Zend doesn't provide a standalone version of their debugger for php 5.4.x).
Ever since, I'm getting this problem after maybe loading and reloading the website a few time. After this error occurs, my web server keeps returning the same error for any other application hosted on localhost. I have to mention that static web pages are served up fine.
I've seen several threads on this topic. Most point out to issues in code where file handles are not being closed properly, thereby crossing the open file limit threshold. I also found this thread which seems to suggest this might be a zend debugger issue. There's also a bug report filed for php 5.2.x. Following the thread here, I tried the following:
$ ulimit -a
which reports:
open files (-n) 256
Also,
sysctl -a | grep files
returns,
kern.maxfiles = 12288
kern.maxfilesperproc = 10240
kern.maxfiles: 12288
kern.maxfilesperproc: 10240
kern.num_files: 3248
Another interesting thread suggests to raise this limit (currently 256) using:
ulimit -n 1024
I've tried everything, but nothing seems to be working. The problem is also not consistently reproducible.
I am wondering is using ulimit -n 1024 is going to affect apache, since from what I've read, it affects the number of files shell can have open.
Any help is appreciated.
EDIT:
Restarting apache helps for a bit, till the error is encountered again.
Leaving the web server idle for a bit (no definite interval) also helps.
Shamelessly stolen from http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/#Mac-OS-X
To check the current limits on your Mac OS X system, run:
$ launchctl limit maxfiles
The last two columns are the soft and hard limits, respectively.
To adjust the maximum open file limits in OS X 10.7 (Lion) or newer, edit /etc/launchd.conf and increase the limits for both values as appropriate.
For example, to set the soft limit to 16384 files, and the hard limit to 32768 files, perform the following steps:
Verify current limits:
$ launchctl limit
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 709 1064
maxfiles 10240 10240
Edit (or create) /etc/launchd.conf and increase the limits. Add lines that look like the following (using values appropriate to your environment):
limit maxfiles 16384 32768
Save the file, and restart the system for the new limits to take effect. After restarting, verify the new limits with the launchctl limit command:
$ launchctl limit
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 709 1064
maxfiles 16384 32768
If you are experiencing this issue while running Apache you can configure apache to increase the limit:
$ sudo vi /usr/sbin/apachectl
locate:
ULIMIT_MAX_FILES=""
and change this line to something like:
ULIMIT_MAX_FILES="ulimit 4096"
Then:
sudo apachectl restart
This will not work for CLI scripts. But adding a ulimit directly to your ~/.bash_profile (or equivalent) should work for that purpose.
This has the advantage of setting specific limits for apache and your terminal without affecting other apps.
Also, you should be able to adapt this method to other OSs by substituting ulimit with the command applicable to that environment.
I was running into the same issue on El Capitain. Found an article here I owes due credit for the solution. Follow the actions below:
Adjusting Open File Limits
To adjust open files limits on a system-wide basis on Yosemite and above, you need to create two configuration files. The first is a property list (aka plist) file in /Library/LaunchDaemons/limit.maxfiles.plist that contains the following XML configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>65536</string>
<string>65536</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
This will set the open files limit to 65536. The second plist configuration file should be stored in /Library/LaunchDaemons/limit.maxproc.plist with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
Both plist files must be owned by root:wheel and have permissions -rw-r–r–. Restart the system.
Also its recommended setting them for the user session in .bashrc and add:
ulimit -n 65536
ulimit -u 2048
Hope this helps.
I was probably suffering from information overload. A possible explanation is offered here which I've also mentioned in my original post. I guess I missed the little detail where the OP mentions that he's working on Mac OSX 10.8.x. I'm on 10.9 so I downloaded the zenddebugger.so from the page and things are looking good. Haven't gotten a single too many open files all day.
So, perhaps it was a ZendDebugger issue.
Regarding the debugger patch answer above. Unfortunately the answer provided above won't work for me, as it applies to php versions 5.4 and I must limit myself to php 5.3.
Zend has released version 6.3 of their server, which supports php at 5.3. I have been playing with the installation for a little while (after dropping my ulimit back down to Apple's default) to test it and am not experiencing any problems. Before the upgrade I could not do any php debugging without raising that limit.
Per http://forums.zend.com/viewtopic.php?t=110823&start=10#p219438 I think this was really just a bug in Zend Server that was fixed in 6.2.
Got the same error with running xDebug.
An upgrade solved the issue.
see:
https://superuser.com/questions/787888/too-many-files-open-on-mac-osx-after-running-apache-in-php-with-xdebug-for-som/829413#829413

PHP IIS 7 and FastCGI not working

I've followed the directions here: Using FastCGI to Host PHP Applications on IIS 7 to configure Windows 2008, PHP with IIS 7 and FastCGI, and I'm running into issues. The PHP version is 5.3.8. I've setup the Handler Mappings on IIS, and created a test page, though the page doesn't return anything except for a 500 error. I've ensured that PHP works, from the command line I get a response when I enter:
php -version.
That said, I've turned on Failed Request Tracing Rules for php pages, and when I browse through the error log, I see things like:
<EventData>
<Data Name="ContextId">{00000000-0000-0000-0200-0080010000F6}</Data>
<Data Name="ModuleName">FastCgiModule</Data>
<Data Name="Data1">FASTCGI_RESPONSE_ERROR</Data>
<Data Name="Data2">PHP Warning: phpinfo() [<a href=&apos;function.phpinfo&apos;>function.phpinfo</a>]: It is not safe to rely on the system&apos;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected &apos;America/New_York&apos; for &apos;-4.0/DST&apos; instead in C:\inetpub\wwwroot\phpinfo.php on line 1
</Data>
<Data Name="ErrorCode">5</Data>
</EventData>
<RenderingInfo Culture="en-US">
<Opcode>MODULE_WARNING</Opcode>
<Keywords>
<Keyword>Module</Keyword>
</Keywords>
<freb:Description Data="ErrorCode">Access is denied.
(0x5)</freb:Description>
From the top of the failed request log, I can see it's running under IUSR account:
tokenUserName="NT AUTHORITY\IUSR"
Here's settings for the fastCgi:
<fastCgi>
<application fullPath="C:\PHP\php-cgi.exe" instanceMaxRequests="10000">
<environmentVariables>
<environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000" />
<environmentVariable name="PHPRC" value="C:\php\php.ini" />
</environmentVariables>
</application>
</fastCgi>
<handlers accessPolicy="Read, Script">
<add name="PHP via FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" resourceType="Unspecified" requireAccess="Script" />
I've ensure that this user name has full control over my C:\PHP directory. My php.ini file is configured within C:\PHP directory.
In addition to following the directions in that article, I also tried to create a script map for PHP, and when I created that I got a difference error, not a 500.
HTTP Error 403.1 - Forbidden
You have attempted to run a CGI, ISAPI, or other executable program from a directory that does not allow executables to run.
Once again though, IUSR has full control over that directory so I don't quite understand why that error message.
Update
The issue was glaring right at me in the log. I had ignored the PHP Warning with regard to the date.timezone thinking that it's just a warning. I set it to:
date.timezone = America/New_York
and now it works.
For future reference you can use http://php.iis.net/ to easily install php into your IIS setup. It comes with a manager which will also let you go into 'development mode' which will display php errors as opposed to covering them up.

Categories