Common Netdata Tasks

Update Netdata

/usr/libexec/netdata/netdata-updater.sh

Renaming a Node

You can change the node name in the Netdata web interface. Instead you can change hostname of the node directly on the node. Sometimes the node name doesn’t use the entire hostname, to override the hostname you can edit the /etc/netdata/netdata.conf and uncomment the hostname section and provide the correct hostname.

https://community.netdata.cloud/t/how-do-i-rename-a-node/1068

Moving a Node to a different War Room

https://community.netdata.cloud/t/how-do-i-move-a-node-to-another-war-room/1069

ZSH Sorting Associative Arrays

As I dive into ZSH more and more and start to put more hours into zshbop, I’m finding it harder to locate good ZSH documentation. I got stuck with an associative array being unsorted, why? I started to document all of the scripts and commands I’ve created and used the following format.

help_files[gcp]='GIT commit then push!'

This makes it super easy to explain all of the scripts and functions I have without having to place them all in one help file. I just use the associative array just above the function I’m writing.

The problem is that they’re unordered as I create them as needed. This results in the help file spewing the following out.

------------------------
-- Help Command Categories --
------------------------

  help php                       - PHP related commands
  help wordpress                 - WordPress related commands
  help ssh                       - SSH related commands
  help nginx                     - Nginx related commands
  help software                  - Software related commands
  help software_description      - -- To install, run software <cmd>
  help ubuntu                    - Ubuntu OS related commands
  help mail                      - All mail related commands
  help git                       - Git related commands
  help mysql                     - MySQL related commands
  help linux                     - Linux related commands
  help core                      - Core commands

It’s super ugly. So I started to look at trying to sort the associate array somehow. I first thought I could actually sort the array data, take out the data and then put it back in. But I thought that was too much work, and I wouldn’t understand the code as it was a copy and paste snippet I found on Stack Overflow.

I started to use ZSH substitution modifiers, which I had already been using for creating my command categories and other help verbiage. Here’s an example of listing all of the category commands.

help_files[nginx]='Nginx related commands'
help_files[php]='PHP related commands'
help_files[mail]='All mail related commands'
help_files[ubuntu]='Ubuntu OS related commands'

for key value in ${(kv)help_files}; do
        printf '%s\n' "  help ${(r:25:)key} - $value"
done

This works out well and the output is what you see in the previous code snippet. It’s just not sorted.

So I tried to work with ZSH substitutions but I couldn’t figure out how to return a key and values while also sorting. I couldn’t use (okv) this broke and I don’t know why. Still learning….

So instead I just grabbed the key, and sorted it. Then passed the kay to the array to print out the value. So easy.

        for key in ${(kon)help_zshbop}; do
                printf '%s\n' "  zshbop ${(r:25:)key} - help_zshbop[$key]"
        done

Sentry Self-Hosted Notes (Sentry.io)

Setting up Traefik with Sentry Self-Hosted

If you’re running Traefik on your docker host, then you’ll need to appropriate labels for Traefik. I’m using Portainer so I had to add the following to the docker-compose.yml under the nginx label

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.sentry-lmthosting.entrypoints=http"
      - "traefik.http.routers.sentry-lmthosting.rule=Host(`sentry.lmthosting.com`)"
      - "traefik.http.middlewares.sentry-lmthosting-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.sentry-lmthosting.middlewares=sentry-lmthosting-https-redirect"
      - "traefik.http.routers.sentry-lmthosting-secure.entrypoints=https"
      - "traefik.http.routers.sentry-lmthosting-secure.rule=Host(`sentry.lmthosting.com`)"
      - "traefik.http.routers.sentry-lmthosting-secure.tls=true"
      - "traefik.http.routers.sentry-lmthosting-secure.tls.certresolver=http"
      - "traefik.http.routers.sentry-lmthosting-secure.service=sentry-lmthosting"
      - "traefik.http.services.sentry-lmthosting.loadbalancer.server.port=80"
      - "traefik.docker.network=traefik-proxy"
    networks:
      - default
      - traefik-proxy

You will also need to add the appropriate networks at the bottom of the docker-compose.yml

networks:
  default:
    external: false
  traefik-proxy:
    external: true

Reset Sentry Self-Hosted Login

Easily found on https://forum.sentry.io/t/default-username-password/13246

docker-compose run --rm web createuser

Sending email from Synology via CLI/SSH on DSM 6

Doing a quick Google search for sending emails from Synology via CLI/SSH talks about the sendmail command. However, this doesn’t work on DSM6 unless you install a package that provides the command.

You can install one of the following packages to get the sendmail command

  • Synology Mail Server
  • Synology MailPlus Server

Both allow you to set up an SMTP mail relay such as Gmail, Postmark, or Sendgrid. But that means you need to install and run these services. This is not ideal if you’re not using all the features of these applications.

Instead, you can look at using ssmtp which is installed by default and will use the built-in SMTP configuration that is present in the Synology Control Panel -> Notification -> Email.

You will have to make sure you use the appropriate email headers such as From: when piping in data to be sent via email like so.

echo "From: [email protected]\nthis is a test" | ssmtp [email protected]

You could also look at using Sendgrid or Postmark with Bash. There are two scripts that would work for this.

  • SendGrid

MySQL 8 Increasing table_open_cache in Ubuntu 20

So if you’ve ever had to increase table_open_cache in Ubuntu 20, you’ll probably find that it doesn’t work the traditional way. Which is mind blowing! But I have a guess as to why. It’s to stop you from blowing up your server from too many open files!

I had updated /etc/mysql/mysql.conf.d/mysqld.cnf with the following

Plain Text

However, MySQL was only showing the value set at 4945

Plain Text

After some Google searching, I found this thread https://askubuntu.com/questions/1241013/cannot-increase-mysql-table-open-cache-in-ubuntu-20-04

Which pointed me to /lib/systemd/system/mysql.service and the line LimitNOFILE

Plain Text

Based on the information in the post, the LimitNOFILE is causing an automatic change to the “table_open_cache” variable. Modifying it to say 20000 will allow you to go with an 8000 table_open_cache. Copy and pasting into WordPress wouldn’t have done this post justice. So I screenshotted it.

After making the changes and restarting MySQL I got table_open_cache set to 8000

NetData Installation or Upgrade – Permission Denied Temp Directory not Executable

You might have run into the following issue at some point when trying to install or upgrade Netdata.

Shell

It’s usually related to your /tmp folder is mounted without execution permission and doesn’t allow execution of programs from this location. A simple work around is to set the $TMPDIR location in your shell to a place that is mount with execution permission. As an example

Shell

Granted you don’t have to use /root/tmp it can be any location.