Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Posts
    23

    Unanswered: Displaying DBCC PSS Result

    Hi all an happy new year

    Well... may be you can help me... i'm making a web page, that page makes a lot of functions, monitoring 5 servers of databases, 11 building of primari atention, ping many IP's, web servers and some more things... but... one of this pages returns a list with locked processes in Sybase databases... when i have the PID of the process locking, must go to another tool, modify a query and capture the process like this :

    dbcc traceon (3604)
    go
    dbcc pss(301,PID,1)
    go
    dbcc traceoff
    go

    With this i can work fine, but i want make some more functional, but i can't capture and display the result of this query in a web page... in first place make a batch who work with "isql" in the S.O., but later must change the S.O. from Window$ to Linux, everithing work fine, less this Batch, later makes a SP_ but the result not work, just return 2 lines and bad result...

    Can some help me ???... i'm working with Sybase 11.0.3.3

    Need to capture the result from DBCC PSS in a array or just display it in a white page to read it without use nother tool to obtain some result.

    Thanx for your help

    P.S.: Sorry my english

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    You might be better posting this in the sybase area of the forum, as you haven't supplied any PHP code that might be relevant.

  3. #3
    Join Date
    Dec 2007
    Posts
    23
    Ok...

    forgive the sybase code... it is no relevant
    then... how i can capture the result from the "dbcc pss" query with PHP???
    or... how i make PHP display that result in a page ???
    sybase_query() and sybase_fetch_array() return empty result and can't asociate the result to a variable...
    can php obtain result from this instruction ??? (dbcc pss)

    if you ignore wath to do the dbcc command, that is some like "showplan" but showplan sucks :P dont work properly... >_<

    everybody know how execute a query and display is result in PHP, but, how do the same with DBCC PSS result ???

    I use "system" to execute a batch with "isql", tha "isql" runs a file with the sentences and the variable obtain from the php site, store the result in another file, read this file and display it in the php page... but i can't do that animore T_T

    somebody help me !!!??? T_T

    Grettigs

    P.S.: thnx for the seed, useless, but thanx anyway

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if the command isnt valid SQL then I doubt that you will be able to read what you want in a standard PHP function like fetch_array

    you may need to use another route to access that data.. ie connecting directly tot he server, rather than going through a web server.. which may well make what you want to do impossible to achieve within PHP

  5. #5
    Join Date
    Dec 2007
    Posts
    23
    The sentense is right, is just like post in first post...

    If i run it in some tool (dbrtisan, rapid SQL, etc.) obtain just the properly result... but i can't find a way to display it result in a PHP page...

    sybase_fetch_array() just return bolean result (0 or 1), but not the full text from the query...

    i make a SP and execute it, but don't know how to refer to the full result...

    Tha function retur some like that :

    DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
    {

    PSS (any state) for suid 31 - spid 34:

    PSS at 0x423d26f8

    pstat=0x50000 (0x00040000 (P_SETDATEFMT), 0x00010000 (P_USERPROC))
    p2stat=0x1001000 (0x01000000 (P2_PSWD_CHANGING), 0x00001000 (P2_XLATE))
    p3stat=0x0 (0x00000000)
    pcurdb=5 psuid=31 puid=1 pxdes=0x41b18ef0 ppss=0x423d26f8
    puname= ploginflags=7 prowcnt=999 pstatlist=0x0
    pnumplan=0 pattention=0 plasterror=0 ppreverror=0 ptranstate=1
    prowcount=1 plastprocid=160730229 pprocnest=1
    pgid=0 phid=0 pspid=34 pkspid=1833041984
    poptions= 7 (OPT_TRUNCABORT) 8 (OPT_ARITHABORT) 13 (OPT_CONTROL) 20 (OPT_ROWCOUNT) 40 (OPT_PREFETCH) 41 (OPT_TRIGGERS) 42 (OPT_REPLICATION)
    poffsets=0 pcurcmd=193 (SELECT)
    pcputot=3 pcpucur=10 pmemusage=2 pbufread=11764
    pbufwrite=3 pcmderrs=0 pntext=91 ptext=0x0
    donestat=0x40, doneinfo=0 donecount=0
    pxactcnt=0 ptimeslice=1 pcurcolid=0
    pcompct=0 phdr=0x145b52000 pplan=0x145b52000
    phosttype=0 phsocket=0 phindex=0 pline=10
    ptrigdate=0x0 pwaitsema=0x0 premote=0x0
    precvbuf=0x1421a9760 psendbuf=0x1421a9790 pdbtable=0x143c71240 ppars=0x0
    pcurstep=0x467bf000 pnetid=0 pextobject=0x0 pbegintmps=0x0
    pdbindex=-1 pdb_stat=1 pbackground=0
    ploginrec=0x421b5228 ptdsversion=4.2.0.0
    pstackbound=0x4081d940 pguardbound=0x4081e940
    pmasterxact=0x0 pinternalxact=0x0 pplc=0x4415ceb0
    pcss=0x0 pfreecss=0x0 pcss_cache=0x0 pcurcss=0x0
    IDENTITY_VAL info
    objid=0 dbid=0 idtnum=0
    IDENTITY_INSERT settings
    objid=0 dbid=0 state=0


    PHDR proc header:
    PROC_HDR at 0x145b52000
    p_hdrstep=0x145ab7168 p_hdrseq=0x0 p_hdrcrt=0x0
    p_hdrpbuf=0x1435b01c0 p_hdrtmps=0x0 p_hdrcaller=0x146712800
    p_hdrelease=0 p_hdrtabid=160730229 p_hdrsub=0x0
    p_hdrsubcnt=0 p_css=0x0 p_csscnt=0
    p_hdrstatus=0x1 (0x00000001 (CACHED))
    p_lastpg=0 p_lastoff=12 p_procnum=0 p_hdrdbid=5
    p_hdraux=0x0 p_lostcnt=721 p_hdrtype=2

    Memory Allocation Map:


    0 mempgptr=0x145b52000 byte_count=2044 byte_save=2044
    1 mempgptr=0x145ab7000 byte_count=2048 byte_save=2048
    2 mempgptr=0x1450a9800 byte_count=2048 byte_save=2048
    3 mempgptr=0x14639a800 byte_count=2044 byte_save=2044
    4 mempgptr=0x145004000 byte_count=2027 byte_save=2027
    5 mempgptr=0x146833000 byte_count=2048 byte_save=2048
    6 mempgptr=0x14514a800 byte_count=2024 byte_save=2024
    7 mempgptr=0x1466f6800 byte_count=2040 byte_save=2040
    8 mempgptr=0x144574000 byte_count=2037 byte_save=2037
    9 mempgptr=0x14588f000 byte_count=2048 byte_save=2048
    10 mempgptr=0x144b42800 byte_count=2024 byte_save=2024
    11 mempgptr=0x145964800 byte_count=1976 byte_save=1976
    12 mempgptr=0x1467bf000 byte_count=160 byte_save=160


    PPLAN proc header:


    PTEXT proc header:


    PNETBUFP:


    T-SQL command (may be truncated): *BD_ENTI_CORPORATIVA..AUGE_TraeAugeAgendada


    DES LIST (user objects):

    DES (any state) for objid 2074449018 in dbid 5:
    Current database (5) BD_ENTI_CORPORATIVA:


    DES at 0x43bc63f0

    dirty_chain=0x43b0e830 dnew=0x43b0e830 dold=0x43b0e830
    ddbid=5
    objone=1 objrno=4 objuid=1
    dobjstat.objid=2074449018
    dobjstat.objuserstat=0x0
    dobjstat.objsysstat=0x53 3 (O_USER) (0x00000040 (O_LOGGED), 0x00000010 (O_CLUST))
    dobjstat.objsysstat2=0x8 (0x00000008 (O2_PKEY))
    dobjstat.objindexdel=0 dobjstat.objschema=3dobjstat.objcoldel=0
    objdeltrig=0 objinstrig=0 objupdtrig=0
    objseltrig=0 objckfirst=0 objtype [85],[32]
    objcache=0 objlen=87 objname=AUGE_Citacion objaudflags=0
    dindc.ind_first=0 dindc.ind_root=0
    dindc.ind_maxlen=117 dindc.ind_minlen=6
    dindwork=0x0 dnextdes=0x43bcab60
    dihash=0x0 dnhash=0x43beeed0 ddbtable=0x43c71240 dkeepcnt=1
    dstate=0x1 1 (ACTIVE_STATE)
    dstatus=0x0 (0x0000)
    dunkept=0x43c30298 dkept=0x43b179f0 dipgtripcnt=0 doampgtripcnt=0
    dworkindlen=0 doampg=10650369 dstatus=0 dtsoff=0
    dtscolid=0 didt.coloff=0 didt.colid=0 dlevel0cnt=0
    dlg_prefetch_ok=0 diosize=2048 dworktable_number=0
    dslinfo.sd_numslices=1
    dslinfo.sd_slice1.slicenum=1 sc_first=10650370 sc_ctrlpg=0 sc_root=10648985
    dlkprom.lwm = 200 dlkprom.hwm = 500 dlkprom.pct = 100
    dlkprom.status = 1 dlkprom.seqno = 2
    approx data pages = 12300
    lock promotion level = 500
    Object mapped to cache -1.
    Index 1 mapped to cache -1.




    DES LIST (system objects):


    PPLAN p_hdrpbuf proc buffer:

    address=0x1435b01c0 id=160730229 pbdbid=5
    pbuid=1 pbihash=0x0 pbnhash=0x0 pbold=0x1435a1e40
    pbnew=0x1435a9340 pbprochdr=0x145b52000 pbparam=0x146a5d8e0 pbtype=4
    pbstate=1 pbstat=0x0 pbusecnt=1 pbspid=34
    pbname=AUGE_TraeAugeAgendada pbprocnum=1

    PPLAN pbdes descriptor:

    DES (any state) for objid 160730229 in dbid 5:
    Current database (5) BD_ENTI_CORPORATIVA:


    DES at 0x43c30298

    dirty_chain=0x43b102e0 dnew=0x43b102e0 dold=0x43b102e0
    ddbid=5
    objone=1 objrno=9 objuid=1
    dobjstat.objid=160730229
    dobjstat.objuserstat=0x0
    dobjstat.objsysstat=0x4 4 (O_PROC) (0x00000000)
    dobjstat.objsysstat2=0x80 (0x00000080 (O2_NEWSUBQSTYLE))
    dobjstat.objindexdel=0 dobjstat.objschema=0dobjstat.objcoldel=0
    objdeltrig=0 objinstrig=0 objupdtrig=0
    objseltrig=0 objckfirst=0 objtype [80],[32]
    objcache=0 objlen=95 objname=AUGE_TraeAugeAgendada objaudflags=0
    dindc.ind_first=0 dindc.ind_root=0
    dindc.ind_maxlen=-1 dindc.ind_minlen=-1
    dindwork=0x0 dnextdes=0x43c11a70
    dihash=0x0 dnhash=0x43bc4038 ddbtable=0x43c71240 dkeepcnt=1
    dstate=0x1 1 (ACTIVE_STATE)
    dstatus=0x0 (0x0000)
    dunkept=0x0 dkept=0x43bc63f0 dipgtripcnt=0 doampgtripcnt=0
    dworkindlen=0 doampg=0 dstatus=0 dtsoff=0
    dtscolid=0 didt.coloff=0 didt.colid=0 dlevel0cnt=0
    dlg_prefetch_ok=0 diosize=0 dworktable_number=0
    dslinfo.sd_numslices=1
    dslinfo.sd_slice1.slicenum=0 sc_first=-1 sc_ctrlpg=0 sc_root=-1
    dlkprom.lwm = 0 dlkprom.hwm = 0 dlkprom.pct = 0
    dlkprom.status = 0 dlkprom.seqno = 0
    approx data pages = 0
    lock promotion level = 0
    Object mapped to cache -1.




    PPLAN (execution) p_hdrstep plan:

    QUERY PLAN FOR STATEMENT 1 (at line 0).


    STEP 1
    The type of query is DECLARE.


    QUERY PLAN FOR STATEMENT 2 (at line 10).


    STEP 1
    The type of query is SELECT.

    FROM TABLE
    AUGE_Citacion
    Nested iteration.
    Table Scan.
    Ascending scan.
    Positioning at start of table.
    Using I/O Size 2 Kbytes.
    With LRU Buffer Replacement Strategy.


    QUERY PLAN FOR STATEMENT 3 (at line 17).


    STEP 1
    The type of query is COND.


    QUERY PLAN FOR STATEMENT 4 (at line 19).


    STEP 1
    The type of query is SELECT.

    FROM TABLE
    AUGE_Citacion
    Nested iteration.
    Table Scan.
    Ascending scan.
    Positioning at start of table.
    Using I/O Size 2 Kbytes.
    With LRU Buffer Replacement Strategy.


    QUERY PLAN FOR STATEMENT 5 (at line 26).


    STEP 1
    The type of query is COND.


    QUERY PLAN FOR STATEMENT 6 (at line 28).


    STEP 1
    The type of query is SELECT.

    FROM TABLE
    AUGE_Citacion
    Nested iteration.
    Table Scan.
    Ascending scan.
    Positioning at start of table.
    Using I/O Size 2 Kbytes.
    With LRU Buffer Replacement Strategy.


    QUERY PLAN FOR STATEMENT 7 (at line 35).


    STEP 1
    The type of query is COND.


    QUERY PLAN FOR STATEMENT 8 (at line 37).


    STEP 1
    The type of query is SELECT.

    FROM TABLE
    AUGE_Citacion
    Nested iteration.
    Table Scan.
    Ascending scan.
    Positioning at start of table.
    Using I/O Size 2 Kbytes.
    With LRU Buffer Replacement Strategy.


    QUERY PLAN FOR STATEMENT 9 (at line 44).


    STEP 1
    The type of query is COND.


    QUERY PLAN FOR STATEMENT 10 (at line 46).


    STEP 1
    The type of query is SELECT.

    FROM TABLE
    AUGE_Citacion
    Nested iteration.
    Table Scan.
    Ascending scan.
    Positioning at start of table.
    Using I/O Size 2 Kbytes.
    With LRU Buffer Replacement Strategy.


    QUERY PLAN FOR STATEMENT 11 (at line 0).


    STEP 1
    The type of query is GOTO.

    }
    DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
    DBCC execution completed. If DBCC printed error messages, contact a user with System Administrator (SA) role.
    i need show that in the page...

    Plz help me

    Thnx

    P.S.: Sorry about the full result... it's too much, but give a light about wath i want
    There's only 10 kinds of people: the ones who know binary and the ones who doesn't

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    As said before I don't think this is valid SQL, so I don't esxpect it to populate an associative array. its a specific sybase server command, which the PHP library may not implement.... check PHP.NET and the sybase adapater.. mebbe theres an updated library for PHP to connect to Sybase that does what you want, or possibly its soemhting else .. say sybase_get_last_message or some other function

    alternatively can you get the server to dump the output to a file, and then read the file?

  7. #7
    Join Date
    Dec 2007
    Posts
    23
    that i do in first place

    $var1 = "use database\n";
    $var2 = "dbcc traceon (3604)\n";
    $var3 = "dbcc pss(301,".$_GET["proceso"].",1)\n";
    $var4 = "dbcc traceoff";
    $nombre_archivo = 'batch_file.sql';

    if (is_writable($nombre_archivo)) {
    if (!$gestor = fopen($nombre_archivo, 'w')) {
    echo "No se puede abrir el archivo".$nombre_archivo;
    exit;
    }

    if (fwrite($gestor, $var1) === FALSE)
    {
    echo "No se puede escribir al archivo".$nombre_archivo."<br>";
    exit;
    }
    if (fwrite($gestor, $var2) === FALSE)
    {
    echo "No se puede escribir al archivo".$nombre_archivo."<br>";
    exit;
    }
    if (fwrite($gestor, $var3) === FALSE)
    {
    echo "No se puede escribir al archivo".$nombre_archivo."<br>";
    exit;
    }

    if (fwrite($gestor, $var4) === FALSE)
    {
    echo "No se puede escribir al archivo".$nombre_archivo."<br>";
    exit;
    }

    fclose($gestor);
    system('/isql -S server -U us -P pass -i batch_file.sql -o output.resul');

    $row = 1;
    $handle = fopen("resultado.resul", "r");
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    echo "<tr><td><n>".$row.": </n></td>";
    $row++;
    for ($c=0; $c < $num; $c++) {
    echo "<td>".$data[$c] . "<br/></td></tr>";
    }
    }
    fclose($handle);


    } else {
    echo "No se puede escribir sobre el archivo".$nombre_archivo;
    }
    that work fine... but i don do that anymore T_T
    need make it with array o some way to show the full result in the page T_T

    Thnx again

    P.S.: the code is not optimised, but i'm just a DBA autodidact programming... :P
    There's only 10 kinds of people: the ones who know binary and the ones who doesn't

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •