diff --git a/h3exporter/README b/h3exporter/README index 6555667..fdc9f6d 100644 --- a/h3exporter/README +++ b/h3exporter/README @@ -1,31 +1,12 @@ Python3 script to report WA hadoop3 key stats -CURRENTLY, BELOW systemctl SETUP NOT WORK - ISSUE WITH D-BUS AND monitor USER +To set up as a systemctl daemon, as the root user: +* Copy h3exporter service file to systemctl directory + * cp h3exporter.service /usr/lib/systemd/system/ -To set up as a systemctl daemon: -* Ensure user systemd directory exists - * mkdir -p ~/.config/systemd/user - -* Create service file as ~/.config/systemd/user/h3exporter.service, chmod 644 - -``` -[Unit] -Description=h3exporter systemctl configuration -After=network.target - -[Service] -Type=simple -ExecStart=/home/monitor/github/ukwa-monitor/h3exporter/run_h3exporter.sh -Restart=always -RestartSec=30 - -[Install] -WantedBy=default.target -``` - -* Reload user systemctl - * systemctl --user daemon-reload +* Reload systemctl + * systemctl daemon-reload * Enable and start h3exporter service - * systemctl --user enable --now h3exporter + * systemctl enable --now h3exporter diff --git a/h3exporter/h3exporter.py b/h3exporter/h3exporter.py index c28a36e..6cc161b 100755 --- a/h3exporter/h3exporter.py +++ b/h3exporter/h3exporter.py @@ -15,7 +15,7 @@ # globals logger = logging.getLogger(__name__) SCRIPTNAME = os.path.splitext(os.path.basename(__main__.__file__))[0] -CONFIG = 'config/settings' +CONFIG = '/home/monitor/github/ukwa-monitor/h3exporter/config/settings' # script -------------------- @@ -44,10 +44,10 @@ def script(): or ( underReplicated != prevUnderReplicated): h3stats.send_hadoop_stats(settings, usedPercent, deadNodes, underReplicated) - # update previous values - prevUsedPercent = usedPercent - prevDeadNodes = deadNodes - prevUnderReplicated = underReplicated + # update previous values + prevUsedPercent = usedPercent + prevDeadNodes = deadNodes + prevUnderReplicated = underReplicated # sleep until next time to send hadoop3 stats time.sleep(int(settings['sleep'])) diff --git a/h3exporter/h3exporter.service b/h3exporter/h3exporter.service new file mode 100644 index 0000000..0da058d --- /dev/null +++ b/h3exporter/h3exporter.service @@ -0,0 +1,14 @@ +[Unit] +Description=h3exporter systemctl configuration +After=network.target + +[Service] +Type=forking +User=monitor +Group=monitor +ExecStart=/home/monitor/github/ukwa-monitor/h3exporter/run_h3exporter.sh +Restart=always +RestartSec=30 + +[Install] +WantedBy=default.target