bgp, collectd, logsentry, ospf: update scripts

This commit is contained in:
Jérémy Dubois 2023-02-06 16:10:40 +01:00
parent cdc2546448
commit 328dc63d82
6 changed files with 47 additions and 21 deletions

View file

@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* logsentry: update config files, add "[logsentry]" in subject, and simplify task
* nagios-nrpe: deleted unused variables and added a ntp check server variable
* post-install: use basename of path in generateldif.sh to define file from elsewhere
* bgp, collectd, logsentry, ospf: update scripts
### Fixed

View file

@ -1,4 +1,4 @@
#!/bin/ksh
#!/bin/sh
# Script writen by Daniel Jakots
@ -29,7 +29,7 @@ mkdir -p "${_TMPDIR}"
# Don't try to run if it's already running
if [ -e "${_PIDFILE}" ]; then
date >> "${_TMPDIR}"/log
echo "$(date)" >> "${_TMPDIR}"/log
exit 1
else
echo $$ >> "${_PIDFILE}"
@ -49,11 +49,13 @@ bgpctl show neighbor | grep Description {{ bgp_exclude_grep_command }} | sed s,\
while read -r _PEER
do
_STATUS=$(/usr/sbin/bgpctl show neighbor "${_PEER}" | grep state | awk '{print $4}' |tr -d ',')
echo -n "${_PEER}" >> "${_TMPDIR}"/bgp-status
echo -n " " >> "${_TMPDIR}"/bgp-status
# we note only if it's established or not
if ! [[ "${_STATUS}" = "Established" ]] ; then
_STATUS="NotEstablished"
fi
echo "${_PEER} ${_STATUS}" >> "${_TMPDIR}"/bgp-status
echo "${_STATUS}" >> "${_TMPDIR}"/bgp-status
done <"${_TMPDIR}"/peers-list

View file

@ -2,6 +2,7 @@ Interval {{ collectd_interval }}
Timeout 2
LoadPlugin syslog
<Plugin syslog>
LogLevel warning
</Plugin>
@ -23,25 +24,46 @@ LoadPlugin syslog
{% endif %}
</Plugin>
{% endif %}
{% if collectd_plugin_cpu is sameas true %}
LoadPlugin cpu
{% endif %}
{% if collectd_plugin_df is sameas true %}
LoadPlugin df
{% endif %}
{% if collectd_plugin_disk is sameas true %}
LoadPlugin disk
{% endif %}
{% if collectd_plugin_interface is sameas true %}
LoadPlugin interface
{% endif %}
{% if collectd_plugin_load is sameas true %}
LoadPlugin load
{% endif %}
{% if collectd_plugin_memory is sameas true %}
LoadPlugin memory
{% endif %}
LoadPlugin network
{% if collectd_plugin_pf is sameas true %}
LoadPlugin pf
{% endif %}
{% if collectd_plugin_processes is sameas true %}
LoadPlugin processes
{% endif %}
{% if collectd_plugin_swap is sameas true %}
LoadPlugin swap
{% endif %}
{% if collectd_plugin_tcpconns is sameas true %}
LoadPlugin tcpconns
{% endif %}
{% if collectd_plugin_uptime is sameas true %}
LoadPlugin uptime
{% endif %}
{% if collectd_plugin_users is sameas true %}
LoadPlugin users
{% endif %}
{% if collectd_plugin_pf is sameas true %}
LoadPlugin pf
{% endif %}
{% if collectd_plugin_df is sameas true %}
LoadPlugin df
<Plugin df>
# expose host's mounts into container using -v /:/host:ro (location inside container does not matter much)
# ignore rootfs; else, the root file-system would appear twice, causing
@ -73,7 +95,6 @@ LoadPlugin df
{% endif %}
{% if collectd_plugin_disk is sameas true %}
LoadPlugin disk
<Plugin "disk">
#Disk "/^[hsv]d[a-z]/"
IgnoreSelected false
@ -81,28 +102,24 @@ LoadPlugin disk
{% endif %}
{% if collectd_plugin_cpu is sameas true %}
LoadPlugin cpu
<Plugin cpu>
ValuesPercentage true
</Plugin>
{% endif %}
{% if collectd_plugin_memory is sameas true %}
LoadPlugin memory
<Plugin memory>
ValuesPercentage true
</Plugin>
{% endif %}
{% if collectd_plugin_swap is sameas true %}
LoadPlugin swap
<Plugin swap>
ValuesPercentage true
</Plugin>
{% endif %}
{% if collectd_plugin_interface is sameas true %}
LoadPlugin interface
<Plugin interface>
Interface "/^lo[0-9]*/"
Interface "/^veth.*/"
@ -113,13 +130,12 @@ LoadPlugin interface
{% endif %}
{% if collectd_plugin_tcpconns is sameas true %}
LoadPlugin tcpconns
<Plugin "tcpconns">
AllPortsSummary true
</Plugin>
{% endif %}
LoadPlugin network
<Plugin "network">
Server "{{ collectd_server }}" "25826"
<Server "{{ collectd_server }}" "25826">
</Server>
</Plugin>

