📜 ⬆️ ⬇️

Mikrotik guarding temperature

Hello, Hello!

Prehistory

A small plant, a small server (2x4 meters), a park of rack servers, storage, UPS. Air conditioning that works around the clock / year-round.
')
Peace, labor, May 1, 7 am, bell from the factory, security: “The fire alarm in the server room worked, the door was hot, there was no burning smell.” I give instructions for further actions: “Arming with a fire extinguisher standing next to us, open the door, go.” On the way, the bell rang: “The door was opened, nothing burns hot there.” I said: “Leave the door open.”

30 minutes after the first call, I’m near the server room. Really hot. Servers are unpleasantly noisy with coolers. Air conditioning is off. Switch off the air conditioner, wait, turn back, "peak", but not cold. We call the air conditioner serving our organization, check the gas pressure in the air conditioner, there is gas but the pressure is small, we add gas, it cools. We close the door, wait, go, cool, the server is pleasantly noisy with coolers. We agree on finding a leak. Disagree. Barbecue. May 1, labor. world.

Further under cat.

Task

Monitoring the temperature in the server.

1. Any kind of additional sensors, with notifications anywhere.
There is an organization that is engaged in our fire and all kinds of alarm at the factory, could not offer anything intelligible.
2. Forced ventilation, with valves, fan filters.
The server's location is such that without a project and connecting to this case a different type of service there is no way to do it. Of course, there is a possibility, but the desires of these services are reduced to zero. "Do it yourself."
3. Sensors in the existing gland.
This stopped for the sake of a monitoring test and at least some kind of warning.

Decoupling

In the server a lot of bitty iron. And they all contain sensors, that's a fact. But the choice fell on Mikrotik RouterBoard 2011UAS-RM. I will explain why.

1. He is the first who blows air conditioning.
2. He does not have his own cooler.
3. The presence of a temperature sensor.
4. Located at the top of the rack.
5. Linux.
6. Own scripting language.
7. The presence of balls SMB.
8. The ability to send e-mail, SMS do not use.

All you need to do is check its temperature. Notify by mail. Notify the security post. If the temperature exceeds the desired value.

Tutorial

1. On Mikrotik, there is an Internet. Sending an e-mail is configured as it should and works.
2. We write a script to check the temperature and send readings to the e-mail.

:global temp1 :set temp1 30 :global temp2 [/system health get temperature] :if ($temp2 > $temp1) do= {/tool e-mail send to=email@email.ru subject=Warning_Temperature body="Warning!!! Room temperature - $temp2 Degrees"} 


Let us consider :global temp1 variable for temperature threshold :set temp1 30 temperature threshold :global temp2 [/system health get temperature] get the temperature and put it into a variable :if ($temp2 > $temp1) do= {/tool e-mail send to=email@email.ru subject=Warning_Temperature body="Warning!!! Room temperature - $temp2 Degrees"} here everything is simple if the received temperature above the threshold send a notification to the mail. Variables global for other scripts.

Data script in Scheduler with the execution of once every 30 minutes, and although the time as you want.

3. Alert security at the post. Since the server and security post on different floors, but the network is one. And at the post is a large TV with cameras connected to the Windows machine.

So:

Turn on the ball in Mikrotik / ip smb. Create a user, give access to // mikrotik / pub.
We write a script.

 :global t :set t 1 :global f :set f 0 /file set pub/temp.txt contents=$f :if ($temp2 > $temp1) do= {/file set pub/temp.txt contents=$t} 


We will analyze. Variable for bad temperature :global t assign variable to variable :set t 1 variable for good temperature :global f :set t 0 variable to zero :set t 0 write to pub / temp.txt file “0” /file set pub/temp.txt contents=$f check the temperature :if ($temp2 > $temp1) do= {/file set pub/temp.txt contents=$t} if the temperature is above normal in the pub / temp.txt 0 file, change to 1.

Data script in Scheduler with the execution of once every 30 minutes, and although the time as you want.

4. Alert Windows Machines at the guard post.

All you need is to periodically read the file //mikrotik/pub/temp.txt. If the file 0 does nothing, and if 1 then the screen (TV in my case) to output in red letters WARNING and other information that will be useful in solving the problem. This program can safely write at least something. At hand was Delphi on it and wrote.

Yes, you say the collective farm and all that, but so far such a decision. While the security did not have to bother.

Source: https://habr.com/ru/post/327984/


All Articles