Signed-off-by: Brian J. Murrell <brian@interlinx.bc.ca>lilik-openwrt-22.03
@ -0,0 +1,55 @@ | |||
# | |||
# Copyright (C) 2010-2011 OpenWrt.org | |||
# | |||
# This is free software, licensed under the GNU General Public License v2. | |||
# See /LICENSE for more information. | |||
# | |||
include $(TOPDIR)/rules.mk | |||
PKG_NAME:=foolsm | |||
PKG_VERSION:=1.0.10 | |||
PKG_RELEASE:=1 | |||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | |||
PKG_SOURCE_URL:=http://lsm.foobar.fi/download | |||
PKG_HASH:=33210209ca38b3bfef1a9180f765266a134fc811dea8bc06450a3bd48d1d083e | |||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) | |||
include $(INCLUDE_DIR)/package.mk | |||
define Package/foolsm | |||
SECTION:=net | |||
CATEGORY:=Network | |||
DEPENDS:=+ssmtp | |||
TITLE:=A link state monitor | |||
URL:=http://lsm.foobar.fi/ | |||
endef | |||
define Package/foolsm/description | |||
foolsm is a link state monitor for carrying out actions when a link | |||
transistions from the up to down state or vice versa. | |||
endef | |||
define Package/foolsm/conffiles | |||
/etc/foolsm/foolsm.conf | |||
endef | |||
define Package/foolsm/install | |||
$(INSTALL_DIR) $(1)/usr/sbin | |||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/foolsm $(1)/usr/sbin/ | |||
$(INSTALL_DIR) $(1)/etc/foolsm/script.d | |||
$(INSTALL_DIR) $(1)/etc/init.d | |||
$(INSTALL_DATA) ./files/connections.conf $(1)/etc/foolsm/connections.conf | |||
$(INSTALL_DATA) ./files/foolsm.conf $(1)/etc/foolsm/foolsm.conf | |||
$(INSTALL_BIN) ./files/foolsm_script $(1)/etc/foolsm/script | |||
$(INSTALL_BIN) ./files/foolsm.init $(1)/etc/init.d/foolsm | |||
endef | |||
define Package/foolsm/conffiles | |||
/etc/foolsm/connections.conf | |||
/etc/foolsm/foolsm.conf | |||
endef | |||
$(eval $(call BuildPackage,foolsm)) |
@ -0,0 +1,13 @@ | |||
connection { | |||
name=Provider1 | |||
checkip=1.1.1.1 | |||
device=pppoe-wan | |||
ttl=2 | |||
} | |||
connection { | |||
name=Provider2 | |||
checkip=2.2.2.2 | |||
device=eth0.2 | |||
ttl=1 | |||
} |
@ -0,0 +1,43 @@ | |||
# | |||
# (C) 2009 Mika Ilmaranta <ilmis at nullnet.fi> | |||
# | |||
# License: GPLv2 | |||
# | |||
# | |||
# Debug level: 0 .. 8 are normal, 9 gives lots of stuff and 100 doesn't | |||
# bother to detach | |||
# | |||
#debug=10 | |||
#debug=9 | |||
debug=8 | |||
# reopen_on_enodev=1 | |||
# | |||
# Defaults for the connection entries | |||
# | |||
defaults { | |||
name=defaults | |||
checkip=127.0.0.1 | |||
eventscript=/etc/foolsm/script | |||
notifyscript= | |||
max_packet_loss=20 | |||
max_successive_pkts_lost=7 | |||
min_packet_loss=5 | |||
min_successive_pkts_rcvd=10 | |||
interval_ms=2000 | |||
timeout_ms=2000 | |||
warn_email=root | |||
check_arp=0 | |||
sourceip= | |||
# if using ping probes for monitoring only then defaults should | |||
# not define a default device for packets to autodiscover their path | |||
# to destination | |||
# device=eth0 | |||
# use system default ttl | |||
ttl=0 | |||
} | |||
include /etc/foolsm/connections.conf | |||
#EOF |
@ -0,0 +1,19 @@ | |||
#!/bin/sh /etc/rc.common | |||
# Copyright (C) 2010-2011 OpenWrt.org | |||
START=45 | |||
SERVICE_USE_PID=1 | |||
SERVICE_PID_FILE=/var/run/foolsm.pid | |||
start() { | |||
service_start /usr/sbin/foolsm -c /etc/foolsm/foolsm.conf -p $SERVICE_PID_FILE | |||
} | |||
stop() { | |||
service_stop /usr/sbin/foolsm | |||
} | |||
reload() { | |||
service_reload /usr/sbin/foolsm | |||
} |
@ -0,0 +1,57 @@ | |||
#!/bin/sh | |||
# | |||
# (C) 2009 Mika Ilmaranta <ilmis@nullnet.fi> | |||
# (C) 2009 Tom Eastep <teastep@shorewall.net> | |||
# | |||
# License: GPLv2 | |||
# | |||
DATE=$(/bin/date) | |||
STATE=${1} | |||
NAME=${2} | |||
CHECKIP=${3} | |||
DEVICE=${4} | |||
WARN_EMAIL=${5} | |||
REPLIED=${6} | |||
WAITING=${7} | |||
TIMEOUT=${8} | |||
REPLY_LATE=${9} | |||
CONS_RCVD=${10} | |||
CONS_WAIT=${11} | |||
CONS_MISS=${12} | |||
AVG_RTT=${13} | |||
cat <<EOM | ssmtp ${WARN_EMAIL} | |||
Subject: "LSM: ${NAME} ${STATE}, DEV ${DEVICE}" | |||
Hi, | |||
Your connection ${NAME} has changed it's state to ${STATE} at ${DATE}. | |||
Following parameters were passed: | |||
newstate = ${STATE} | |||
name = ${NAME} | |||
checkip = ${CHECKIP} | |||
device = ${DEVICE} | |||
warn_email = ${WARN_EMAIL} | |||
Packet counters: | |||
replied = ${REPLIED} packets replied | |||
waiting = ${WAITING} packets waiting for reply | |||
timeout = ${TIMEOUT} packets that have timed out (= packet loss) | |||
reply_late = ${REPLY_LATE} packets that received a reply after timeout | |||
cons_rcvd = ${CONS_RCVD} consecutively received replies in sequence | |||
cons_wait = ${CONS_WAIT} consecutive packets waiting for reply | |||
cons_miss = ${CONS_MISS} consecutive packets that have timed out | |||
avg_rtt = ${AVG_RTT} average rtt, notice that waiting and timed out packets have rtt = 0 when calculating this | |||
Your LSM Daemon | |||
EOM | |||
exit 0 | |||
#EOF |
@ -0,0 +1,11 @@ | |||
--- a/defs.h 2016-11-10 07:22:50.275506874 -0500 | |||
+++ b/defs.h 2016-11-10 07:22:58.639469850 -0500 | |||
@@ -22,7 +22,7 @@ | |||
#define min(x, y) ((x)<(y) ? (x) : (y)) | |||
-#define PLUGIN_EXPORT_DIR "/var/lib/foolsm" | |||
+#define PLUGIN_EXPORT_DIR "/tmp" | |||
#endif | |||
@ -0,0 +1,11 @@ | |||
--- a/forkexec.c 2017-11-02 07:45:28.679821530 -0400 | |||
+++ /bforkexec.c 2017-11-02 07:44:54.527653043 -0400 | |||
@@ -108,7 +108,7 @@ | |||
int script_status; | |||
pid_t pid; | |||
- while ((pid = waitpid(WAIT_ANY, &script_status, WNOHANG)) != 0) { | |||
+ while ((pid = waitpid(-1, &script_status, WNOHANG)) != 0) { | |||
if(pid == -1) { | |||
if(cfg.debug >= 9 && errno != ECHILD) | |||
syslog(LOG_ERR, "%s: %s: %d: waitpid failed %s", __FILE__, __FUNCTION__, __LINE__, strerror(errno)); |