Last active
July 3, 2020 14:53
-
-
Save egorsmkv/9f692112624a7901af4f9a7c38184da6 to your computer and use it in GitHub Desktop.
This file contains 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
import sys | |
ETC_SYSCONFIG_NE = 'OPTIONS="--web.listen-address=:{port} --collector.textfile.directory ' \ | |
'/var/lib/node_exporter/textfile_collector --collector.systemd --collector.processes"' | |
ETC_SYSTEMD_NE = '''[Unit] | |
Description=Node Exporter | |
After=network.target | |
[Service] | |
Type=simple | |
User=node_exporter | |
EnvironmentFile=/etc/sysconfig/node_exporter | |
ExecStart=/usr/bin/node_exporter $OPTIONS | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target | |
''' | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print('Provide port, please') | |
exit(1) | |
port = sys.argv[1] | |
ETC_SYSCONFIG_NE = ETC_SYSCONFIG_NE.format(port=port) | |
with open('/etc/sysconfig/node_exporter', 'w') as h: | |
h.write(ETC_SYSCONFIG_NE) | |
with open('/etc/systemd/system/node_exporter.service', 'w') as h: | |
h.write(ETC_SYSTEMD_NE) | |
print('OK') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment