サーバーダッシュボードアプリを構築しています。各サーバーからディスクのリストを取得し、それぞれの使用量の値を表示するリストを作成したいと考えています。
これが返される JSON サンプルです...
{"server":"webster","disks":[ {"use": "91%", "used": "16G", "mount": "/", "free": "1.6G", "device": "/dev/mapper/vg_f12-lv_root", "total": "18G", "type": "ext4"} ,
{"use": "0%", "used": "0", "mount": "/dev/shm", "free": "500M", "device": "tmpfs", "total": "500M", "type": "tmpfs"} ,
{"use": "22%", "used": "40M", "mount": "/boot", "free": "145M", "device": "/dev/sda1", "total": "194M", "type": "ext4"} ,
{"use": "47%", "used": "52G", "mount": "/rsync", "free": "61G", "device": "/dev/sdb1", "total": "119G", "type": "ext3"} ]}
私はC#コードでこれまでに取得します:
WebClient c = new WebClient();
var data = c.DownloadString("http://192.0.0.40:8000/cgi-bin/df.py");
JObject o = JObject.Parse(data);
string serv = o["server"].Select(s => (string)s).ToString();
lblJson.Text = serv;
しかし、リストビューにプラグインできる意味のあるものに「ディスク」を抽出できないようです。これを IList に送り込もうとしましたが、常にクラッシュするか、Intellisense から無礼なコメントが返ってきます。
このために構築されたクラスがありますが、情報を移植する方法がわかりません。参考までに、それはここにあります:
public class drive
{
public string Usage;
public string usedSpace;
public string Mount;
public string freeSpace;
public string Device;
public string Total;
public string Type;
}
注: JSON のソースは Linux サーバーです。Windows サーバーは、最終的に別の形式でデータを提供します。
それから VMWare がありますが、それについては後で苦労します。
前もって感謝します。