Package: simple-monitor-alert
Simple Monitor AlertA simple monitor with alerts for Unix/Linux under the KISS philosophy. Keep It Simple, Stupid!Light: Only ~7MiB of RAM. (That’s great for your raspberry pi!)Veryeasyto use and understand.Writeyour own monitorsin any language (Bash, Python, Perl, JS, Ruby, PHP, C, C++…).Awesome features: send alerts once or several times, graphic peak…No server required. You can run as adaemon or using crond.Easy todebugand test.Multiple ways to send alerts:email, telegram…Easy configurationin a single file.Available monitors:Hard disks: SMART, temperature, free space, Mdadm (linux RAID).System: CPU usage, free RAM, free SWAP, monitorize services (daemons), sensors, [time]…Web: load time, return code, content in page.Network: ping, [port, dynamic ip].Others: [Log monitor, google cloud print]Screencast3-Step Quick Start GuideInstall it from Pypi:$ sudo pip install simple-monitor-alertEdit/etc/simple-monitor-alert/sma.iniand defines the recipient of the alerts:[mail]
to = awesome@email.comExecute sma:# Just once:
$ sma
# or... Run as a service (daemon)
$ sma service
# or... Run usign system service:
$ sudo systemctl start smaAnd yes, that’s it!5 minutes guideFiles and directories:/etc/simple-monitor-alert/sma.ini(file): all-in-one config file. Configure monitors and alerts methods./etc/simple-monitor-alert/monitors-available(directory): All monitors available for usage. You can create monitors here./etc/simple-monitor-alert/monitors-enabled(directory): All monitors that are here are activated./etc/simple-monitor-alert/alerts(directory): Alerts methods available. You need to configure them in sma.ini.Enable and disable monitorsAll monitors in/etc/simple-monitor-alert/monitors-enabledare enabled. It is recommended that files are symbolic
links. Toactivatea monitor:$ cd /etc/simple-monitor-alert/monitors-enabled
$ sudo ln -s ../monitors-available/mdadm.shTodisable:$ cd /etc/simple-monitor-alert/monitors-enabled
$ rm mdadm.sh # It's safe. mdadm is a symlink.We recommend you read the beginning of the monitor before activating. Some monitors may require parameters and
configure the system. For example:$ head -n 6 /etc/simple-monitor-alert/monitors-available/service.sh
#!/usr/bin/env bash
# Service Status monitor.
# Verify that the service is running.
# It requires a parameter: service name. For example, sshd.
# [service]
# service_status.param = sshdTo pass the parameter you must add the following tosma.ini:[service]
service_status.param = sshdTo monitor multiple services:[service]
service_status(sshd).param = sshd
service_status(ntpd).param = ntpdDebuggingYou can test your monitors running them:$ /etc/simple-monitor-alert/monitors-available/mdadm.sh
mdadm(md0).name = 'Mdadm /dev/md0'
mdadm(md0).expected = 0
mdadm(md0).value = 0You can also run sma and see the results:$ sma
2016-05-03 00:28:14,972 - sma - INFO    - Trigger: [success] (mdadm) mdadm(md0). Result: 0 == 0
2016-05-03 00:28:14,990 - sma - INFO    - Trigger: [success] (system) ram. Result: 32.1427 <= 85
2016-05-03 00:28:14,990 - sma - INFO    - Trigger: [success] (system) cpu. Result: 9.57627 <= 80
2016-05-03 00:28:15,156 - sma - WARNING - Trigger: [warning] (hdds) pcnt_use(sdc1). Assertion 98 <= 80 failed.
Extra info: Space: 23G/25G
2016-05-03 00:28:15,157 - sma - WARNING - Trigger: [warning] (hdds) pcnt_use(md0). Assertion 100 <= 80 failed.
Extra info: Space: 5,4T/5,5TTo test the alerts you can use:$ sma alerts --testMy first monitorSMA works by checking the output of your monitor script. A monitor has observables. Each observable has 2 major
sections: the expected value and the value obtained:observable1.expected = yes
observable1.value = yes
observable2.expected = yes
observable2.value = noIn this example the first observable is fine and the second is under error. Your program should return something
similar. The following example check that a file exists:#!/usr/bin/env bash
echo "file_exists.expected = yes"
if [ -f "/path/to/file" ]; then value="yes"; else value="no"; fi
echo "file_exists.value = $value"Output:$ /etc/simple-monitor-alert/monitors-available/example-1.sh
file_exists.expected = yes
file_exists.value = noThere are more options with monitors, such as obtaining arguments. For more information see the documentation.