Сообщение
lysyy » Чт июл 16, 2015 7:49 pm
Мне как админу привычнее Powershell, сейчас пишу скрипт, который для любого компа разберет Json - ответ этой проги. Пока есть вот это, для размышлений и наглядности, ближе к вечеру или завтра сделаю окончательный скрипт, который будет закидывать инфу вытянутую в MD.
В переменную отправляется ответ на компе с MD, что бы каждый раз его не опрашивать.
$json = '{"id": 0, "Text": "Sensor", "Children": [{"id": 1, "Text": "ASS", "Children": [{"id": 2, "Text": "Gigabyte D425TUD", "Children": [{"id": 3, "Text": "ITE IT8720F", "Children": [{"id": 4, "Text": "Voltages", "Children": [{"id": 5, "Text": "CPU VCore", "Children": [], "Min": "1,104 V", "Value": "1,104 V", "Max": "1,104 V", "ImageURL": "images/transparent.png"}, {"id": 6, "Text": "DRAM", "Children": [], "Min": "1,504 V", "Value": "1,504 V", "Max": "1,504 V", "ImageURL": "images/transparent.png"}, {"id": 7, "Text": "+3.3V", "Children": [], "Min": "3,344 V", "Value": "3,344 V", "Max": "3,344 V", "ImageURL": "images/transparent.png"}, {"id": 8, "Text": "+5V", "Children": [], "Min": "4,973 V", "Value": "4,973 V", "Max": "4,973 V", "ImageURL": "images/transparent.png"}, {"id": 9, "Text": "Voltage #5", "Children": [], "Min": "3,056 V", "Value": "3,072 V", "Max": "3,072 V", "ImageURL": "images/transparent.png"}, {"id": 10, "Text": "Voltage #6", "Children": [], "Min": "4,080 V", "Value": "4,080 V", "Max": "4,080 V", "ImageURL": "images/transparent.png"}, {"id": 11, "Text": "Voltage #7", "Children": [], "Min": "4,080 V", "Value": "4,080 V", "Max": "4,080 V", "ImageURL": "images/transparent.png"}, {"id": 12, "Text": "Voltage #8", "Children": [], "Min": "2,144 V", "Value": "2,144 V", "Max": "2,144 V", "ImageURL": "images/transparent.png"}, {"id": 13, "Text": "VBat", "Children": [], "Min": "3,248 V", "Value": "3,248 V", "Max": "3,248 V", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/voltage.png"}, {"id": 14, "Text": "Temperatures", "Children": [{"id": 15, "Text": "Temperature #2", "Children": [], "Min": "25,0 В°C", "Value": "25,0 В°C", "Max": "25,0 В°C", "ImageURL": "images/transparent.png"}, {"id": 16, "Text": "Temperature #3", "Children": [], "Min": "55,0 В°C", "Value": "55,0 В°C", "Max": "56,0 В°C", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/temperature.png"}, {"id": 17, "Text": "Fans", "Children": [{"id": 18, "Text": "Fan #1", "Children": [], "Min": "4655 RPM", "Value": "4821 RPM", "Max": "4891 RPM", "ImageURL": "images/transparent.png"}, {"id": 19, "Text": "Fan #2", "Children": [], "Min": "1510 RPM", "Value": "1513 RPM", "Max": "1517 RPM", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/fan.png"}, {"id": 20, "Text": "Controls", "Children": [{"id": 21, "Text": "Fan Control #1", "Children": [], "Min": "-", "Value": "-", "Max": "-", "ImageURL": "images/transparent.png"}, {"id": 22, "Text": "Fan Control #2", "Children": [], "Min": "2,0 %", "Value": "2,0 %", "Max": "2,0 %", "ImageURL": "images/transparent.png"}, {"id": 23, "Text": "Fan Control #3", "Children": [], "Min": "0,0 %", "Value": "0,0 %", "Max": "0,0 %", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/control.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/chip.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/mainboard.png"}, {"id": 24, "Text": "Intel Atom D425", "Children": [{"id": 25, "Text": "Clocks", "Children": [{"id": 26, "Text": "Bus Speed", "Children": [], "Min": "200 MHz", "Value": "200 MHz", "Max": "200 MHz", "ImageURL": "images/transparent.png"}, {"id": 27, "Text": "CPU Core", "Children": [], "Min": "1800 MHz", "Value": "1800 MHz", "Max": "1800 MHz", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/clock.png"}, {"id": 28, "Text": "Temperatures", "Children": [{"id": 29, "Text": "CPU Core", "Children": [], "Min": "43,0 В°C", "Value": "44,0 В°C", "Max": "45,0 В°C", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/temperature.png"}, {"id": 30, "Text": "Load", "Children": [{"id": 31, "Text": "CPU Core", "Children": [], "Min": "94,0 %", "Value": "100,0 %", "Max": "100,0 %", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/load.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/cpu.png"}, {"id": 32, "Text": "Generic Memory", "Children": [{"id": 33, "Text": "Load", "Children": [{"id": 34, "Text": "Memory", "Children": [], "Min": "30,9 %", "Value": "34,0 %", "Max": "35,2 %", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/load.png"}, {"id": 35, "Text": "Data", "Children": [{"id": 36, "Text": "Used Memory", "Children": [], "Min": "0,9 GB", "Value": "1,0 GB", "Max": "1,1 GB", "ImageURL": "images/transparent.png"}, {"id": 37, "Text": "Available Memory", "Children": [], "Min": "1,9 GB", "Value": "2,0 GB", "Max": "2,1 GB", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/power.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/ram.png"}, {"id": 38, "Text": "WDC WD7500BPVT-80HXZT1", "Children": [{"id": 39, "Text": "Temperatures", "Children": [{"id": 40, "Text": "Temperature", "Children": [], "Min": "30,0 В°C", "Value": "30,0 В°C", "Max": "31,0 В°C", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/temperature.png"}, {"id": 41, "Text": "Load", "Children": [{"id": 42, "Text": "Used Space", "Children": [], "Min": "47,8 %", "Value": "47,8 %", "Max": "47,8 %", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/load.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/hdd.png"}, {"id": 43, "Text": "ST3250824A", "Children": [{"id": 44, "Text": "Temperatures", "Children": [{"id": 45, "Text": "Temperature", "Children": [], "Min": "0,0 В°C", "Value": "33,0 В°C", "Max": "34,0 В°C", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/temperature.png"}, {"id": 46, "Text": "Load", "Children": [{"id": 47, "Text": "Used Space", "Children": [], "Min": "84,7 %", "Value": "84,7 %", "Max": "84,8 %", "ImageURL": "images/transparent.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/load.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/hdd.png"}], "Min": "", "Value": "", "Max": "", "ImageURL": "images_icon/computer.png"}], "Min": "Min", "Value": "Value", "Max": "Max", "ImageURL": ""}';
$a = ConvertFrom-json $json
cls
#Поуровневое раскидалово структуры в объекте, смотрим что получается
foreach ($q in $a.Children)
{
"Q"
#$q.Text
#$q.value
foreach ($w in $q.Children){
"W"
#$w.Text
#$w.value
foreach ($e in $q.Children){
"E"
#$e.Text
#$e.Text
#$e.value
foreach ($r in $e.Children){
"R"
# $r.Text
# $r.Text
#$r.value
foreach ($t in $r.Children){
"t"+" R = ",$r.text," E = ",$e.text," Q = ",$q.text
$t.Text
$t.Text
$t.value
}
}
}
}
}