Last active
March 20, 2024 17:53
-
-
Save rbudiharso/3ca2bc41d73a0e9e3511805b8708c345 to your computer and use it in GitHub Desktop.
mongodb_exporter systemd setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# create mongodb_exporter.service | |
cat > /etc/systemd/system/mongodb_exporter.service <<END | |
[Unit] | |
Description=mongodb exporter service | |
After=network.target | |
[Service] | |
ExecStart=/usr/local/bin/mongodb_exporter --collect.database --collect.collection --collect.topmetrics --collect.indexusage --mongodb.uri=mongodb+srv://<username>:<password>@<host:port>/?ssl=false | |
Type=simple | |
PIDFile=/var/run/mongodb_exporter.pid | |
Restart=on-failure | |
[Install] | |
WantedBy=default.target | |
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.11.1/mongodb_exporter-0.11.1.linux-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 ====================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment