Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new interface metrics: speed, mtu, duplex and isup. (#646) #837

Open
wants to merge 16 commits into
base: maint
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ agent/plugins/*
ncpa.db
prereqs.installed
.python-version
.DS_Store
build/ncpa
build/*.dmg
build/NCPA-*
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
2.4.1 - 2022-08-16
==================
- Changed the date format in the changelog (#838) (ccztux)
- Added new interface metrics speed, duplex, mtu and isup (#646) (ccztux)
- Removed max_file_length and max_file_path from graphing (ccztux)
- NRDP connection timeout is missing in the admin section of the gui (#841) (ccztux)
- Updated psutil to address incorrectly reported mounts on Windows (#863)
- Changed the way NCPA detects the number of CPUs (#864)
Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Downloads
Current versions:

+---------+-------------+-------------------------------------------------------+
| Current | **2.4.0** | `Downloads <https://www.nagios.org/ncpa/#downloads>`_ |
| Current | **2.5.0** | `Downloads <https://www.nagios.org/ncpa/#downloads>`_ |
+---------+-------------+-------------------------------------------------------+

`Older Versions <https://www.nagios.org/ncpa/archive.php>`_
Expand All @@ -21,9 +21,10 @@ We currently build for the following operating systems:

- Windows (7+)
- Mac OS X (10.7+)
- CentOS / RHEL 7, 8
- CentOS Stream
- Debian 9, 10
- RHEL 7, 8, 9
- CentOS 7
- CentOS Stream 8, 9
- Debian 9, 10, 11
- Ubuntu 16.04, 18.04, 20.04
- OpenSUSE Leap 15, Tumbleweed
- SLES 11, 12, 15
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.1
2.4.1
164 changes: 116 additions & 48 deletions agent/build_resources/macosinstall.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh

set -e

pushd /Volumes/NCPA-*
scriptUser=$(whoami)
if ! id -Gn "${scriptUser}" | grep -q -w admin; then
echo -e "\n\n ERROR!!!: You must have admin privileges to run this script!\n\n"
exit 1
fi

# These values are set in the ncpa.cfg for the user to drop permissions to
username="nagios"
Expand All @@ -14,47 +16,66 @@ added="0"
# Check if NCPA is installed
if [ -d ${homedir} ]; then
upgrade="1"
echo "Starting upgrade..."
echo "Starting upgrade... "
else
echo "Starting install..."
echo "Starting install... "
fi

# Get MacOS version
macOSVer=""
if [[ $OSTYPE == 'darwin'* ]]; then
macOSVer=`sw_vers | grep ProductVersion | awk '{print $2}'`
echo " MacOS version: $macOSVer."
fi

# Disable NCPA if it's already installed for upgrade
# Go to install script directory
pushd $( dirname -- "${0}" )

# Quit if any errors occur
set -e

# Save config and disable NCPA if it's already installed for upgrade
if [ ${upgrade} -eq "1" ]; then
echo -n "Stopping old NCPA services..."
# Temporarily save etc directory
echo -n " Saving configuration... "
cp -Rf ${homedir}/etc /tmp/ncpa_etc
echo "Done."

echo -n " Stopping old NCPA services... "
launchctl stop com.nagios.ncpa.listener
launchctl stop com.nagios.ncpa.passive

# Give launchctl time to stop services before continuing
sleep 5
echo "done"
echo "Done."
fi

# Create the group account
if ! dscl . -read /Groups/${groupname} > /dev/null 2>&1;
then
# Select GID the same way
PrimaryGroupID=`dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -ug | tail -1`
let PrimaryGroupID=PrimaryGroupID+1

# Create the group if we need to
if ! dscl . -read /Groups/${groupname} > /dev/null 2>&1; then
echo -n " Adding nagios user and group... "
echo -n "Creating the group account... "
# Select GID the same way
PrimaryGroupID=`dscl . -list /Groups PrimaryGroupID | awk '{print $2}' | sort -ug | tail -1`
let PrimaryGroupID=PrimaryGroupID+1

# Create the group if we need to
dscl . -create /Groups/${groupname}
dscl . -create /Groups/${groupname} RecordName "_${groupname} ${username}"
dscl . -create /Groups/${groupname} PrimaryGroupID ${PrimaryGroupID}
dscl . -create /Groups/${groupname} RealName "${groupname}"
dscl . -create /Groups/${groupname} Password "*"

added="1"
added="1"
fi

# Create the user account
if ! dscl . -read /Users/${username} > /dev/null 2>&1;
then
# Find the highest UID that exists, pick the next one
UniqueID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1`
let UniqueID=UniqueID+1
if ! dscl . -read /Users/${username} > /dev/null 2>&1; then
echo -n "Creating the user account... "
# Find the highest UID that exists, pick the next one
UniqueID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -ug | tail -1`
let UniqueID=UniqueID+1

# Create the actual user if we need to
# Create the actual user if we need to
dscl . -create /Users/${username}
dscl . -create /Users/${username} UserShell /usr/bin/false
dscl . -create /Users/${username} UniqueID ${UniqueID}
Expand All @@ -63,68 +84,115 @@ then
dscl . -create /Users/${username} Password "*"
dscl . -create /Users/${username} NFSHomeDirectory ${homedir}

added="1"
added="1"
fi

if [ ${added} -eq "1" ]; then
echo "Users and group set"
echo "Done."
else
echo " Nagios user and group already exist."
fi

# Unload the daemons so they can be re-loaded after
if [ ${upgrade} -eq "1" ]; then
echo -n "Re-loading services..."
echo -n " Unloading old NCPA services... "
launchctl unload /Library/LaunchDaemons/com.nagios.ncpa.listener.plist
launchctl unload /Library/LaunchDaemons/com.nagios.ncpa.passive.plist
else
echo -n "Loading services..."
echo "Done."
fi

cp ncpa/build_resources/ncpa_listener.plist /Library/LaunchDaemons/com.nagios.ncpa.listener.plist
cp ncpa/build_resources/ncpa_passive.plist /Library/LaunchDaemons/com.nagios.ncpa.passive.plist

echo "done"
echo -n "Setting permissions..."

mkdir -p ${homedir}
# Remove MacOS x attributes
echo -n " Removing MacOS xattributes from LaunchDaemon plists... "
if [[ $(xattr -l /Library/LaunchDaemons/com.nagios.ncpa.listener.plist) ]]; then
xattr -d com.apple.quarantine /Library/LaunchDaemons/com.nagios.ncpa.listener.plist
fi

# Temporarily save etc directory
if [ ${upgrade} -eq "1" ]; then
cp -Rf ${homedir}/etc /tmp/ncpa_etc
if [[ $(xattr -l /Library/LaunchDaemons/com.nagios.ncpa.passive.plist) ]]; then
xattr -d com.apple.quarantine /Library/LaunchDaemons/com.nagios.ncpa.passive.plist
fi

# Copy over files
echo "Done."

echo -n " Copying new NCPA files... "
mkdir -p ${homedir}
cp -Rf ncpa/* ${homedir}
echo "Done."

echo -n " Setting permissions... "
chmod -R 775 ${homedir}
chown -R ${username}:${groupname} ${homedir}
chmod +x "${homedir}/uninstall.sh"
echo "Done."

# Replace files
echo -n " Removing MacOS xattributes from ${homedir}... "
xattr -d -r com.apple.quarantine ${homedir}
echo "Done."

# Restore config files
if [ ${upgrade} -eq "1" ]; then
cp -Rf /tmp/ncpa_etc ${homedir}
echo -n " Restoring configuration to ${homedir}/etc... "
rm -rf ${homedir}/etc
cp -Rf "/tmp/ncpa_etc" "${homedir}/etc"
rm -rf /tmp/ncpa_etc
echo "Done."
fi

echo "done"
echo -n "Starting NCPA..."

echo -n " Starting NCPA... "
launchctl load /Library/LaunchDaemons/com.nagios.ncpa.listener.plist
launchctl load /Library/LaunchDaemons/com.nagios.ncpa.passive.plist

launchctl start com.nagios.ncpa.passive
launchctl start com.nagios.ncpa.listener
echo "Done."

echo "done"
listNCPAcomponents() {
echo "---------------------------------------"
echo "Listing NCPA components... "
echo "\nProcesses?:"
ps aux | grep -v grep | grep ncpa_

echo "\nLaunchDaemons?:"
launchctl list | grep nagios

echo "\nLaunchDaemon plists?:"
ls -al /Library/LaunchDaemons/ | grep nagios

echo "\ndscl group?:"
sudo dscl . -ls /Groups | grep nagios

echo "\ndscl user?:"
sudo dscl . -ls /Users | grep nagios

echo "\nHome dir?:"
ls -al /usr/local | grep ncpa
}

listNCPAcomponents

# Installation completed
echo "\n\n"
echo " "
tokenPhrase="'mytoken'"
if [ ${upgrade} -eq "1" ]; then
echo "-------------------"
echo " Upgrade Completed "
echo "-------------------"
echo "-------------------"
echo " Upgrade Completed "
echo "-------------------"
tokenPhrase="your token"
else
echo "-------------------"
echo " Install Completed "
echo "-------------------"
echo "-------------------"
echo " Install Completed "
echo "-------------------"
fi

echo "\nConfirm your installation:"
echo " 1. In a web browser, navigate to https://localhost:5693 "
echo " (acknowledge the uncertified certificate warning, if necessary)"
echo " 2. Enter ${tokenPhrase} when it asks for a token or a password"
echo " 3. Click the 'See Live Stats' button\n"
echo " After several seconds the graphs should start populating with data."
echo " NCPA is now capturing data from your Mac!"

popd
exit 0
14 changes: 14 additions & 0 deletions agent/build_resources/macosreadme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Installing NCPA:
1. Download MacOS archive (https://www.nagios.org/ncpa/#downloads)
2. Double click open the disk image file to mount it
3. Find the installer volume name in the terminal:
ls /Volumes
Look for NCPA-<version> (e.g. NCPA-2.4.0)

4. Run the installer, and follow any user prompts:
sudo zsh /Volumes/NCPA-<version>/install.sh

Note: if you already have NCPA installed, the installer will upgrade the NCPA software, and retain your configuration.

Uninstalling NCPA
1. On the command line, enter: sudo zsh /usr/local/ncpa/uninstall.sh
Loading