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 * logsentry: update config files, add "[logsentry]" in subject, and simplify task
* nagios-nrpe: deleted unused variables and added a ntp check server variable * 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 * post-install: use basename of path in generateldif.sh to define file from elsewhere
* bgp, collectd, logsentry, ospf: update scripts
### Fixed ### Fixed

View File

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

View File

@ -2,6 +2,7 @@ Interval {{ collectd_interval }}
Timeout 2 Timeout 2
LoadPlugin syslog LoadPlugin syslog
<Plugin syslog> <Plugin syslog>
LogLevel warning LogLevel warning
</Plugin> </Plugin>
@ -23,25 +24,46 @@ LoadPlugin syslog
{% endif %} {% endif %}
</Plugin> </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 %} {% endif %}
{% if collectd_plugin_load is sameas true %} {% if collectd_plugin_load is sameas true %}
LoadPlugin load LoadPlugin load
{% endif %} {% 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 %} {% if collectd_plugin_processes is sameas true %}
LoadPlugin processes LoadPlugin processes
{% endif %} {% 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 %} {% if collectd_plugin_uptime is sameas true %}
LoadPlugin uptime LoadPlugin uptime
{% endif %} {% endif %}
{% if collectd_plugin_users is sameas true %} {% if collectd_plugin_users is sameas true %}
LoadPlugin users LoadPlugin users
{% endif %} {% endif %}
{% if collectd_plugin_pf is sameas true %}
LoadPlugin pf
{% endif %}
{% if collectd_plugin_df is sameas true %} {% if collectd_plugin_df is sameas true %}
LoadPlugin df
<Plugin df> <Plugin df>
# expose host's mounts into container using -v /:/host:ro (location inside container does not matter much) # 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 # ignore rootfs; else, the root file-system would appear twice, causing
@ -73,7 +95,6 @@ LoadPlugin df
{% endif %} {% endif %}
{% if collectd_plugin_disk is sameas true %} {% if collectd_plugin_disk is sameas true %}
LoadPlugin disk
<Plugin "disk"> <Plugin "disk">
#Disk "/^[hsv]d[a-z]/" #Disk "/^[hsv]d[a-z]/"
IgnoreSelected false IgnoreSelected false
@ -81,28 +102,24 @@ LoadPlugin disk
{% endif %} {% endif %}
{% if collectd_plugin_cpu is sameas true %} {% if collectd_plugin_cpu is sameas true %}
LoadPlugin cpu
<Plugin cpu> <Plugin cpu>
ValuesPercentage true ValuesPercentage true
</Plugin> </Plugin>
{% endif %} {% endif %}
{% if collectd_plugin_memory is sameas true %} {% if collectd_plugin_memory is sameas true %}
LoadPlugin memory
<Plugin memory> <Plugin memory>
ValuesPercentage true ValuesPercentage true
</Plugin> </Plugin>
{% endif %} {% endif %}
{% if collectd_plugin_swap is sameas true %} {% if collectd_plugin_swap is sameas true %}
LoadPlugin swap
<Plugin swap> <Plugin swap>
ValuesPercentage true ValuesPercentage true
</Plugin> </Plugin>
{% endif %} {% endif %}
{% if collectd_plugin_interface is sameas true %} {% if collectd_plugin_interface is sameas true %}
LoadPlugin interface
<Plugin interface> <Plugin interface>
Interface "/^lo[0-9]*/" Interface "/^lo[0-9]*/"
Interface "/^veth.*/" Interface "/^veth.*/"
@ -113,13 +130,12 @@ LoadPlugin interface
{% endif %} {% endif %}
{% if collectd_plugin_tcpconns is sameas true %} {% if collectd_plugin_tcpconns is sameas true %}
LoadPlugin tcpconns
<Plugin "tcpconns"> <Plugin "tcpconns">
AllPortsSummary true AllPortsSummary true
</Plugin> </Plugin>
{% endif %} {% endif %}
LoadPlugin network
<Plugin "network"> <Plugin "network">
Server "{{ collectd_server }}" "25826" <Server "{{ collectd_server }}" "25826">
</Server>
</Plugin> </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 /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 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/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 /sbin/bioctl sd2 as root from /
doas: _nrpe ran command /usr/local/libexec/nagios doas: _nrpe ran command /usr/local/libexec/nagios
doas: .* ran command su - as root from 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 # 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 # Don't try to run if it's already running
if [ -e "${_PIDFILE}" ]; then if [ -e "${_PIDFILE}" ]; then
date >> "${_TMPDIR}"/log echo "$(date)" >> "${_TMPDIR}"/log
exit 1 exit 1
else else
echo $$ >> "${_PIDFILE}" echo $$ >> "${_PIDFILE}"
@ -51,7 +51,7 @@ do
_STATUS=$(/usr/sbin/ospf6ctl show neighbor | grep "${_PEER} " | awk {'print $3'}) _STATUS=$(/usr/sbin/ospf6ctl show neighbor | grep "${_PEER} " | awk {'print $3'})
echo -n "${_PEER}" >> "${_TMPDIR}"/ospf6-status echo -n "${_PEER}" >> "${_TMPDIR}"/ospf6-status
echo -n " " >> "${_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" _STATUS="UP"
else else
_STATUS="DOWN" _STATUS="DOWN"
@ -103,6 +103,9 @@ fi
echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body
ospf6ctl show fib ospf >> "${_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 echo "\n\n*** Network used memory ***\n" >> "${_TMPMAILDIR}"/body
netstat -m >> "${_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 # 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 # Don't try to run if it's already running
if [ -e "${_PIDFILE}" ]; then if [ -e "${_PIDFILE}" ]; then
date >> "${_TMPDIR}"/log echo "$(date)" >> "${_TMPDIR}"/log
exit 1 exit 1
else else
echo $$ >> "${_PIDFILE}" echo $$ >> "${_PIDFILE}"
@ -51,7 +51,7 @@ do
_STATUS=$(/usr/sbin/ospfctl show neighbor | grep "${_PEER} " | awk {'print $3'}) _STATUS=$(/usr/sbin/ospfctl show neighbor | grep "${_PEER} " | awk {'print $3'})
echo -n "${_PEER}" >> "${_TMPDIR}"/ospf-status echo -n "${_PEER}" >> "${_TMPDIR}"/ospf-status
echo -n " " >> "${_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" _STATUS="UP"
else else
_STATUS="DOWN" _STATUS="DOWN"
@ -103,6 +103,9 @@ fi
echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body echo "\n\n*** Known OSPF routes ***\n" >> "${_TMPMAILDIR}"/body
ospfctl show fib ospf >> "${_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 echo "\n\n*** Network used memory ***\n" >> "${_TMPMAILDIR}"/body
netstat -m >> "${_TMPMAILDIR}"/body netstat -m >> "${_TMPMAILDIR}"/body