I’m creating a monitoring website that monitors servers of different customer locations using google maps API. Using MVC5 ASP.net.
About my customers
There are multiple customerlocations. Each customer location is represented by a dot. If there are no issues on the servers the dot is green. When there is a problem on the server, the dot turns red. Pretty simple so far. Every 5 minutes I receive datapackages from each customerlocation, giving me information about the servers on that customerlocation. Using that information I can update the customerlocation on my google maps infowindows above.
Each customerlocation has 4 type servers which are displayed in a google maps markerpopup, showing the status of the servers on that location(see image above)
How do I get the data?
Every customerlocation sends me a datapackage every 5 minutes with information about their servers. This package contains multiple objects. Each object represents 1 server and each package can contain up to 1-20 objects. This is what 1 object looks like:
[
{
"CameraStatus": "1"
"HasCamera": true,
"LocationName": "MON",
"ServerType": "L1",
"Status": true,
}
//... about 1-20 of these objects for each package, each representing a server.
L1 means that it is a locationserver. Status = true, means that the location server is running. HasCamera means the server has a camera, and the status of that camera is 1 which means it’s also working.
These are a few possible values from the objects I recieve(if this is any helpful):
CameraStatus : "1" // 1 = Online, 0 = No screen, -1 = Off, -2 = No Power
HasCamera : true // true = This server has a camera, false = no camera
LocationName : "MON" // "MON" = this package is from Mondaline (Customerlocation)
ServerType : "L1" // "C1" / "ST1" / "SK1" // LocationServer/CameraServer/etc..
Status : true // Server is on
My goalNow I have to find a way to update the customlocations on my google maps based on this data. Doing this, I have to keep the following requirements in mind:
– If there is one or more problem(s) detected on a server the markercolor changes to red, and the info window on the marker shows which servers are OFF like this:
– If there are no problems detected the google maps infowindow just shows some information about the location- If a server has a camera(HasCamera=True) then CameraStatus has to be checked. If HasCamera = false, CameraStatus can be ignored.-If HasCamera = true and CameraStatus = -2, -1 or 0 the CameraServer should show OFF on the overview.
How I tried doing it:
My code: https://pastebin.com/5rZhqMui (you might wanna copy it in your visualstudio because this is unreadable)
-
First of all I check from which location the object is from with “LocationName” value.
-
Then ServerType has to be checked, to find out is it a Location server, Camera server, Stitch server, or SalesKiosk Server?
-
If it’s a camera server, I have to check CameraStatus value as well.
While checking these servers I set the corresponding values to OFF for the servers that are not working and the marker to red. Eventually I ended up with a whole bunch of spaghetti and if functions. At 1 point I ended up making an array for every server and each location like this. MonCArray = [], MonLArray = [], MonSTArray [], MonSKArray[], filling it up with all the Status values.
This made it work for the most part, but whenever location A shows which servers are down and location B updates their location, Location A turn back to green, because the arrays get overwritten.that’s my problem now and also the point I want to give up.
I really hope someone could take their time and help me with this problem, or give me some ideas. Because I spend a lot of days and tried really hard making this and I just can’t get it to work.
I’m a beginner and this is overwhelming for me. Please help! thanks. if there are any questions, I answer you immediatly, you can also PM me if you want.