Loading ...
Sorry, an error occurred while loading the content.

Howto use ploticus CGI with ASP/VBS

Expand Messages
  • Craig Williams
    Saw a post for someone looking how to do this a couple weeks ago. Most of the examples with the doc are for Perl, so I wanted to share this. Follow the basic
    Message 1 of 2 , Jan 30, 2005
    • 0 Attachment
      Saw a post for someone looking how to do this a couple weeks ago.
      Most of the examples with the doc are for Perl, so I wanted to share this.
      Follow the basic CGI instructions from the Ploticus doc, such as creating a cgi-bin dir, copying ploticus to that dir, and then read on...
       
      If using Server2003, enable pl.exe as a CGI extension in the IIS MMC.
      Create a global.asa file in the root of the virtual web root (contents at end of post).
      Don't overwrite any existing global.asa. Make a new virtual web root.
      Copy the graph.asp (contents at end of post) to your virtual web root.
      Make a directory called temp in your virtual web root.
      This is the directory where the numeric data for the plot will be temporarily stored.
      If using windows integrated security, grant the Group change access to the temp dir.
      If using anonymous, grant IUSR_SERVERNAME change access to the temp dir.
      For either, also grant the Creator group change access to the temp dir.
      Construct/Modify the page where you want to link to the graphs.
       
      This example includes 3 files:
      global.asa - Global Application Settings file - creates a session variable used to store a list of the temp files created
      graph.asp - Link to this from another page, and pass it the parameters of what you would like graphed.
      There will be a 3rd file that I won't go into here. Mine is custom to my application, and would not be of benefit. You simply need a page that contains a link such as:
      ID and Path are used to define that data will be selected for the graph through SQL.
      Label, Server are passed to pl.exe to be included as labels in the graph.
      The app I wrote this for is graphing some disk usage data.
       
      Graphs will be created dynamically on the server. The global.asa file defines a session timeout of 1 minute, after which the numeric graph data file will be deleted.
      This example uses the cron prefab, adjust per your needs. There's also some SQL going on to retrieve the numeric graph data. Adjust depending on how and where you need to retrieve your data.
       
      *****BEGIN FILE: GRAPH.ASP*****
      <%
      sDBserver = "Server"
      sDBname = "Database"
      sConnStr = "Provider=SQLOLEDB;Server=" & sDBserver &_
            ";Database=" & sDBname &_
            ";Integrated Security=SSPI"
      'Create and open the Connection object.
      Set oADOconn = Server.CreateObject("ADODB.Connection")
      oADOconn.Open  sConnStr
      oADOconn.CommandTimeout = 0
      %>
      <HTML>
      <BODY>
      <%
      sID = Request.QueryString("ID")
      sPath = Request.QueryString("Path")
      sTitle = Request.QueryString("Server")
      sLabel = Request.QueryString("Label")
      SQLQuery = "SELECT Date, Used FROM tblHist WHERE ID='" & sID & "' AND Path='" & sPath & "' ORDER BY Date ASC"
      Set oRS = oADOconn.Execute(SQLQuery) 
      ' Get a temporary filename to save chart in that file
      sTempFile = "temp/" & Session("FSO").GetTempName
      Set oTempFile = Session("FSO").CreateTextFile(Server.MapPath(sTempFile), True)
      Do While Not oRS.EOF
       oTempFile.WriteLine oRS("Date") & vbTab & Round(oRS("Used")/1024, 1)
       oRS.MoveNext
      Loop
      oTempFile.Close
      oRS.Close
      oADOconn.Close
      Set oRS = Nothing
      Set oADOconn = Nothing
      ' Invoke the CGI and pass it the path to the data file
      ' &-debug
      Response.Write "<IMG SRC='/cgi-bin/pl.exe?cgi=1&-prefab&chron&x=1&y=2&xgrid=yes&ygrid=yes" &_
       "&title=" & sTitle &_
       "&name=" & Left(sPath, 2) & " " & sLabel &_
       "&data=" & Server.MapPath(sTempFile) & "'>"
      ' Store the file with its path in the session object for cleanup
      Session("sTempFile" & Session("n")) = Server.MapPath(sTempFile)
      ' Increment the number of files
      Session("n") = Session("n") + 1
      %>
      </BODY>
      </HTML>
      *****END FILE: GRAPH.ASP*****
       
      *****BEGIN FILE: GLOBAL.ASA*****
      <SCRIPT LANGUAGE=VBScript RUNAT=Server>
      Sub Session_OnStart
       ' Create a FileSystemObject to provide files in the script
       Set Session("FSO") = CreateObject("Scripting.FileSystemObject")
       ' Create a variable that has the number of files created in this session
       Session("n") = 0
       ' Set timeout to be 1 minute
       Session.Timeout = 1
      End Sub
      Sub Session_OnEnd
       ' Delete the files created in this session
       Dim x
       For x = 0 to Session("n")-1
        Session("FSO").DeleteFile Session("sTempFile" & x), True
       Next
      End Sub
      </SCRIPT>
      *****END FILE: GLOBAL.ASA*****
       
    • Jamie Echlin
      Hi, Is there some equivalent to the command line arg -csmap that I can use in #proc page? According to the docs no. My problem is that the pl.exe invocation is
      Message 2 of 2 , Feb 3, 2005
      • 0 Attachment
        Hi,

        Is there some equivalent to the command line arg -csmap that I can use in
        #proc page? According to the docs no.

        My problem is that the pl.exe invocation is buried away in a mod_perl app,
        and I won't know whether there will be clickable sections or not, let's say
        a third party is writing the plot templates. I use SVG only so there are no
        external files. If I use the -csmap I get:
        pl: error 2795: Warning, no map regions were assigned (stdout)

        Which although says it's a warning, gets categorised by my app as an error.

        Any ideas?

        Cheers, jamie


        --
        http://www.onresolve.com
      Your message has been successfully submitted and would be delivered to recipients shortly.