Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save VityaSchel/f865f40a28cb0394a51798b3d6b66e2a to your computer and use it in GitHub Desktop.

Select an option

Save VityaSchel/f865f40a28cb0394a51798b3d6b66e2a to your computer and use it in GitHub Desktop.
Hetzner Robot Server Monitoring bulk mass adding
/*
This script automatically adds many domains to the hetzner sysmon via robot console. It is preconfigured to create an http check on port 443 with ssl enabled and no auth.
Instructions:
1. Go to https://robot.hetzner.com/server
2. Open your server
3. Open "monitoring" tab
4. Click on "configured systems" to reveal the sysmon form (it should show a plus sign, checks list, etc)
5. Open devtools in your browser -> go to console
6. Make sure to select "System-Monitor" iframe context! the script won't run in the top page context
7. Modify "yourdomains" to add whatever domains you want
8. Run the script and it should add all the domains while correctly replacing csrf tokens each time
Make sure to reload the page or click the "reload" button near your server's ip after that to see added entries
by hloth.dev
*/
const yourdomains = ["example.org"] // no protocol
(async () => {
let serverId = document.querySelector(
'form[action^="/robot/add_check/"]'
).action.split("/").filter(Boolean).at(-1);
let authenticityToken = document.querySelector(
'form[action^="/robot/add_check/"] input[name=authenticity_token]'
).value;
for (const address of yourdomains) {
authenticityToken = await fetch("https://sysmon.hetzner.com/robot/add_check/" + serverId, {
"headers": {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-CSRF-Token": document.querySelector("meta[name=csrf-token]").content,
},
"referrer": "https://sysmon.hetzner.com/robot/",
"body": new URLSearchParams({
"authenticity_token": authenticityToken,
"check_type_id": "3",
"check_params[user]": "",
"check_params[ssl]": "1",
"check_params[port]": "443",
"check_params[hostname]": address,
"check_params[path]": "/",
"check_params[pass]": ""
}).toString(),
"method": "POST"
}).then(res => res.text()).then(text => text.split('<input type=\\"hidden\\" name=\\"authenticity_token\\" value=\\"')[1].split('\\"')[0]);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment