protected override async Task GetValueAsync(SortedDictionary <string, string> ret, RefInt nextPollingInterval, CancellationToken cancel = default) { // sys/class/thermal/ から温度取得 foreach (var thermalFile in this.ThermalFiles) { string value = (await Lfs.ReadStringFromFileAsync(thermalFile.Value))._GetFirstFilledLineFromLines(); double d = ((double)value._ToInt()) / 1000.0; ret.TryAdd($"{thermalFile.Key}", NormalizeDoubleValue(d.ToString("F3"))); } if (IsSensorsCommandOk) { try { // Sensors コマンドで温度取得 var result = await EasyExec.ExecAsync(Consts.LinuxCommands.Sensors, "-u", cancel : cancel); string[] lines = result.OutputStr._GetLines(true); string groupName = ""; string fieldName = ""; foreach (string line2 in lines) { string line = line2.TrimEnd(); if (line.StartsWith(" ") == false && line._InStr(":") == false) { // グループ名 groupName = line.Trim(); } else if (line.StartsWith(" ") == false && line.EndsWith(":")) { // 値名 fieldName = line.Substring(0, line.Length - 1); } else if (line.StartsWith(" ") && line._GetKeyAndValue(out string key, out string value, ":")) { // 値サブ名 : 値 key = key.Trim(); value = value.Trim(); if (key.EndsWith("_input", StringComparison.OrdinalIgnoreCase)) { ret.TryAdd($"{groupName}/{fieldName}", NormalizeDoubleValue(value)); } } } } catch (Exception ex) { ex._Debug(); } } }
public async Task <byte[]> SignSeInternalAsync(ReadOnlyMemory <byte> srcData, string certName, string flags, string comment, int numRetry = 5, CancellationToken cancel = default) { if (SeInternalPasswordCache._IsEmpty()) { SeInternalPasswordCache = await Lfs.ReadStringFromFileAsync(SeInternalPasswordFilePath, oneLine : true); } return(await SignAsync(SeInternalPasswordCache, srcData, certName, flags, comment, numRetry, cancel)); }
protected override async Task GetValueAsync(SortedDictionary <string, string> ret, RefInt nextPollingInterval, CancellationToken cancel = default) { if (IsConnTrackOk) { try { // ConnTrack var result = await EasyExec.ExecAsync(Consts.LinuxCommands.ConnTrack, "-C"); string valueStr = result.OutputStr._GetFirstFilledLineFromLines(); ret.TryAdd($"ConnTrack Sessions", valueStr._ToInt().ToString()); } catch (Exception ex) { ex._Debug(); } } if (true) { try { // Threads var result = EasyExec.ExecBashAsync("ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }'")._GetResult(); string valueStr = result.OutputStr._GetFirstFilledLineFromLines(); ret.TryAdd($"Threads", valueStr._ToInt().ToString()); } catch (Exception ex) { ex._Debug(); } } if (true) { try { // FDs string result = await Lfs.ReadStringFromFileAsync(Consts.LinuxPaths.FileNr, flags : FileFlags.NoCheckFileSize); string valueStr = result._GetFirstFilledLineFromLines(); string[] tokens = valueStr._Split(StringSplitOptions.RemoveEmptyEntries, " ", "\t"); int numFd = -1; if (tokens.Length >= 1) { numFd = tokens[0]._ToInt(); } ret.TryAdd($"FDs", numFd.ToString()); } catch (Exception ex) { ex._Debug(); } } if (true) { try { // Sockets string[] lines = (await Lfs.ReadStringFromFileAsync(Consts.LinuxPaths.SockStat, flags: FileFlags.NoCheckFileSize))._GetLines(); int numSockets = -1; int numTcp = -1; int numUdp = -1; foreach (string line in lines) { string[] tokens = line._Split(StringSplitOptions.RemoveEmptyEntries, " "); if (tokens.Length >= 3) { if (tokens[0]._IsSamei("sockets:")) { numSockets = tokens[2]._ToInt(); } if (tokens[0]._IsSamei("TCP:")) { numTcp = tokens[2]._ToInt(); } if (tokens[0]._IsSamei("UDP:")) { numUdp = tokens[2]._ToInt(); } } } if (numSockets >= 0 && numTcp >= 0 && numUdp >= 0) { ret.TryAdd($"Sockets", numSockets.ToString()); ret.TryAdd($"TCP", numTcp.ToString()); ret.TryAdd($"UDP", numUdp.ToString()); } } catch (Exception ex) { ex._Debug(); } } }