php engine scripts execution logging

This is a discussion on php engine scripts execution logging within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I want to gain insight into the access and running of scripts by the php engine on my production ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-21-2004
karoshi
 
Posts: n/a
Default php engine scripts execution logging

Hello,

I want to gain insight into the access and running of scripts by the
php engine on my production box.

Most scripts are executed via cronjobs and they invoke a lot of other
php scripts. I can backtrace these files, but a lot of other scripts
are run by our users from the command line and I want to know if it possible
to instruct the engine to log the names of these script files.

I use php version 4.3.6 and I tried to modify the php.ini file to enable
logging, but the logfile only reports errors and not the access/execution a
scriptfile.

Is there a way to instruct the php engine to log the execution of
scriptfiles?

Cheers
Karoshi






Reply With Quote
  #2 (permalink)  
Old 07-21-2004
Setec Astronomy
 
Posts: n/a
Default Re: php engine scripts execution logging

karoshi wrote:

> Is there a way to instruct the php engine to log the execution of
> scriptfiles?


You can use a fake. Rename the php engine and create a shell script
named php in the same location of the original php engine that log the
script executed (ie. begin and end) and call the original php engine.

--
I am what I am, I do what I can
L'uomo, conscio di sbagliare, persevera.
Reply With Quote
  #3 (permalink)  
Old 07-22-2004
karoshi
 
Posts: n/a
Default Re: php engine scripts execution logging [solution]

Hello,

I found the solution myself, thank you ;) just kiddin'
Ok, here's the solution : this works with version 4.3.6 (cli), mileage may
vary with other versions.
PHP uses php.ini (of course) and with the lines

; Automatically add files before or after any PHP document.
auto_prepend_file =
auto_append_file = /usr/local/karoshi/src/logging/php-log.php

you can append or prepend a script after of before execution of the main
script. Here I state that after execution of the main script php should
execute php-log.php (remember to fully quantify the path to the script).

Now let's take a look at php-log.php :

<begin>...

$current_exec ="";
$current_incl ="";

for ($index = 0; $index < $_SERVER['argc']; $index++)
{
$current_exec .= " ".$_SERVER['argv'][$index];
}

$includes = get_included_files();

for ($index = 0; $index < sizeof(get_included_files()); $index++)
{
$current_incl .= " ".$includes[$index];
}

print("executed .... ".getcwd()." ".$current_exec . " incl:
".$current_incl);

....<end>

first check if there are commandline parameters, and parse them. Then check
the includes and parse them. Then output the results prepended with the path
of the executed main script.

Cheers
Karoshi

----------------------------------------------------------------------------
----------------
"karoshi" <karoshi@japan.com> wrote in message
news:cdlnuo$81n$1@reader13.wxs.nl...
> Hello,
>
> I want to gain insight into the access and running of scripts by the
> php engine on my production box.
>
> Most scripts are executed via cronjobs and they invoke a lot of other
> php scripts. I can backtrace these files, but a lot of other scripts
> are run by our users from the command line and I want to know if it

possible
> to instruct the engine to log the names of these script files.
>
> I use php version 4.3.6 and I tried to modify the php.ini file to enable
> logging, but the logfile only reports errors and not the access/execution

a
> scriptfile.
>
> Is there a way to instruct the php engine to log the execution of
> scriptfiles?
>
> Cheers
> Karoshi
>
>
>
>
>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0