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:
http://server.somewhere.com/graph.asp?ID=45&Path=G%3A%5C&Label=DiskLabel&Server=BigServer
This link contains 4 parameters.
This link contains 4 parameters.
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"
sDBserver = "Server"
sDBname = "Database"
sConnStr = "Provider=SQLOLEDB;Server=" & sDBserver &_
";Database=" & sDBname &_
";Integrated Security=SSPI"
";Database=" & sDBname &_
";Integrated Security=SSPI"
'Create and open the Connection object.
Set oADOconn = Server.CreateObject("ADODB.Connection")
oADOconn.Open sConnStr
oADOconn.CommandTimeout = 0
%>
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")
<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)
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)
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.WriteLine oRS("Date") & vbTab & Round(oRS("Used")/1024, 1)
oRS.MoveNext
Loop
oTempFile.Close
oRS.Close
oADOconn.Close
Set oRS = Nothing
Set oADOconn = Nothing
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) & "'>"
' &-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)
Session("sTempFile" & Session("n")) = Server.MapPath(sTempFile)
' Increment the number of files
Session("n") = Session("n") + 1
Session("n") = Session("n") + 1
%>
</BODY>
</HTML>
</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 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
Session("n") = 0
' Set timeout to be 1 minute
Session.Timeout = 1
End Sub
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>
' 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*****