php engine scripts execution logging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • karoshi

    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


  • karoshi

    #2
    Re: php engine scripts execution logging

    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_fi le =
    auto_append_fil e = /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_fi les();

    for ($index = 0; $index < sizeof(get_incl uded_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:cdlo08$83l $1@reader13.wxs .nl...[color=blue]
    > 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[/color]
    possible[color=blue]
    > 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[/color]
    a[color=blue]
    > scriptfile.
    >
    > Is there a way to instruct the php engine to log the execution of
    > scriptfiles?
    >
    > Cheers
    > Karoshi
    >
    >[/color]


    Comment

    Working...