View file

@ -66,6 +66,7 @@ collectd.*: parse_value: Failed to parse string as gauge: "Idle".
doas: _collectd ran command /bin/cat /var/log/daemon as root from /var/collectd
doas: _collectd ran command /usr/sbin/bgpctl sh as root from /var/collectd
doas: _collectd ran command /usr/sbin/bgpctl show neighbor as root from /var/collectd
doas: _collectd ran command /usr/sbin/unbound-control stats as root from /var/collectd
doas: _nrpe ran command /sbin/bioctl sd2 as root from /
doas: _nrpe ran command /usr/local/libexec/nagios
doas: .* ran command su - as root from

View file

@ -1,4 +1,4 @@
#!/bin/ksh
#!/bin/sh
# Script writen by Daniel Jakots for BGP, adapted by Jeremy Dubois for OSPF
@ -29,7 +29,7 @@ mkdir -p "${_TMPDIR}"
# Don't try to run if it's already running
if [ -e "${_PIDFILE}" ]; then
date >> "${_TMPDIR}"/log
echo "$(date)" >> "${_TMPDIR}"/log
exit 1
else
echo $$ >> "${_PIDFILE}"
@ -51,7 +51,7 @@ do
_STATUS=$(/usr/sbin/ospf6ctl show neighbor | grep "${_PEER} " | awk {'print $3'})
echo -n "${_PEER}" >> "${_TMPDIR}"/ospf6-status
echo -n " " >> "${_TMPDIR}"/ospf6-status
if [[ "${_STATUS}" = "FULL/BCKUP" ]] || [[ "${_STATUS}" = "FULL/DR" ]] || [[ "${_STATUS}" = "2-WAY/OTHER" ]] || [[ "${_STATUS}" = "FULL/OTHER" ]] ; then
if ([[ "${_STATUS}" = "FULL/BCKUP" ]] || [[ "${_STATUS}" = "FULL/DR" ]] || [[ "${_STATUS}" = "2-WAY/OTHER" ]] || [[ "${_STATUS}" = "FULL/OTHER" ]]) ; then
_STATUS="UP"
else
_STATUS="DOWN"
@ -103,6 +103,9 @@ fi
echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body
ospf6ctl show fib ospf >> "${_TMPMAILDIR}"/body
echo "\n\n*** OSPF interfaces state ***\n" >> "${_TMPMAILDIR}"/body
ospf6ctl show interfaces >> "${_TMPMAILDIR}"/body
echo "\n\n*** Network used memory ***\n" >> "${_TMPMAILDIR}"/body
netstat -m >> "${_TMPMAILDIR}"/body

View file

@ -1,4 +1,4 @@
#!/bin/ksh
#!/bin/sh
# Script writen by Daniel Jakots for BGP, adapted by Jeremy Dubois for OSPF
@ -29,7 +29,7 @@ mkdir -p "${_TMPDIR}"
# Don't try to run if it's already running
if [ -e "${_PIDFILE}" ]; then
date >> "${_TMPDIR}"/log
echo "$(date)" >> "${_TMPDIR}"/log
exit 1
else
echo $$ >> "${_PIDFILE}"
@ -51,7 +51,7 @@ do
_STATUS=$(/usr/sbin/ospfctl show neighbor | grep "${_PEER} " | awk {'print $3'})
echo -n "${_PEER}" >> "${_TMPDIR}"/ospf-status
echo -n " " >> "${_TMPDIR}"/ospf-status
if [[ "${_STATUS}" = "FULL/BCKUP" ]] || [[ "${_STATUS}" = "FULL/DR" ]] || [[ "${_STATUS}" = "2-WAY/OTHER" ]] || [[ "${_STATUS}" = "FULL/OTHER" ]] ; then
if ([[ "${_STATUS}" = "FULL/BCKUP" ]] || [[ "${_STATUS}" = "FULL/DR" ]] || [[ "${_STATUS}" = "2-WAY/OTHER" ]] || [[ "${_STATUS}" = "FULL/OTHER" ]]) ; then
_STATUS="UP"
else
_STATUS="DOWN"
@ -103,6 +103,9 @@ fi
echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body
ospfctl show fib ospf >> "${_TMPMAILDIR}"/body
echo "\n\n*** OSPF interfaces state ***\n" >> "${_TMPMAILDIR}"/body
ospfctl show interfaces >> "${_TMPMAILDIR}"/body
echo "\n\n*** Network used memory ***\n" >> "${_TMPMAILDIR}"/body
netstat -m >> "${_TMPMAILDIR}"/body