Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DeveloperMos/be7c940540169d3deb2afb387566e6ef to your computer and use it in GitHub Desktop.
Save DeveloperMos/be7c940540169d3deb2afb387566e6ef to your computer and use it in GitHub Desktop.
mongodb_exporter systemd setup
#!/bin/bash
# create mongodb_exporter.service
cat > /etc/systemd/system/mongodb_exporter.service <<END
[Unit]
Description=Prometheus MongoDB Exporter
Documentation=https://github.com/percona/mongodb_exporter
After=network.target
[Service]
EnvironmentFile=/etc/default/mongodb_exporter
ExecStart=/usr/bin/mongodb_exporter $OPTIONS
Type=simple
PIDFile=/var/run/mongodb_exporter.pid
Restart=on-failure
SyslogIdentifier=mongodb_exporter
[Install]
WantedBy=default.target
Restart=always
END
chmod 644 /etc/systemd/system/mongodb_exporter.service
echo "============= starting mongodb_exporter setup ============"
cd /tmp
curl -Ls -o ./mongodb_exporter.tar.gz https://github.com/percona/mongodb_exporter/releases/download/v0.40.0/mongodb_exporter-0.40.0.darwin-amd64.tar.gz
tar xvzpf mongodb_exporter.tar.gz
chmod 755 ./mongodb_exporter
mv ./mongodb_exporter /usr/local/bin/mongodb_exporter
systemctl daemon-reload
systemctl enable mongodb_exporter.service
systemctl start mongodb_exporter.service
echo "============= done ===================================="
@DeveloperMos
Copy link
Author

in /etc/default/mongodb_exporter

OPTIONS="--mongodb.uri=mongodb://mongodb_exporter:[email protected]:27017/admin?ssl=false --collect-all --compatible-mode --web.listen-address=127.0.0.1:9001"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment