What is Netdata?
Real-time performance monitoring, done right!
Edit 04/13/2016:
Edit 04/20/16:
Damn, I let a cat out the bag. I am also writing software to create BluRay movies from the terminal. Ignore that... I am at best 2/3 the way through it.
Like I said I did not write it: Netdata homepage
Funny, you can 100% monitor their server using this tool. I can not only as the vid shows above monitor my main rig the "JackHammer", I can monitor other boxes in my house in a centralized and well visualized way. Good thing I had the raid box turned off, or would have been a 15 minute video Has 0 impact on your rig minus a small amount of memory. It is so smooth, makes me question the installation of it on even Lite based O/S's. Let me contemplate that, feel free to chime in.
Debianization:
I have had this app running as can be seen in a production environment (Ultimate Edition 4.2.4), I have also installed it in another upcoming LTS (Long Term Supported) O/S Ultimate Edition 5.0 Lite and was equally as smooth. I do understand a lite machine is not going to have 8 processors & will do regression testing. I do have a "Craptop" here. My media boxes are not something to test resource usage with a 8 core downstairs and a Quad upstairs, nothing really "Lite" about them.
Recreation of the wheel is not in my vocabulary, I picked apart uecorebuilder a subprogram from tmosb and made it comparable in deliberation for building that package. I bet I have close to 100 processor cores in house. Nothing above dual core when I go down that road. The current resolve? I can assure you we have a ways to go (currently you will have to build it on your rig first) then you can build the package:
- Code: Select all
#!/bin/bash
# ==============================================================================
# title :TheeMahn's Netdata builder
# description :Netdata - Real-time performance monitoring, done right!
# author :theemahn <[email protected]>
# date :04/13/2016
# version :1.0.0
# usage :netbuilder.sh --help
# notes :See change-log below for further information.
# ==============================================================================
# Change-log:
# 1.0.0: Initial public release
# wrote init.d start-up script, postinst & prerm scripting. We now
# have a working deb almost across the board. I am sorry, I work
# multiple jobs. It does take it's toll on a fella.
#
# Built a repository for it this morning before I rolled off to
# work. I will do final testing today. I took a vacation day
# tomorrow, only to work some more ;)
#
# ==============================================================================
APPNAME="Netdata: Package Builder"
PROGNAME="Netdatabuilder"
VERSION="1.0.0"
BUILDDATE="04/13/2016"
WEBSITE="os-builder.com"
AUTHOR="TheeMahn"
EMAIL="<"$AUTHOR"@"$WEBSITE">"
# Retrieve number of lines & columns the screen supports.
LINEZ=$(tput lines)
COLUMNZ=$(tput cols)
SPLIT=0
# check to see if notify is installed & if sound is supported.
NOTIFY=$(which notify-send)
SOUND=$(which canberra-gtk-play)
# Declare integer to span eye-candy routine
declare -i RR
RR=0
declare -i TT
TT=0
declare -i CALC
CALC=0
declare -i TOTALOS
TOTALOS=0
# Declare Integer for root user detection - Set as initial normal user.
declare -i TRUEROOT
TRUEROOT=1000 #Set as 1000 initially, try an cause root access to fail.
IUSER=${SUDO_USER:-$USER}
IHOME="/home/$IUSER"
TRUEROOT=$(id -u)
# set colors so errors etc. stand out.
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
txtrst='\e[0m' # Text Reset
# Get Directory executed in.
CURRENT=$PWD
filename="netdata"
extension="${filename##*.}"
filename="${filename%.*}"
PACKAGE="$filename-$2_all"
declare -a RECURSIVE=("/etc/netdata/" "/usr/share/netdata/web/" "/usr/libexec/netdata/");
declare -a DESTINATION=("/etc/" "/usr/share/netdata/" "/usr/libexec/");
declare -a ARGUMENTS=();
declare -a ARGLENGTH=();
# Pull info we will use to compare against later
IUSER=${SUDO_USER:-$USER}
IHOME="/home/$IUSER"
# Debugging function to monitor passed arguments.
CommandLineInterpreter () {
#echo -e "${bldgrn}Number of switches passed: $#"
for var in "$@"
do
array_counter=$(($array_counter + 1))
#echo "Switch $array_counter: $var"
done
}
# Download various packages showing progression...
Download() {
local url=$1
echo -n " "
wget --progress=dot $url 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
echo -ne "\b\b\b\b"
Encapsulate "Done."
}
# Dump data to the screen in pretty columns.
Columnize () {
# Columnize is an internally called function exclusively.
# EXAMPLE
# -t to shove through the column titles we will count the number of switches and
# calculate spacing eventually.
if [[ $1 == '-t' ]]; then
#echo -e "${bldgrn}Number of switches passed: $#"
for ARG in "$@"
do
array_counter=$(($array_counter + 1))
if [[ $array_counter -gt 2 ]]; then
#echo "Switch $array_counter: $ARG"
ARGUMENTS[$array_counter]=$ARG
tLen=${#ARGUMENTS[$array_counter]}
if [[ $tLen -ge $WIDEST ]]; then
WIDEST=$tLen
fi
#echo "Length of ${ARGUMENTS[$array_counter]} is $tLen"
fi
#echo "The widest passed varible is $WIDEST"
done
else
#echo -e "${bldgrn}Number of switches passed: $#"
for ARG in "$@"
do
array_counter=$(($array_counter + 1))
if [[ $array_counter -gt 1 ]]; then
#echo "Switch $array_counter: $ARG"
ARGUMENTS[$array_counter]=$ARG
tLen=${#ARGUMENTS[$array_counter]}
if [[ $tLen -ge $WIDEST ]]; then
WIDEST=$tLen
fi
#echo "Length of ${ARGUMENTS[$array_counter]} is $tLen"
fi
#echo "The widest passed varible is $WIDEST"
done
fi
#echo "#: $# VARS: $*"
LONGESTLENGTH=${#2}
#echo "Length of $2 is $LONGESTLENGTH"
#echo $COLUMNZ
MAINS=$(echo "scale=2; $COLUMNZ-30" | bc)
MAINS=${MAINS%.*}
#echo $MAINS
MAINS=$(expr $MAINS - 2)
MAINS=$(expr $MAINS / 4)
#echo $MAINS
if [[ $1 = '-t' ]]; then
#"#" "DEV" "VENDOR" "LABEL" "TYPE" "SIZE"
printf "%-0s %-16s %-7s %-16s %-7s %-3s %-13s %-3s %-16s %-1s\n" "▒" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
else
#MAINS=$(expr $MAINS / 2)
printf "%-0s %-16s %-7s %-16s %-7s %-3s %-13s %-3s %-16s %-1s\n" "▒" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
fi
}
# Usage: Eye Candy "Message"
EyeCandy() {
# Verify a message has been sent to this function otherwise do squat.
# Example: Eye Candy ('Repostorm $REPOVERSION is entering extraction mode.')
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒ Repostorm 1.7.7 is entering extraction mode. ▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
STP="$1"
if [[ $STP ]]; then
STRLEN=${#STP}
STRLEN=$(expr $STRLEN + 3)
GREPPED=$(echo $STP | grep -E '\e')
if [[ $GREPPED ]]; then
STRLEN=$(expr $STRLEN - 13)
fi
RR=0; while [ $RR -le $STRLEN ]; do echo -n "▒"; RR=RR+1; done; echo;
echo -e "▒ "$STP" ▒"
RR=0; while [ $RR -le $STRLEN ]; do echo -n "▒"; RR=RR+1; done; echo;
fi
}
Encapsulate() {
# Verify a message has been sent to this function otherwise do squat.
# Example: Encapsulate ('Repostorm $REPOVERSION is entering extraction mode.')
# ▒ Repostorm 1.7.7 is entering extraction mode. ▒
STP="$1"
if [[ $STP ]]; then
STRLEN=${#STP}
STRLEN=$(expr $STRLEN + 3)
DISTANCE=$(expr $COLUMNZ - $STRLEN)
GREPPED=$(echo $STP | grep -E '\e')
if [[ $GREPPED ]]; then
STRLEN=$(expr $STRLEN - 13)
fi
echo -en "▒ "$STP
RR=0; while [ $RR -lt $DISTANCE ]; do echo -n " "; RR=RR+1; done; echo "▒";
fi
}
# Function for outputting to X-11 screen a notification of completion and playing sound.
# The sound file is from the "Optional" ultimate-edition-sound-theme
Notification () {
# Is X11 running?
X=$( pidof X )
# Does the user have the optional Ultimate Edition Sound scheme installed?
if [[ -f "/usr/share/sounds/Ultimate Edition Sound Scheme/stereo/itisdone.wav" ]]; then
WAVE=1
fi
# Is the user in an X11 GUI environment and have notification OSD installed?
if [[ $X && $NOTIFY ]]; then
a=$(notify-send "$APPNAME" "$1" -i /usr/share/ultimate_edition/logo.png -t 5000)
fi
# Does the user have pre-requisites? If so, break out the Cylon voice.
if [[ $SOUND && $WAVE ]]; then
a=$(canberra-gtk-play -i itisdone 2>/dev/null)
fi
# Display message in terminal unconditionally
Encapsulate "$1"
}
# Draws a bar across the screen based on screen size detected (columnz)
FullBar() {
RR=1; while [ $RR -le $COLUMNZ ]; do echo -n "▒"; RR=RR+1; done; echo;
}
# Center data passed to function on screen
Center () {
STP=$1
if [[ $STP ]]; then
STRLEN=${#STP}
CENTER=$(expr $STRLEN / 2 )
#CENTER=CENTER-1
TCENTER=$(expr $COLUMNZ / 2 )
#TCENTER=TCENTER-1
DISTANCE=$(expr $TCENTER - $CENTER)
DISTANCE=$(expr $DISTANCE - 2)
echo -en "${txtrst}"
RR=0; while [ $RR -lt $DISTANCE ]; do echo -n "▒"; RR=RR+1; done;
echo -en "${bldgrn} $STP ${txtrst}"
TT=0; while [ $TT -lt $DISTANCE ]; do echo -n "▒"; TT=TT+1; done;
CALC=$(expr $RR + $TT + $STRLEN + 2)
if [[ $CALC -lt $COLUMNZ ]]; then
ZZZ=0; while [ $CALC -lt $COLUMNZ ]; do echo -n "▒"; CALC=CALC+1; done; echo;
fi
# Dubugging:
fi # echo "STRING LEN: $STRLEN CENTER: $CENTER TOTAL CNTER: $TCENTER RR=$RR TT=$TT COLUMNZ: $COLUMNZ CALC: $CALC DISTANCE: $DISTANCE"
}
Error () {
echo -en "${bldred}"
FullBar
Center "$1"
echo -en "${bldred}"
FullBar
echo -en "${txtrst}"
}
ControlFile(){
Encapsulate "Creating Debian Control file."
echo 'Package: netdata' > "$PACKAGE/DEBIAN/control"
echo 'Priority: optional' >> "$PACKAGE/DEBIAN/control"
echo 'Section: gnome' >> "$PACKAGE/DEBIAN/control"
echo 'Architecture: all' >> "$PACKAGE/DEBIAN/control"
echo "Version: $1" >> "$PACKAGE/DEBIAN/control"
echo "Installed-Size: 144" >> "$PACKAGE/DEBIAN/control"
echo "Homepage: https://github.com/firehol/netdata/wiki" >> "$PACKAGE/DEBIAN/control"
echo "Maintainer: Ultimate Edition Team <[email protected]>" >> "$PACKAGE/DEBIAN/control"
echo "Description: System Monitor." >> "$PACKAGE/DEBIAN/control"
echo " Real-time performance monitoring, done right!" >> "$PACKAGE/DEBIAN/control"
if [[ -f "$PACKAGE/DEBIAN/control" ]]; then
Encapsulate "Success."
else
Error "Failure! Permission rights issue(s)?"
exit 1;
fi
}
DebianStructure(){
# DEBIAN STRUCTURE
Encapsulate "Creating Debian Structure."
mkdir -p "$PACKAGE/usr/share/doc/$PACKAGE/"
mkdir -p "$PACKAGE/usr/sbin/"
mkdir -p "$PACKAGE/etc/netdata/"
mkdir -p "$PACKAGE/usr/share/netdata/web/"
mkdir -p "$PACKAGE/usr/libexec/netdata/"
mkdir -p "$PACKAGE/DEBIAN/"
mkdir -p "$PACKAGE/var/cache/netdata/"
mkdir -p "$PACKAGE/var/log/netdata/"
mkdir -p "$PACKAGE/etc/init.d/"
if [[ -d "$PACKAGE" ]]; then
Encapsulate "Success."
else
Error "Failure: unable to create Debian Structure. Permission issues?"
exit 1;
fi
}
Populate(){
ARRAY=0
for EACH in ${RECURSIVE[@]};
do
Encapsulate "Processing: $EACH to $PACKAGE/${DESTINATION[$ARRAY]}"
cp -r "$EACH" "$PACKAGE/${DESTINATION[$ARRAY]}"
((ARRAY ++))
done
Encapsulate "Processing executable: netdata"
cp "/usr/sbin/netdata" "$PACKAGE/usr/sbin/"
if [[ -f "$PACKAGE/usr/sbin/netdata" ]]; then
Encapsulate "Success."
else
Error "Failure: unable to create Debian Structure. Permission issues?"
exit 1;
fi
}
Services() {
echo '#!/bin/bash
### BEGIN INIT INFO
# Provides: Netdata_service
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Real-time performance monitoring, done right!
### END INIT INFO
SCRIPT="netdata"
RUNAS="netdata"
# Detect user runspace
if [ -d "/run" ]; then
RUN="/run"
elif [ -d "/var/run/" ]; then
RUN="/var/run"
fi
if [ "$RUN" ]; then
PIDFILE=/var/run/netdata.pid
LOGFILE=/var/log/netdata.log
fi
start() {
if [ -f "$RUN/$PIDFILE" ]; then
PROCID=$(cat "$RUN/$PIDFILE")
if [ -f "$RUN/$PIDFILE" ] && kill -0 "$PROCID"; then
echo "Service already running" >&2
return 1
fi
fi
echo "Starting service " >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo "Service started" >&2
}
stop() {
if [ -f "$RUN/$PIDFILE" ]; then
PROCID=$(cat "$RUN/$PIDFILE")
kill -0 "$PROCID"
echo "Service not running" >&2
return 1
fi
echo "Stopping service " >&2
kill -15 "$PROCID" && rm -f "$PIDFILE"
echo "Service stopped" >&2
}
uninstall() {
echo -n "Are you really sure you want to uninstall this service? This action cannot be undone. [yes|No] "
local SURE
read -r SURE
if [ "$SURE" = "yes" ]; then
stop
rm -f "$PIDFILE"
echo "Notice: log file is not be removed: "$LOGFILE" >&2
update-rc.d -f netdata remove
rm -fv "$0"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
uninstall)
uninstall
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac' > "$PACKAGE/etc/init.d/netdata"
}
BuildPackage() {
Encapsulate "Populating documentation for $PACKAGE."
cp /usr/share/ultimate_edition/doc/copyright $PACKAGE/usr/share/doc/$PACKAGE/
cp /usr/share/ultimate_edition/doc/changelog.gz $PACKAGE/usr/share/doc/$PACKAGE/
sudo chmod -R 777 "$PACKAGE"
if [[ -d $PACKAGE ]]; then
CURRENT=$PWD
if [[ -d $PACKAGE/etc/ ]]; then
Encapsulate "Scanning /etc to build conffiles."
cd $PACKAGE
find etc/ -name '*' -type f > DEBIAN/conffiles
#search and replace etc/ with /etc/
sed -i 's/etc/\/etc/g' DEBIAN/conffiles
cd $CURRENT
else
Encapsulate "No /etc/ so need to build conffiles."
fi
cd $PACKAGE
Encapsulate "Calculating MD5SUMS in "$PACKAGE
find -name "DEBIAN" -prune -o -type f -exec md5sum {} + > DEBIAN/md5sums
cd $CURRENT
Encapsulate "Setting ownership to root in $PACKAGE"
sudo chown -R root:root $PACKAGE
sudo find $PACKAGE -type d -exec chmod 755 {} \;
Encapsulate "Chmodding folders to 755: Success."
#set 644 for files
sudo find $PACKAGE -type f -exec chmod 644 {} \;
Encapsulate "Chmodding files to 644: Success."
Encapsulate "Scanning for executables in $PACKAGE."
FullBar
echo -en "${txtcyn}"
find "$PACKAGE/" -name "DEBIAN" -prune -o -type f -exec sh -c 'test "$(head -c 2 "$1")" = "#!"' sh {} \; -print -exec sudo chmod 755 {} \;
sudo chmod 0664 "$PACKAGE/etc/netdata/netdata.conf"
sudo chmod 755 "$PACKAGE/usr/sbin/netdata"
sudo touch "$PACKAGE/var/log/netdata/debug.log"
sudo chown netdata:netdata -R "$PACKAGE/usr/share/netdata/web/"
sudo chown netdata:netdata -R "$PACKAGE/var/log/netdata/"
cd $PACKAGE/DEBIAN/
echo "Setting permissions rights for control etc."
sudo chmod 755 * 2>/dev/null
sudo chmod 644 control 2>/dev/null
sudo chmod 644 md5sums 2>/dev/null
sudo chmod 644 conffiles 2>/dev/null
sudo chmod 644 shlibs 2>/dev/null
sudo chmod 644 symbols 2>/dev/null
sudo chmod 644 templates 2>/dev/null
cd $CURRENT
else
echo -e "${bldred}CRITICAL ERROR: $PACKAGE, not found.${txtrst}"
exit 0;
fi
FullBar
echo "PACKAGE is: $PACKAGE"
if ! [[ -f "$PACKAGE/usr/sbin/netdata" ]]; then
Error "Critical: no Executable."
fi
if [[ -d $PACKAGE ]]; then
echo "Debug: in $PWD"
echo -e -n "${bldgrn}Building Package $PACKAGE.deb: "
else
echo -e "${bldred}Critical error in $PWD folder $PACKAGE does not exist.${txtrst}"
fi
SUCCESS=$(dpkg --build $PACKAGE)
if [[ -f "$PACKAGE.deb" ]]; then
echo -e "${bldgrn}Success.${txtrst}"
else
echo -e "${bldred}Failure.${txtrst}"
exit 0
fi
if [[ $SUCCESS ]]; then
#mv ultimate-edition-core*.deb ultimate-edition-$1-core-files.deb
echo -e "${bldgrn}Cleaning up.${txtrst}"
TRASH=$(sudo rm -R "$PACKAGE/")
FullBar
Center "$APPNAME($PROGNAME): All operations completed successfully."
FullBar
else
echo -e "${bldred}ERROR: Fatal${txtrst}"
fi
}
VersionDump() {
GREPIT=$(echo $* | grep 'suppress')
if ! [[ $GREPIT ]]; then
Center "$APPNAME ($PROGNAME) $VERSION, $BUILDDATE"
Encapsulate "GNU $PROGNAME home page: <http://$WEBSITE/>."
Encapsulate "E-mail bug reports to: $EMAIL."
Encapsulate "Be sure to include the word $PROGNAME somewhere in the Subject: field."
FullBar
else
echo "$APPNAME ($PROGNAME) $VERSION, $BUILDDATE"
echo "GNU $PROGNAME home page: <http://$WEBSITE/>."
echo "E-mail bug reports to: $EMAIL."
echo "Be sure to include the word $PROGNAME somewhere in the Subject: field."
fi
}
Help() {
CONTAINS=$(echo $* | grep -w '\-h\|\-\-help')
#echo "DEBUGGING HELP FUNCTION: 1:$1 2:$2 3:$3 CONTAINS:$CONTAINS"
if ! [[ $3 == "" && $CONTAINS ]]; then
if [[ $2 != "" ]]; then
PRAM=$2
else
PRAM="ALL"
fi
fi
if [[ $CONTAINS ]]; then
if [[ $3 == "" ]]; then
VersionDump
fi
if [[ $2 != "" ]]; then
PRAM=$2
else
PRAM="ALL"
VersionDump
fi
fi
if ! [[ $1 ]]; then
VersionDump
fi
case $PRAM in
ALL)
echo -e "${bldgrn}Usage: $PROGNAME -<-COMMAND> [OPTION]${txtrst}"
FullBar
echo "Mandatory arguments to long options are identical for short options."
echo -e " possible commands...\n"
echo ' -h --help this help message'
echo -e ' -v --version dump version info and exit\n'
FullBar
echo -e "${bldgrn}$PROGNAME --help [COMMAND] for further information.${txtrst}";;
ALL|b|build)
FullBar
echo -e "\n${bldwht}Usage build;${txtrst}"
EyeCandy "$PROGNAME -b <VERSION>"
echo -e "Invokes $PROGNAME to build corefiles for Ultimate Edition <VERSION> from scratch. The format"
echo "must comply as follows:"
echo "<VERSION> [LITE/GAMERS/SERVER] [DE]"
echo "Valid arguments are as follows and <REQUIRED>:"
echo "Version: 3.4, 3.5 - 4.7"
echo "[OPTIONAL TYPES]"
echo "Lite: lite"
echo "Gamers: gamers"
echo "Server: server, minimal-server"
echo "[OPTIONAL DE]"
echo "Desktop Environment (DE): MATE, KDE, XFCE, AWESOME, LXDE, RAZORQT, TOUCH, CINNAMON"
echo "and / or GNOME to add [OPTIONAL] Desktop Environment(s)"
echo "iso, lite, gamers, server and DE's as per synopsis is [OPTIONAL]"
FullBar
echo -e "${bldgrn}Example: ${bldwht}$PROGNAME --build 4.7 mate --defaultde=mate${txtrst}"
echo "Will build core files for Ultimate Edition 4.7 setting mate as default (DE)."
echo "adding the optional mate DE"
FullBar;;
ALL|v|version)
echo -e "\n${bldwht}Usage version;${txtrst}"
echo -e "${txtgrn}$PROGNAME -v${txtrst}"
echo -e "Displays $PROGNAME's version number and exits.";;
ALL|h|help|\?)
echo -e "\n${bldwht}Useage Help [COMMAND];${txtrst}"
echo -e "${txtgrn}$PROGNAME -h [COMMAND]${txtrst}"
echo "Displays this message. For futher information $PROGNAME help [COMMAND]"
echo -e "or refer to the manpages.\n"
echo -e "man $PROGNAME"
echo -e "${txtgrn}"
echo -e "Example: $PROGNAME -h version"
echo -e "${txtwht}Will display help about the command version${txtrst}"
esac
exit 0
}
InstScripts() {
Encapsulate "Writing postinst script."
echo '#!/bin/bash
# title :netdata post installation
# author :Glenn Cady <[email protected]>
# date :04/13/2016
# ============================================================================
set -e
root_inode=$(stat -c %i /);
if [ $root_inode -ne 2 ]; then echo "Chroot environment detected."; else echo "We are NOT in a chroot environment."; fi
case "$1" in
configure)
# Discovered condition #1: user is installing using sudo command in physical O/S
if [ "$IUSER" != "root" ]
then
if [ $root_inode == 2 ]
then
echo "Installing Netdata for $IUSER"
echo >&2 "Adding netdata user group ..."
getent group netdata > /dev/null || groupadd -r netdata
echo >&2 "Adding netdata user account ..."
getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
echo "Done."
fi
fi
# Discovered condition #2: user is installing as root in chroot environment.
if [ "$IUSER" != "root" ]
then
if ! [ $root_inode == 2 ]
then
echo "Chroot environment detected running as root user."
echo "Installing Netdata for $IUSER"
echo >&2 "Adding netdata user group ..."
getent group netdata > /dev/null || groupadd -r netdata
echo >&2 "Adding netdata user account ..."
getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
echo "Done."
fi
fi
# Discovered condition #3: user is installing as root in physical O/S
if [ "$IUSER" == "root" ]
then
if ! [ $root_inode == 2 ]
then
echo "Setting up scripts for root user."
echo "Installing Netdata for $IUSER"
echo >&2 "Adding netdata user group ..."
getent group netdata > /dev/null || groupadd -r netdata
echo >&2 "Adding netdata user account ..."
getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
if [ -f /var/run/netdata.pid ]
then
echo "Trying a soft restart"
kill -9 `cat /var/run/netdata.pid`
sleep 2
echo >&2 "Starting netdata..."
./usr/sbin/netdata -pidfile /var/run/netdata.pid
if [ $? -ne 0 ]
then
echo >&2
echo >&2 "SORRY! FAILED TO START NETDATA!"
exit 1
else
echo >&2 "OK. NetData Started!"
fi
echo "Done."
fi
fi
fi
# Report distro info
lsb_release -a
update-rc.d netdata defaults 2>/dev/null
;;
esac
exit 0' > "$PACKAGE/DEBIAN/postinst"
if [[ -f "$PACKAGE/DEBIAN/postinst" ]]; then
Encapsulate "Success."
else
Error "Failure! Permission rights issue(s)?"
exit 1;
fi
Encapsulate "Writing postrm script."
echo "#!/bin/bash" > "$PACKAGE/DEBIAN/postrm"
echo "# title :netdata post installation" > "$PACKAGE/DEBIAN/postrm"
echo "# author :Glenn Cady <[email protected]>" > "$PACKAGE/DEBIAN/postrm"
echo "# date :04/07/2016" > "$PACKAGE/DEBIAN/postrm"
echo "# ============================================================================" > "$PACKAGE/DEBIAN/postrm"
echo "set -e" > "$PACKAGE/DEBIAN/postrm"
echo 'LOG_DIR="/var/log/netdata/"' > "$PACKAGE/DEBIAN/postrm"
echo '[ -d "${LOG_DIR}" ]' > "$PACKAGE/DEBIAN/postrm"
echo 'case "${1}" in' > "$PACKAGE/DEBIAN/postrm"
echo "remove)" > "$PACKAGE/DEBIAN/postrm"
echo " # Remove logs" > "$PACKAGE/DEBIAN/postrm"
echo ' rm -rf "${LOG_DIR}"' > "$PACKAGE/DEBIAN/postrm"
echo ";;" > "$PACKAGE/DEBIAN/postrm"
echo " purge)" > "$PACKAGE/DEBIAN/postrm"
echo " # Remove logs" > "$PACKAGE/DEBIAN/postrm"
echo ' rm -rf "${LOG_DIR}"' > "$PACKAGE/DEBIAN/postrm"
echo " # Remove user/group" > "$PACKAGE/DEBIAN/postrm"
echo " deluser netdata || true" > "$PACKAGE/DEBIAN/postrm"
echo " delgroup netdata || true" > "$PACKAGE/DEBIAN/postrm"
echo ";;" > "$PACKAGE/DEBIAN/postrm"
echo " upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)" > "$PACKAGE/DEBIAN/postrm"
echo " # Nothing to do" > "$PACKAGE/DEBIAN/postrm"
echo ";;" > "$PACKAGE/DEBIAN/postrm"
echo " *)" > "$PACKAGE/DEBIAN/postrm"
echo ' echo "${0} called with unknown argument \`${1}'" >&2" > "$PACKAGE/DEBIAN/postrm"
echo " exit 1" > "$PACKAGE/DEBIAN/postrm"
echo ";;" > "$PACKAGE/DEBIAN/postrm"
echo "esac" > "$PACKAGE/DEBIAN/postrm"
echo "exit 0" > "$PACKAGE/DEBIAN/postrm"
if [[ -f "$PACKAGE/DEBIAN/postrm" ]]; then
Encapsulate "Success."
else
Error "Failure! Permission rights issue(s)?"
exit 1;
fi
}
BuildNetdata() {
VersionDump
if ! [[ "$2" == "" ]]; then
if [[ -d "$PACKAGE/" ]]; then
Encapsulate "Old build detected, removing."
sudo rm -R "$PACKAGE/"
fi
DebianStructure
ControlFile "$2"
Populate
InstScripts
Services
BuildPackage
exit 1;
fi
exit 0;
}
# Command Line Interpreter. - We do have a function above to handle invalidity (unused btw)
# We also have bash autocompletion to herd users into the corral ;)
# Each function has is's own invalidity options. This will expand, and why I pass $* (everything*)
# In every function.
case "$1" in
-b|--build) BuildNetdata "$@"; exit 0;;
-v|--version) VersionDump $*; exit 0;;
*) Help; exit 0;;
esac
# ==============================================================================
# This code was automatically cleaned up using code-cleanup
# title :code-cleanup
# description :Bash code cleanup script
# Author :root
# date :10/23/2013
# version :1.7.2-1
# http://ultimateedition.info/
# ==============================================================================
Once it is tested, Patrick is doing so right now as I type w/o building it (installing the deb). I can almost guarantee you once that happens I can unload it to our repositories and all reap the benefits.
Please do not download the following unless you are courteous, brave & want to help debug:
I am providing the following data to assist in correction of packaging, repostorm has picked up.
Warnings:
Warning: W: netdata: missing-depends-line Logged to all_warnings.txt.
Warning: W: netdata: non-standard-dir-in-usr usr/libexec/ Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/README.md Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/airsearches.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/ap.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/apache.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/cpu_apps.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/cpufreq.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/crsproxy.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/example.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/load_average.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/mem_apps.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/mysql.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/nginx.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/nut.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/opensips.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/postfix.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/sensors.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/charts.d/squid.chart.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/README.md Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/named.node.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/asn1.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/ber/errors.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/ber/index.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/ber/reader.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/ber/types.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/ber/writer.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/extend.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/net-snmp.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/netdata.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/node-int64.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/node_modules/pixl-xml.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/sma_webbox.node.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/node.d/snmp.node.js Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/README.md Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/apps.plugin Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/charts.d.dryrun-helper.sh Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/charts.d.plugin Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/loopsleepms.sh.inc Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/node.d.plugin Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir usr/libexec/netdata/plugins.d/tc-qos-helper.sh Logged to all_warnings.txt.
Warning: W: netdata: duplicate-font-file usr/share/netdata/web/fonts/FontAwesome.otf also in fonts-font-awesome Logged to all_warnings.txt.
Warning: W: netdata: duplicate-font-file usr/share/netdata/web/fonts/fontawesome-webfont.ttf also in fonts-font-awesome Logged to all_warnings.txt.
Warning: W: netdata: file-in-unusual-dir var/log/netdata/debug.log Logged to all_warnings.txt.
Errors:
E: netdata: arch-independent-package-contains-binary-or-object usr/libexec/netdata/plugins.d/apps.plugin
E: netdata: unstripped-binary-or-object usr/libexec/netdata/plugins.d/apps.plugin
E: netdata: arch-independent-package-contains-binary-or-object usr/sbin/netdata
E: netdata: unstripped-binary-or-object usr/sbin/netdata
E: netdata: changelog-file-missing-in-native-package
E: netdata: no-copyright-file
E: netdata: postrm-does-not-call-updaterc.d-for-init.d-script etc/init.d/netdata
E: netdata: init.d-script-does-not-implement-required-option etc/init.d/netdata force-reload
E: netdata: shell-script-fails-syntax-check etc/init.d/netdata
E: netdata: arch-independent-package-contains-binary-or-object usr/libexec/netdata/plugins.d/apps.plugin
E: netdata: arch-independent-package-contains-binary-or-object usr/sbin/netdata
E: netdata: postrm-does-not-call-updaterc.d-for-init.d-script etc/init.d/netdata
E: netdata: init.d-script-does-not-implement-required-option etc/init.d/netdata force-reload
E: netdata: shell-script-fails-syntax-check etc/init.d/netdata
E: netdata: arch-independent-package-contains-binary-or-object usr/libexec/netdata/plugins.d/apps.plugin
E: netdata: arch-independent-package-contains-binary-or-object usr/sbin/netdata
E: netdata: postrm-does-not-call-updaterc.d-for-init.d-script etc/init.d/netdata
E: netdata: init.d-script-does-not-implement-required-option etc/init.d/netdata force-reload
E: netdata: shell-script-fails-syntax-check etc/init.d/netdata
a bunch of those errors / warnings are buried in the binary I provide below. Not all. Makes me want to continue production on the Storm