Uninstall the agent

Remove the agent with the public uninstall script or the on-host helper. Server deletion behaves differently on v0.1.0 and v0.2.2.

Updated Nov 7, 2026

On this page

Manual uninstall#

Warning: These commands remove the CloudStats agent, its systemd units, configuration under /etc/cloudstats, and local buffered metrics under /var/lib/cloudstats. They do not delete the server or its metric history in your CloudStats account. Delete the server in the CloudStats website if you want it removed there.

Public one-liner (no token in the URL):

sh
curl -fsSL https://install.cloudstats.me/uninstall.sh | sudo sh

If the helper is already on the machine:

sh
sudo /usr/local/lib/cloudstats/uninstall.sh

Both run the same static script. It requires root, makes no network calls, and ignores extra arguments except informational --reason. It is idempotent. It:

  1. Disables and stops cloudstats-agent.service, cloudstats-agent-uninstall.path, and cloudstats-agent-update.path (errors ignored)
  2. Removes /usr/local/bin/cloudstats-agent, .new, and .prev
  3. Removes the systemd unit files
  4. Removes /usr/local/lib/cloudstats, /etc/cloudstats, and /var/lib/cloudstats
  5. Reloads systemd and prints a short summary

GET /uninstall.sh is public and cacheable. The current installer also embeds this helper on the host.

v0.1.0 versus v0.2.2#

v0.1.0v0.2.2 (current installer)
/usr/local/lib/cloudstats/uninstall.shNot installedInstalled
https://install.cloudstats.me/uninstall.shNot served by that release’s installerServed
systemd uninstall path unitNot installedInstalled (PathExists=/var/lib/cloudstats/server-deleted)
RestartPreventExitStatus=87Not in the v0.1.0 unitPresent
Manual removal if the helper is missingStop and disable cloudstats-agent, then delete /usr/local/bin/cloudstats-agent, /etc/cloudstats, /var/lib/cloudstats, and /etc/systemd/system/cloudstats-agent.service, then systemctl daemon-reloadPrefer the helper above

You can still fetch today’s uninstall.sh from https://install.cloudstats.me/uninstall.sh onto a v0.1.0 host. That current script removes the paths listed above; v0.1.0 never created the extra unit names, and the script ignores missing units.

When you delete the server in CloudStats#

Deleting the server in the website revokes the agent credential. Ingest then returns HTTP 401 with code server_deleted for that credential.

v0.2.2#

The agent does not uninstall on a single server_deleted response.

After at least 5 authenticated server_deleted responses spanning at least 15 minutes, with no successful (accepted) send in between, the agent:

  1. Logs an error with server_id
  2. Deletes /var/lib/cloudstats/wal
  3. Writes /var/lib/cloudstats/server-deleted
  4. Exits 87 so systemd does not restart it

The uninstall path unit then runs uninstall.sh --reason server-deleted and removes the files unless you opted out.

A successful accepted batch resets the local evidence. Network errors, 5xx, 429, and a plain 401 without code=server_deleted neither count nor reset that evidence.

If /var/lib/cloudstats/server-deleted already exists at startup, the agent logs it and exits 87 immediately.

v0.1.0#

v0.1.0 does not recognize server_deleted. A 401 is treated as a rejected credential. The agent keeps running, retries with backoff, and does not write server-deleted or uninstall itself. Remove it with the manual steps above, or install v0.2.2 and then uninstall.

Opt out of uninstall-on-delete#

Create this file as root:

text
/etc/cloudstats/no-self-uninstall

If that file exists, a oneshot with --reason server-deleted only stops and disables the agent and keeps the files. The SSH / curl one-liner still removes everything.