From 79b9f029c76a2692a45e90286de6fecaef5366d1 Mon Sep 17 00:00:00 2001 From: copystring Date: Sat, 30 Sep 2023 14:45:00 +0200 Subject: [PATCH 1/3] Fix https://github.com/Scrounger/ioBroker.linux-control/issues/46 --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index cada2c9..c1cb942 100644 --- a/main.js +++ b/main.js @@ -494,7 +494,7 @@ class LinuxControl extends utils.Adapter { // @ts-ignore if (this.config.whitelist && this.config.whitelist["services"] && this.config.whitelist["services"].length > 0 && !this.config.blacklistDatapoints[host.name].includes('services.all')) { if (connection) { - let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); + let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | grep -v '^*' | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); if (response) { response = response.replace(/\t/g, ',') From 4d92220c86c486f04214223ec9d614415280a37d Mon Sep 17 00:00:00 2001 From: copystring Date: Sat, 30 Sep 2023 14:59:07 +0200 Subject: [PATCH 2/3] Further improve filter for services --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index c1cb942..e115376 100644 --- a/main.js +++ b/main.js @@ -494,7 +494,7 @@ class LinuxControl extends utils.Adapter { // @ts-ignore if (this.config.whitelist && this.config.whitelist["services"] && this.config.whitelist["services"].length > 0 && !this.config.blacklistDatapoints[host.name].includes('services.all')) { if (connection) { - let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | grep -v '^*' | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); + let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | sed -E 's/^[^a-zA-Z0-9]*([a-zA-Z0-9-]+\.service)/\1/' | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); if (response) { response = response.replace(/\t/g, ',') From ff1df0d75b25fa98976ca398c34608a6bb05b27c Mon Sep 17 00:00:00 2001 From: copystring Date: Sat, 30 Sep 2023 15:03:53 +0200 Subject: [PATCH 3/3] Fix syntax error --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index e115376..0602d02 100644 --- a/main.js +++ b/main.js @@ -494,7 +494,7 @@ class LinuxControl extends utils.Adapter { // @ts-ignore if (this.config.whitelist && this.config.whitelist["services"] && this.config.whitelist["services"].length > 0 && !this.config.blacklistDatapoints[host.name].includes('services.all')) { if (connection) { - let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | sed -E 's/^[^a-zA-Z0-9]*([a-zA-Z0-9-]+\.service)/\1/' | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); + let response = await this.sendCommand(connection, host, `systemctl list-units --type service --all --no-legend | sed -E 's/^[^a-zA-Z0-9]*([a-zA-Z0-9-]+\\.service)/\\1/' | awk '{out=""; for(i=5;i<=NF;i++){out=out" "$i}; print $1","$2","$3","$4","out}'${serviceName ? ` | grep ${serviceName}` : ''}`, logPrefix, undefined, false); if (response) { response = response.replace(/\t/g, ',')