Originally published October 13, 2016 @ 12:49 am

NetData is a real-time system monitor great for visualizing performance data. Instances of netdata run independently on monitored systems. The results can be accessed remotely and grouped into a single dashboard view, making this tool highly scalable. With all the nice features, one thing netdata seems to be missing is some sort of a GUI drag-and-drop dashboard builder for the rest of us, non-Web-developer types. 

Here’s a quick way to install netdata on RHEL/CentOS:

cd ~/
yum -y install git gcc make autoconf automake uuid uuid-devel libuuid-devel zlib zlib-devel
#git clone https://github.com/firehol/netdata.git --depth=1
git clone https://github.com/netdata/netdata.git --depth=1
cd netdata
./netdata-installer.sh --dont-wait

netdata

Updating NetData

The process for updating netdatainstall via git is similar to the installation process.

cd ~/
/bin/rm -rf netdata
git clone https://github.com/firehol/netdata.git --depth=1
cd netdata
./netdata-installer.sh --dont-wait

Or a quick script, in case you need to update netdata automatically or on multiple servers.
#!/bin/bash

while getopts ":iu" OPTION; do
	case "${OPTION}" in
		i)
			action=1
			;;
		u)
			action=2
			;;
		\? ) echo "Unknown option: -$OPTARG" >&2; usage;;
        :  ) echo "Missing option argument for -$OPTARG" >&2; usage;;
        *  ) echo "Unimplemented option: -$OPTARG" >&2; usage;;
	esac
done

configure() {
	if [ -z ${action} ]
	then
		action=1
	fi
	
	uhome="$(grep ^root /etc/passwd | awk -F':' '{print $6}')"
	
	giturl="https://github.com/firehol/netdata.git"

	if [ $(curl -Lk -o /dev/null --silent --head --write-out '%{http_code}\n' "${giturl}") -ne 200 ]
	then
		echo "Can't get to ${giturl}. Exiting..."
		exit 7
	fi

	if [ $(id -g) -ne 0 ]
	then
		echo "Need to be root. Exiting..."
		exit 33
	fi
}

netdata_do() {
	if [ ${action} -eq 1 ]
	then
		if [ $(ps -ef | grep -c "/usr/sbin/[n]etdata") -ne 0 ]
			then
				echo "Netdata is already installed on $(hostname | awk -F'.' '{print $1}'). Exiting..."
				exit 22
		fi
		yum -y install git gcc make autoconf automake uuid uuid-devel libuuid-devel zlib zlib-devel
	fi
	
	if [ ${action} -eq 2 ]
	then
		if [ $(ps -ef | grep -c "/usr/sbin/[n]etdata") -lt 1 ]
			then
				echo "Netdata is not installed on $(hostname | awk -F'.' '{print $1}'). Exiting..."
				exit 22
		fi
		
		if [ $(which git >/dev/null 2>&1 ; echo $?) -ne 0 ]
		then
			echo "Git not found. Exiting..."
			exit 17
		fi
	fi
	
	cd "${uhome}"
	if [ -d "${uhome}/netdata" ]
	then
		/bin/rm -rf "${uhome}/netdata"
	fi
	
	git clone "${giturl}" --depth=1
	if [ -d "${uhome}/netdata" ]
	then
		cd "${uhome}/netdata"
		${uhome}/netdata/netdata-installer.sh --dont-wait
		else
			echo "Couldn't git it. Exiting..."
			exit 11
	fi
}

# RUNTIME

configure
netdata_do