Network Infrastructure Monitoring

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
MarceldeJongNL
Posts: 43
Joined: Tuesday 03 May 2016 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5108
Location: Barendrecht
Contact:

Network Infrastructure Monitoring

Post by MarceldeJongNL »

I was looking to manage my home network and to be notified for any outages. I have been looking at tools like OpenNMS, Cacti etc but I found them all to be quite complex for my needs. So I decided to try and use my Domoticz set for this purpose and have build the following config:


Internet Connection Monitoring.

Set-up the script defined here: viewtopic.php?f=28&t=11970
This provides me with ping time and current upload and download speed.


Ping Devices:
For every device I wanted to measure I made a Custom Sensor, value ms (milliseconds)
Created a standard script:

Ping.sh

Code: Select all

host=$1
count=$2
idx=$3
name=$4
domoticz=127.0.0.1

value=`ping -c $count $host | awk -F '/' 'END {print $5}'`
echo "$4 $value"
curl "$domoticz:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&sval$
Create a scheduled script:

In the Vars section I put all the devices I wanted to check.
syntax is “IP-address #of pings VirtualSwitch Description”
There is some logging in /home/pi/domoticz/scripts/pingall.log, used for troubleshooting

pingall.sh

Code: Select all

echo start >> /home/pi/domoticz/scripts/pingall.log
date >> /home/pi/domoticz/scripts/pingall.log

vars=(
"192.168.0.1 3 773 Ziggo"
"192.168.1.254 3 774 Linksys"
"192.168.1.253 3 775 Synology"
"192.168.1.175 3 776 ESX"
"192.168.1.13 3 778 Exchange"
"192.168.1.12 3 779 DC"
"192.168.1.14 3 780 Mailcleaner"
"192.168.1.133 3 782 Resol"
"192.168.1.199 3 783 Synology2"
"192.168.1.119 3 784 RP-AC52"
)

echo $vars >> /home/pi/domoticz/scripts/pingall.log
for v in "${vars[@]}";

do
echo $v  >> /home/pi/domoticz/scripts/pingall.log
/home/pi/domoticz/scripts/ping.sh $v  >> /home/pi/domoticz/scripts/pingall.log;

done

#date >> /home/pi/domoticz/scripts/pingall.log
echo done >> /home/pi/domoticz/scripts/pingall.log
Check open ports:

To check if applications are functioning I decided to check if the TCP ports are open. I use nmap for this. If it’s not available, you can install it via apt:
sudo apt-get install nmap

Created a standard script:

nmap.sh

Code: Select all

host=$1
port=$2
idx=$3
name=$4
domoticz=127.0.0.1
value=

value=`nmap $host -p $port | grep closed`
echo "$4 $value"
if  [ -n "$value" ]
then echo "port closed"
curl "$domoticz:8080/json.htm?type=command&param=switchlight&idx=$idx&switchcmd=Off"
##echo "$domoticz:8080/json.htm?type=command&param=switchlight&idx=$idx&&switchcmd=Off"
else echo "port open"
curl "$domoticz:8080/json.htm?type=command&param=switchlight&idx=$idx&switchcmd=On"
fi
Created a scheduled script:
In the Vars section I put all the devices and Ports I wanted to check.
syntax is “IP-address Port# VirtualSwitch Description”
Description is not used, only for my own reference.

There is some logging in /home/pi/domoticz/scripts/nmapall.log, used for troubleshooting

nmapall.sh

Code: Select all

echo start >> /home/pi/domoticz/scripts/nmapall.log
date >> /home/pi/domoticz/scripts/nmapall.log

vars=(
"192.168.0.1 80 786 Ziggo HTTP"
"192.168.0.1 443 787 Ziggo HTTPS"
"192.168.0.1 2602 788 Ziggo RIPD"
"192.168.1.254 5000 790 Linksys UPNP"
"192.168.1.254 5000 789 Linksys HTTP"
"192.168.1.253 22 791 Synology SSH"
"192.168.1.253 25 792 Synology SMTP"
"192.168.1.253 53 785 Synology DNS"
"192.168.1.253 80 793 Synology HTTP"
"192.168.1.253 443 794 Synology HTTPS"
"192.168.1.253 5000 795 Synology DSM"
"192.168.1.253 5001 796 Synology DSM-s"
"192.168.1.175 22 798 ESX SSH"
"192.168.1.175 443 797 ESX HTTPS"
"192.168.1.13 25 799 Exchange SMTP"
"192.168.1.13 80 800 Exchange HTTP"
"192.168.1.13 443 801 Exchange HTTPS"
"192.168.1.13 3389 802 Exchange RDP"
"192.168.1.12 53 803 DC DNS"
"192.168.1.12 389 804 DC LDAP"
"192.168.1.12 88 805 DC Kerb"
"192.168.1.12 139 806 DC Netbios"
"192.168.1.14 22 807 Mailcleaner SSH"
"192.168.1.14 25 808 Mailcleaner SMTP"
"192.168.1.14 80 809 Mailcleaner HTTP"
"192.168.1.133 80 810 Resol HTTP"
"192.168.1.199 22 811 Synology2 SSH"
"192.168.1.199 80 812 Synology2 HTTP"
"192.168.1.199 443 813 Synology2 HTTPS"
"192.168.1.199 139 814 Synology2 NetBios"
"192.168.1.199 548 815 Synology2 AFP"
"192.168.1.199 5000 816 Synology2 DSM"
"192.168.1.199 5001 817 Synology2 DSM-s"
"192.168.1.119 80 818 RP-AC52 HTTP"
)

