Site24x7のオープンなエコシステムでは、カスタム プラグインの自作も可能であり、必要データを、希望の方法で監視できます。属性それぞれにしきい値を決め、指定値超過時のアラートを選択できます。Windowsプラグインの記述には、以下の選択肢があります。
プラグイン スクリプトは、JSONオブジェクトを返すものとします。JSONデータをSite24x7 Plusのサーバーに出力する際は、次のフォーマットに従ってください。
{
"version" : "1",
"data":{"Name":"John","Age":40,"Role":"Admin","Salary":87000,"Experience":3.4,"Performance":98.99},
"units":{"Age":"year","Salary":"Dollars","Experience":"years","Performance":"%"},
"heartbeat":"True",
"displayname":"Employee",
"msg":"Poor Performance"
}
version = "1"
heartbeat = "True"
displayname = "Employee"
Name = "John"
Age = 40
Role = "Admin"
Salary = 87000
Experience = 3.4
Performance = 48.99
data = AddData(data,"name",name)
data = AddData(data,"Age",Age)
data = AddData(data,"Role",Role)
data = AddData(data,"Salary",Salary)
data = AddData(data,"Experience",Experience)
data = AddData(data,"Performance",Performance)
units = AddData(units,"Age","year")
units = AddData(units,"Salary","Dollars")
units = AddData(units,"Experience","years")
units = AddData(units,"Performance","%")
mainJson = AddData(mainJson,"version",version)
mainJson = AddObj(mainJson,"data",data)
mainJson = AddObj(mainJson,"units",units)
mainJson = AddData(mainJson,"heartbeat",heartbeat)
mainJson = AddData(mainJson,"displayname",displayname)
if Performance < 50 then
mainJson = AddData(mainJson,"msg","Poor Performance")
End If
Wscript.Echo mainJson
Function AddData(data,key,value)
emptystr = ""
If data = emptystr then
data = "{"
Else
data = StrReverse(Replace(StrReverse(data),"}",",",1,1))
End If
AddData =
data & """" & key & """" &" : " & """" & value & """" & "}"
End Function
Function AddObj(data,key,value)
emptystr = ""
If data = emptystr then
data = "{" Else data = StrReverse(Replace(StrReverse(data),"}",",",1,1))
End If
AddObj = data & """" &
key & """" &" : " & value & "}"
End Function
{
"version" : "1",
"data":{"Name":"John","Age":40,"Role":"Admin","Salary":87000,"Experience":3.4,"Performance":98.99},
"units":{"Age":"year","Salary":"Dollars","Experience":"years","Performance":"%"},
"heartbeat":"True",
"displayname":"Employee",
"msg" : "Poor Performance"
}
当社コミュニティ(英語)への投稿『VBScriptによるプラグイン ファイルのサンプル:平均ディスクキュー長(Length、要素数)』を参照ください。
Function Add-Data
([string]$json,[string]$key,[string]$value,[bool]$isobj)
{
if($key -ne $null -and $value -ne $null)
{
if($json.Length -gt 0)
{
$json = $json
-replace "(.*)}(.*)", '$1,$2'
}
else
{
$json = $json + "{"
}
if($isobj -eq $true)
{
$json = $json + [char]34
+ $key + [char]34 + " : " + $value +"}"
}
else
{
$json = $json + [char]34 + $key + [char]34 + " : " + [char]34 + $value + [char]34 +"}"
}
}
return $json
}
$version = "1"
$displayname = "Server Monitor"
$heartbeat = "True"
$units = ""
$units = Add-Data $units "CPU_Usage" "%"
$units = Add-Data $units "Memory_Used" "%"
$units = Add-Data $units "Disk" "%"
$CPUusage = (Get-WmiObject win32_processor | Measure-Object -property LoadPercentage -Average | Select Average).Average
$os = Get-Ciminstance Win32_OperatingSystem
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
$msg = ""
$Memory = 100-$pctFree
if($Memory -gt 80)
{
$msg = "Memory Usage increases to "+$Memory +"%"
}
$Processes = (Get-Process).Count
$Disk = 1.2
$Services = 34
$data = ""
$data = Add-Data $data "CPUusage" $CPUusage
$data = Add-Data $data "Memory_Used" $Memory
$data = Add-Data $data "Processes" $Processes
$data = Add-Data $data "Disk" $Disk
$data = Add-Data
$data "Services" $Services
$mainJson = ""
$mainJson = Add-Data $mainJson "version" $version
$mainJson = Add-Data $mainJson "data" $data $true
$mainJson = Add-Data $mainJson "units" $units $true
$mainJson = Add-Data $mainJson "heartbeat"
$heartbeat
$mainJson = Add-Data $mainJson "displayname" $displayname
if($msg.Length -gt 0)
{
$mainJson = Add-Data $mainJson "msg" $msg
}
return $mainJson
@ECHO OFF
SET version="1"
SET heartbeat="True"
SET displayname="Network Traffic"
SET units={"Packets recieved":"sec","Packets sent":"sec","Bandwidth utilization":"Kbps","Speed":"Mbps"}
SET Packetsrecieved=10
SET Packetssent=4
SET Bandwidthutilization=12
SET Speed=87
SET Msg=""
IF %Bandwidthutilization% gtr 10 (
SET Msg="High Bandwidth Utilization"
)
SET data={"Packets recieved":%Packetsrecieved%,"Packets sent":%Packetssent%,"Bandwidth utilization":%Bandwidthutilization%,"Speed":%Speed%}
IF %Msg%=="" (
SET mainJson={"version" : %version%,"data" : %data%,"units" : %units%,"heartbeat" : %heartbeat%,"displayname" : %displayname%}
) ELSE (
SET mainJson={"version" : %version%,"data" : %data%,"units"
: %units%,"heartbeat" : %heartbeat%,"displayname" : %displayname%,"msg" : %Msg%}
)
ECHO %mainJson%
Site24x7のオープンなエコシステムでは、カスタム プラグインの自作も可能であり、必要データを、希望の方法で監視できます。属性それぞれにしきい値を決め、指定値超過時のアラートを選択できます。詳細は、こちらを参照ください。