我想知道是否可以使用php访问Windows性能计数器?
基本上,我已经有了一个PHP应用程序,并且我有一个基本的vb脚本,可以访问性能计数器并从中创建变量。我需要的是能够使用PHP访问这些相同的性能计数器,因此在PHP应用程序中将它们设置为变量。
如果那是不可能的,有没有办法可以使用PHP应用程序中的vb脚本来使用变量?我宁愿不这样做,因为我在这个意义上知识有限,但如果这是我必须学习的唯一方法。
我可以在需要时发布代码,但是现在我只需要知道我问的是否可能。
由于
编辑:
我的vb代码如下:
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.CompilerServices
Imports Microsoft.Win32
Imports System
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Data.SqlClient
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim perfActiveUsers As New PerformanceCounter("ASP.NET Apps v2.0.50727", "Sessions Active", "__Total__")
Dim perfAlcInstances As New PerformanceCounter("Alchemy Web Pool Manager", "Alchemy Instances Active")
Dim perfAlcAvgResponse As New PerformanceCounter("Alchemy Web Pool Manager", "Request Average Response Time")
Dim perfAlcQueue As New PerformanceCounter("Alchemy Web Pool Manager", "Requests Queued")
Dim perfAlcTimeout As New PerformanceCounter("Alchemy Web Pool Manager", "Requests Timed Out")
Dim perfAlcTotal As New PerformanceCounter("Alchemy Web Pool Manager", "Requests Total")
Dim totalDBs As String = "0"
Dim SQLStr As String
Dim ConnString As String = "Server=ALCHEMYSVR\SQLEXPRESS;Database=AuServer;Integrated Security=SSPI;User Id=STORETECSERVICE\administrator;Password=westend"
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim SQLdr As SqlDataReader 'The Local Data Store
SQLStr = "SELECT COUNT (*) FROM AusDatabase"
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data
Do
While (SQLdr.Read()) 'While Data is Present
totalDBs = SQLdr(0)
MsgBox(SQLdr(0)) 'Show data in a Message Box
End While
Loop While SQLdr.NextResult() 'Move to the Next Record
SQLdr.Close() 'Close the SQLDataReader
SQLConn.Close() 'Close the connection
'Display The Values
lblAlcInstances.Text = perfAlcInstances.NextValue()
lblActiveUsers.Text = perfActiveUsers.NextValue()
Label1.Text = perfAlcAvgResponse.NextValue()
Label2.Text = perfAlcQueue.NextValue()
Label3.Text = perfAlcTimeout.NextValue()
Label4.Text = perfAlcTotal.NextValue()
Label5.Text = totalDBs
End Sub
End Class
这是分配给底部标签的性能计数器值,我需要将其作为变量传递给php。我已经尝试过PHP exec但是无法掌握如何将vb脚本中的变量传递给PHP中的变量。
答案 0 :(得分:0)
如果您尝试通过PHP获取Windows系统数据,可能会有点讨厌。
如果您已有VB脚本,则有两个常用选项: