Skip to content

Instantly share code, notes, and snippets.

@deepak7093
Last active July 29, 2019 17:01
Show Gist options
  • Save deepak7093/3476a3c1ba5c4f227a92a87f740217bb to your computer and use it in GitHub Desktop.
Save deepak7093/3476a3c1ba5c4f227a92a87f740217bb to your computer and use it in GitHub Desktop.

Revisions

  1. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -67,5 +67,6 @@ Run `# echo 0 > /etc/netdata/scripts/flag.txt`
    Run `# crontab -e`

    Add `* * * * * run-parts /etc/netdata/scripts/etc_host_check.sh`

    9. Now you must be able to gauge metrics under netdata statsd.

  2. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -61,8 +61,11 @@ else
    Run ` # touch /etc/netdata/scripts/flag.txt`

    Run `# echo 0 > /etc/netdata/scripts/flag.txt`

    8. Now set cronjob to run script every 1 min

    Run `# crontab -e`

    Add `* * * * * run-parts /etc/netdata/scripts/etc_host_check.sh`
    9. Now you must be able to gauge metrics under netdata statsd.

  3. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@

    2. Create config file `/etc/netdata/statsd.d/file.conf` with below content
    Run ` # mkdir -p /etc/netdata/statsd.d/`

    Run `# vi /etc/netdata/statsd.d/file.conf`
    ```
    [app]
    @@ -23,8 +24,11 @@ Run `# vi /etc/netdata/statsd.d/file.conf`
    ```

    3. Create dir to store user scripts

    Run `# mkdir -p /etc/netdata/scripts/`

    4. Run `# vi /etc/netdata/scripts/etc_host_check.sh`

    Add content
    ```
    #!/bin/bash
    @@ -53,7 +57,9 @@ else
    5. Change `localhost` to your `netdata server ip` in above script.
    6. Change <GIT_URL> to your original conf file.
    7. Run `# mkdir -p /etc/netdata/scripts/`

    Run ` # touch /etc/netdata/scripts/flag.txt`

    Run `# echo 0 > /etc/netdata/scripts/flag.txt`
    8. Now set cronjob to run script every 1 min
    Run `# crontab -e`
  4. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -53,9 +53,10 @@ else
    5. Change `localhost` to your `netdata server ip` in above script.
    6. Change <GIT_URL> to your original conf file.
    7. Run `# mkdir -p /etc/netdata/scripts/`
    ` # touch /etc/netdata/scripts/flag.txt`
    `# echo 0 > /etc/netdata/scripts/flag.txt`
    Run ` # touch /etc/netdata/scripts/flag.txt`
    Run `# echo 0 > /etc/netdata/scripts/flag.txt`
    8. Now set cronjob to run script every 1 min
    `# crontab -e`
    `* * * * * run-parts /etc/netdata/scripts/etc_host_check.sh`
    Run `# crontab -e`
    Add `* * * * * run-parts /etc/netdata/scripts/etc_host_check.sh`
    9. Now you must be able to gauge metrics under netdata statsd.

  5. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 40 additions and 4 deletions.
    44 changes: 40 additions & 4 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    # Netdata file integrity check with statsd
    # Netdata host file integrity check with statsd

    1. Check statsd plugin status
    Statsd is enabled by default, if not enable it inside, `/etc/netdata/netdata.conf` under [statsd] section. Default port is 8125.

    2. Create config file `/etc/netdata/statsd.d/file.conf` with below content
    mkdir -p /etc/netdata/statsd.d/
    vi /etc/netdata/statsd.d/file.conf
    Run ` # mkdir -p /etc/netdata/statsd.d/`
    Run `# vi /etc/netdata/statsd.d/file.conf`
    ```
    [app]
    name = filecheckapp
    @@ -22,4 +22,40 @@ vi /etc/netdata/statsd.d/file.conf
    dimension = resolve 'resolve me' last 1 1
    ```

    3.
    3. Create dir to store user scripts
    Run `# mkdir -p /etc/netdata/scripts/`
    4. Run `# vi /etc/netdata/scripts/etc_host_check.sh`
    Add content
    ```
    #!/bin/bash
    rm original_host
    wget <GIT_URL> -O original_host
    base_md5=`md5sum original_host | cut -d' ' -f1`
    server_md5=`md5sum /etc/hosts | cut -d' ' -f1`
    flag=`cat /etc/netdata/scripts/flag.txt`
    if [[ $base_md5 == $server_md5 ]] && [[ $flag == 0 ]];
    then
    echo "No change Required"
    elif [[ $base_md5 == $server_md5 ]] && [[ $flag == 1 ]];
    then
    echo "OK : Host has valid /etc/hosts conf !!!"
    echo 0 > /etc/netdata/scripts/flag.txt; echo "hosts:-1|g" | nc -w 1 -u localhost 8125;
    elif [[ $base_md5 != $server_md5 ]] && [[ $flag == 0 ]];
    then
    echo 1 > /etc/netdata/scripts/flag.txt;
    echo "WARNING: /etc/hosts file got changed."
    echo "hosts:+1|g" | nc -w 1 -u localhost 8125;
    else
    echo "Do nothig.."
    ```
    5. Change `localhost` to your `netdata server ip` in above script.
    6. Change <GIT_URL> to your original conf file.
    7. Run `# mkdir -p /etc/netdata/scripts/`
    ` # touch /etc/netdata/scripts/flag.txt`
    `# echo 0 > /etc/netdata/scripts/flag.txt`
    8. Now set cronjob to run script every 1 min
    `# crontab -e`
    `* * * * * run-parts /etc/netdata/scripts/etc_host_check.sh`

  6. deepak7093 revised this gist Jul 29, 2019. 1 changed file with 23 additions and 2 deletions.
    25 changes: 23 additions & 2 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,25 @@
    # Netdata file integrity check with statsd

    1. Check statsd plugin status
    Statsd is enabled by default, if not enable it inside, `/etc/netdata/netdata.conf`. Default port is 8125.
    Statsd is enabled by default, if not enable it inside, `/etc/netdata/netdata.conf` under [statsd] section. Default port is 8125.

    2.
    2. Create config file `/etc/netdata/statsd.d/file.conf` with below content
    mkdir -p /etc/netdata/statsd.d/
    vi /etc/netdata/statsd.d/file.conf
    ```
    [app]
    name = filecheckapp
    metrics = hosts resolve
    private charts = yes
    [file_chart1]
    title = Files Integrity Check
    family = file_family
    context = filecheckapp.filecheck
    units = filecheck
    type = area
    dimension = hosts 'hosts me' last 1 1
    dimension = resolve 'resolve me' last 1 1
    ```

    3.
  7. deepak7093 created this gist Jul 29, 2019.
    4 changes: 4 additions & 0 deletions netdata_file_integrity_checker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    1. Check statsd plugin status
    Statsd is enabled by default, if not enable it inside, `/etc/netdata/netdata.conf`. Default port is 8125.

    2.