for v in "${vars[@]}";

do
echo $v  >> /home/pi/domoticz/scripts/nmapall.log
/home/pi/domoticz/scripts/nmap.sh $v  >> /home/pi/domoticz/scripts/nmapall.log;

done

#date >> /home/pi/domoticz/scripts/pingall.log
echo done >> /home/pi/domoticz/scripts/nmapall.log


Scheduled the scripts via crontab:

Code: Select all

55 * * * * /home/pi/domoticz/scripts/speedtest.sh
*/2 * * * * bash -l /home/pi/domoticz/scripts/pingall.sh
*/10 * * * * bash -l /home/pi/domoticz/scripts/nmapall.sh 


I created a nice image for the the floorplan, added the created Switches and Sensors. Also the Standard Motherboard Monitors for my Pi and now I have the following overview of my network:
marceldejong_kls39.jpg
marceldejong_kls39.jpg (105 KiB) Viewed 10531 times

I can use the logging to see when there was anything wrong with a device, like this example when my Linksys router was acting up.
chart.jpeg
chart.jpeg (32.89 KiB) Viewed 10531 times
Let me know what you think and if you have any suggestions!
Last edited by MarceldeJongNL on Monday 26 September 2016 15:26, edited 1 time in total.
Hardware: Raspberry Pi 2B | RFXCOM RFXtrx433E v1 | Synology DS213+ | KaKu Clones | Conrad RSL switches | KAKu Doorbell Clone | USB Webcam | ICY Thermostat | Resol DL2 | Imatic Relay Board | Eminent 6230 | Eminent 6220 | iMatic 16 ports Relay Board
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Networking Infrastructure Monitoring

Post by emme »

:o :o :o
will do the same as soon as I can!!! :lol: :lol: :lol:
The most dangerous phrase in any language is:
"We always done this way"
zeputt
Posts: 5
Joined: Thursday 02 July 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: zelatest
Location: Surahammar/Sweden
Contact:

Re: Networking Infrastructure Monitoring

Post by zeputt »

:shock: Nice!
Looks really good and a breeze to administrate if you know your way around in Domoticz.
I will have to make a setup for my own net - thanks for sharing!!
MarceldeJongNL
Posts: 43
Joined: Tuesday 03 May 2016 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5108
Location: Barendrecht
Contact:

Re: Networking Infrastructure Monitoring

Post by MarceldeJongNL »

Thanks, if you make something nice, please share!
Hardware: Raspberry Pi 2B | RFXCOM RFXtrx433E v1 | Synology DS213+ | KaKu Clones | Conrad RSL switches | KAKu Doorbell Clone | USB Webcam | ICY Thermostat | Resol DL2 | Imatic Relay Board | Eminent 6230 | Eminent 6220 | iMatic 16 ports Relay Board
franzelare
Posts: 139
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Network Infrastructure Monitoring

Post by franzelare »

sweet!

this is added to my todo list!
likely with the addition to send out alarm emails to me when times are outside normal values 3 sigma limits or so...
franzelare
Posts: 139
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Network Infrastructure Monitoring

Post by franzelare »

MarceldeJongNL wrote: Ping Devices:
For every device I wanted to measure I made a Custom Sensor, value ms (milliseconds)
what kind of sensor did you use? or how did you create it?
because if i use a counter, the values are all noted in full numbers and the ms from the ping are not correctly displayed in domoticz
franzelare
Posts: 139
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Network Infrastructure Monitoring

Post by franzelare »

fixed it by using a counter and multiply the ping result with 1000 to convert to ms before sending it to domoticz
MarceldeJongNL
Posts: 43
Joined: Tuesday 03 May 2016 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5108
Location: Barendrecht
Contact:

Re: Network Infrastructure Monitoring

Post by MarceldeJongNL »

franzelare wrote: what kind of sensor did you use? or how did you create it?
because if i use a counter, the values are all noted in full numbers and the ms from the ping are not correctly displayed in domoticz
I just use a "custom" sensor, and label it "ms"
My values are noted in *.*** ms
Hardware: Raspberry Pi 2B | RFXCOM RFXtrx433E v1 | Synology DS213+ | KaKu Clones | Conrad RSL switches | KAKu Doorbell Clone | USB Webcam | ICY Thermostat | Resol DL2 | Imatic Relay Board | Eminent 6230 | Eminent 6220 | iMatic 16 ports Relay Board
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Network Infrastructure Monitoring

Post by Derik »

Great stuff!!!
Real you all make my days to sort.....
This one is on my bucket list..

What do you have for other options whit this option
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
MarceldeJongNL
Posts: 43
Joined: Tuesday 03 May 2016 10:07
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5108
Location: Barendrecht
Contact:

