Skip to content

Commit

Permalink
Issues, dublicated IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Aug 22, 2024
1 parent 66fb038 commit 864f605
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 105 deletions.
1 change: 1 addition & 0 deletions Protest/Front/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Issues extends List {
};

static CATEGORY_ICON = {
"Database" : "url(mono/database.svg)",
"Directory" : "url(mono/directory.svg)",
"Password" : "url(mono/lock.svg)",
"Printer component" : "url(mono/printer.svg)",
Expand Down
12 changes: 6 additions & 6 deletions Protest/Tools/LiveStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ public static async void DeviceStats(HttpListenerContext ctx) {
if (OperatingSystem.IsWindows()
&& _os?.value?.Contains("windows", StringComparison.OrdinalIgnoreCase) == true
&& firstAlive is not null && firstReply.Status == IPStatus.Success) {
WmiQuery(ws, mutex, entry.filename, firstAlive, ref wmiHostname);
WmiQuery(ws, mutex, firstAlive, ref wmiHostname);
}

if (firstAlive is not null
&& firstReply.Status == IPStatus.Success
&& entry.attributes.TryGetValue("type", out Database.Attribute _type)
&& entry.attributes.TryGetValue("snmp profile", out Database.Attribute _snmpProfile)) {
SnmpQuery(ws, mutex, entry.filename, firstAlive, _type?.value.ToLower(), _snmpProfile.value);
SnmpQuery(ws, mutex, firstAlive, _type?.value.ToLower(), _snmpProfile.value);
}

if (OperatingSystem.IsWindows() && _hostname?.value?.Length > 0) {
Expand Down Expand Up @@ -302,7 +302,7 @@ public static async void DeviceStats(HttpListenerContext ctx) {
}

[SupportedOSPlatform("windows")]
private static void WmiQuery(WebSocket ws, object mutex, string file, string firstAlive, ref string wmiHostname) {
private static void WmiQuery(WebSocket ws, object mutex, string firstAlive, ref string wmiHostname) {
try {
ManagementScope scope = Protocols.Wmi.Scope(firstAlive, 3_000);
if (scope is not null && scope.IsConnected) {
Expand All @@ -324,7 +324,7 @@ private static void WmiQuery(WebSocket ws, object mutex, string file, string fir

WsWriteText(ws, $"{{\"drive\":\"{caption}\",\"total\":{nSize},\"used\":{nSize - nFree},\"path\":\"{Data.EscapeJsonText($"\\\\{firstAlive}\\{caption.Replace(":", String.Empty)}$")}\",\"source\":\"WMI\"}}", mutex);

if (Issues.CheckDiskCapacity(file, firstAlive, percent, caption, out Issues.Issue? diskIssue)) {
if (Issues.CheckDiskCapacity(null, firstAlive, percent, caption, out Issues.Issue? diskIssue)) {
WsWriteText(ws, diskIssue?.ToLiveStatsJsonBytes(), mutex);
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ private static void WmiQuery(WebSocket ws, object mutex, string file, string fir
catch { }
}

private static void SnmpQuery(WebSocket ws, object mutex, string file, string firstAlive, string type, string snmpProfileGuid) {
private static void SnmpQuery(WebSocket ws, object mutex, string firstAlive, string type, string snmpProfileGuid) {
if (!SnmpProfiles.FromGuid(snmpProfileGuid, out SnmpProfiles.Profile profile)) {
return;
}
Expand Down Expand Up @@ -412,7 +412,7 @@ private static void SnmpQuery(WebSocket ws, object mutex, string file, string fi
WsWriteText(ws, $"{{\"info\":\"Total jobs: {Data.EscapeJsonText(snmpPrinterJobs)}\",\"source\":\"SNMP\"}}", mutex);
}

if (Issues.CheckPrinterComponent(file, ipAddress, profile, out Issues.Issue[] issues)) {
if (Issues.CheckPrinterComponent(null, ipAddress, profile, out Issues.Issue[] issues) && issues is not null) {
for (int i = 0; i < issues.Length; i++) {
WsWriteText(ws, issues[i].ToLiveStatsJsonBytes(), mutex);
}
Expand Down
Loading

0 comments on commit 864f605

Please sign in to comment.