Poor Man’s Monitoring

\|/          (__)
       ||    (__)
       ||w--||     \|/


make sure the emails are reaching out to you

tail -n0 -F /var/log/maillog &
tail -n0 -F /var/log/mail.* &
date | mail -s `uname -n` root

make sure curl is configured properly against a CA store

curl -I https://nethence.com/

grab the script from here, uncomment/tune whatever suits your infrastructures and define a cron job against it e.g. every hour

crontab -e

45 * * * * /root/alive.ksh 2>&1


make sure sparse file work

dd if=/dev/zero of=dummy.ext4 bs=1GB count=0 seek=1
mkfs.ext4 dummy.ext4
cp --sparse=always dummy.ext4 dummy-clone.ext4
md5sum dummy.ext4 dummy-clone.ext4
rm -f dummy*

The simplest monitoring system ever

tested on NetBSD, assuming you got ClusterIt ready in da place

I am using Bash instead of KSH because the latter is not always installed on the target linux hosts.

I am just reporting errors (e.g. disk usage above 90%) so it gets send by email from a crontab.

Prepare the scripts,

mkdir ~/report/
cd ~/report/
wget http://pbraun.nethence.com/scripts/net/diskusage.bash
wget http://pbraun.nethence.com/scripts/net/memoryusage.bash
wget http://pbraun.nethence.com/scripts/net/omreport.bash
chmod +x diskusage.bash
chmod +x memoryusage.bash
chmod +x omreport.bash

test them,

cd ~/
dsh -e -g linux -s report/diskusage.bash
dsh -e -g linux -s report/memoryusage.bash
dsh -e -g poweredge -s report/omreport.bash

Make sure you’ve setup the root alias in /etc/mail/aliases.

Eventually setup a smarthost (relayhost =) into /etc/postfix/main.cf

Then finally enable the crontab e.g.,

crontab -e
*/5 * * * * /usr/pkg/bin/dsh -e -g linux -s /root/report/diskusage.bash
0 * * * * /usr/pkg/bin/dsh -e -g poweredge -s /root/report/omreport.bash

on NetBSD, also change the daily/weekly/monthly crontabs so you won’t get bugged (no need to setup a filter which would make the alerts useless!),

15 3 * * * /bin/sh /etc/daily >> /var/log/daily.out 2>&1
30 4 * * 6 /bin/sh /etc/weekly >> /var/log/weekly.out 2>&1
30 5 1 * * /bin/sh /etc/monthly >> /var/log/monthly.out 2>&1

Note. full path for script to be executed is needed into the crontab, while on command line you can use -s report/scriptname where ever you are (so it’s not even relative to your current working directory but to the homedir), strange.

To enable the Web UI, launch the NetBSD built-in web server (Bozohttpd),

cd /etc/
cp inetd.conf inetd.conf.dist
vi inetd.conf

http stream tcp nowait:600 _httpd /usr/libexec/httpd httpd -X /var/www
http stream tcp6 nowait:600 _httpd /usr/libexec/httpd httpd -X /var/www

/etc/rc.d/inetd reload

Note. -X to enable directory listing

Copyright © 2024 Pierre-Philipp Braun