Re: Network Infrastructure Monitoring

Post by MarceldeJongNL »

Found a little issue with nmap.sh.
If a host is down, nmap will report that instead of using the word closed. So I changed the grep to:

Code: Select all

value=`nmap $host -p $port -Pn | grep 'closed\|down\|filtered'`
so now the light icons for the ports go out if the host is down

Also changed ping.sh to

Code: Select all


host=$1
count=$2
idx=$3
name=$4
domoticz=127.0.0.1

value=`ping -c $count $host | awk -F '/' 'END {print $5}'`
echo "$4 $value"
 if [ $value = ""]; then
               value=99999
            fi
curl "$domoticz:8080/json.htm?type=command&param=udevice&idx=$idx&nvalue=0&svalue=$value


This will set the ping counter to 99999ms if the host is down. Makes it easier to send alarm if the value is higher than ......
Hardware: Raspberry Pi 2B | RFXCOM RFXtrx433E v1 | Synology DS213+ | KaKu Clones | Conrad RSL switches | KAKu Doorbell Clone | USB Webcam | ICY Thermostat | Resol DL2 | Imatic Relay Board | Eminent 6230 | Eminent 6220 | iMatic 16 ports Relay Board
dutchdevil83
Posts: 130
Joined: Monday 31 October 2016 19:34
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Netherlands
Contact:

Re: Network Infrastructure Monitoring

Post by dutchdevil83 »

Thanx for sharing this.

Going to use this for my systemcontrol page!
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
franzelare
Posts: 139
Joined: Thursday 19 February 2015 21:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Network Infrastructure Monitoring

Post by franzelare »

I added my versions of the script and more network monitoring in this topic:
viewtopic.php?f=23&t=15553

I'm also runing uptime counters and device on timers
dutchdevil83
Posts: 130
Joined: Monday 31 October 2016 19:34
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Netherlands
Contact:

Re: Network Infrastructure Monitoring

Post by dutchdevil83 »

I`m getting following error when running pingall.sh

Code: Select all

pi@raspberrypi:~/domoticz/scripts $ sh pingall.sh
: not found 3: pingall.sh:
pingall.sh: 4: pingall.sh: Syntax error: "(" unexpected
My scriptfile is looking like this:

Code: Select all

echo start >> /home/pi/domoticz/scripts/pingall.log
date >> /home/pi/domoticz/scripts/pingall.log

vars=(
"192.168.192.1 3 602 Ping Ziggo"
"192.168.192.6 3 603 Ping Camera"
)


echo $vars >> /home/pi/domoticz/scripts/pingall.log
for v in "${vars[@]}";

do
echo $v  >> /home/pi/domoticz/scripts/pingall.log
/home/pi/domoticz/scripts/ping.sh $v  >> /home/pi/domoticz/scripts/pingall.log;

done

#date >> /home/pi/domoticz/scripts/pingall.log
echo done >> /home/pi/domoticz/scripts/pingall.log
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
dutchdevil83
Posts: 130
Joined: Monday 31 October 2016 19:34
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Netherlands
Contact:

Re: Network Infrastructure Monitoring

Post by dutchdevil83 »

ok found the error. Added bin/bash to script and ran it as bash script and it works now. The ping.sh has to be edited for use with domoticz. The script wasn`t working for me. This one worked for me:

Code: Select all

#!/bin/bash
host=$1
count=$2
idx=$3
name=$4
domoticz=127.0.0.1
port=8080

value=`ping -c $count $host | awk -F '/' 'END {print $5}'`

#output if you run it manually
printf "$4 ping = $ping ms"

curl -s -i -H "Accept: application/json" "http://$domoticz:$port/json.htm?type=command&param=udevice&idx=$idx&svalue=$value"
Hardware
1x Raspberry Pi
1x Razberry Z-Wave
1x RFXtrx433E
1x Toon
1x GoodWe Solarpanels
2x FGSD-002 Smoke Detector
1x FGBS-001 Binaire Sensor (RFID lezer)
7x FGMS-001 Motion Sensor
3x ZW089 Verzonken Deursensor
7x NC Wallplug
&lots of KaKu stuff
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: Network Infrastructure Monitoring

Post by felix63 »

MarceldeJongNL wrote:I was looking to manage my home network and to be notified for any outages. I have been looking at tools like OpenNMS, Cacti etc but I found them all to be quite complex for my needs.
Let me know what you think and if you have any suggestions!
Great.. spend an evening but now its up an running. Thanks!
rickwilleme
Posts: 53
Joined: Wednesday 16 December 2015 15:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.6792
Location: Landgraaf, The Netherlands
Contact:

Re: Network Infrastructure Monitoring

Post by rickwilleme »

Hmm.. Definitely worth adding to Domoticz. Thanks for the inspiration!
Raspberry Pi ~ Fibaro Dimmer (Z-Wave) ~ Several KAKU switches and dimmers (433 MHz) ~ Amazon Echo ~ Somfy RTS ~ Sony TV ~ Kodi/XBMC ~ Essent E-Thermostaat (ICY) ~ Cresta thermostat ~ Wundermap Weather ~ Smoke detectors
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest