Skip to main content
8 votes

Loop to print changes in irrigation state to turn on and off a pump when water is low

Just curious, but have you checked CPU usage ? Programs that run in a while loop can be terribly inefficient and taxing. Here you are just probing a sensor, this does not look like a computationally-...
Kate's user avatar
  • 8,313
7 votes

Laptop battery level monitor for Linux

You could replace your get_str_from_file function with the standard read_to_string function: For instance like so: ...
Oliver's user avatar
  • 171
6 votes
Accepted

NRPE script for monitoring load average

This looks pretty good. Some suggestions: [[ is preferred over [ in Bash. This script could benefit from ...
l0b0's user avatar
  • 9,117
6 votes

Loop to print changes in irrigation state to turn on and off a pump when water is low

If I understand what you are trying to do, I think you can (1) remember the prior state, (2) print only on changes, and (3) select the message to print based on the new state. ...
FMc's user avatar
  • 13.1k
5 votes
Accepted

C# classes for system health metrics

A design pattern often used, is to have a non generic base type and a generic type derived from it or a type implementing a non generic as well as a generic interface. An example is ...
Olivier Jacot-Descombes's user avatar
5 votes

Log monitoring with pythonic tail -f and process killing

Using regex for such a simple task as finding if a line contains a string is not worth it. The built-in str.__contains__, being called by the keyword ...
Graipher's user avatar
  • 41.7k
5 votes

Python script for alerting disk usage and take action if needed

Overall not bad! You've managed to avoid many of the "usual suspects" when it comes to Python scripting practices. make_logger could use a return ...
Reinderien's user avatar
  • 71.1k
5 votes

Remotely collect server data using Net::OpenSSH

Looks good to me. Kudos for the "... or die" idiom. More informative output would be "unable to run df on $s" or "unable to run svmon on $s". You don't have to do ...
J_H's user avatar
  • 42.2k
4 votes

BASH script to monitor subprocess and throttle it for CPU temperature control

Although unrelated to the code, I'll mention that for a CPU to overheat, especially a dual-core CPU, is not usual except with very high ambient temps. I'd suggest removing the heat sink and re-...
Oh My Goodness's user avatar
4 votes
Accepted

Laptop battery level monitor for Linux

Unwrapping options is probably fine for this simple little app that only you’re using, but it dumps out a panic if the result is None. I like your use of ...
RubberDuck's user avatar
  • 31.2k
4 votes

Express.js functions to start session, authenticate user, perform ping, search for user, reset password, and import product XML

The general rule is that you should never incorporate user-controlled input into a string that will be interpreted by a computer system without escaping it first. Specifically, at a quick glance, it'...
200_success's user avatar
4 votes
Accepted

Loop to print changes in irrigation state to turn on and off a pump when water is low

I agree with @Anonymous that you should not loop continuously like that, or you'll waste energy and CPU time continuously checking the values. To solve this you can just sleep, wake up every minute, ...
Francesco Pasa's user avatar
3 votes
Accepted

Python script for alerting disk usage and take action if needed

First, some minor issues: logger is a global variable, and all your functions are completely dependent on it being present -- and if you ...
Sara J's user avatar
  • 4,221
3 votes

C# classes for system health metrics

I just have a couple of minor points to add to Olivier Jacot-Descombes' excellent answer. ...
Peter Taylor's user avatar
  • 24.5k
3 votes

NRPE script for monitoring load average

I’d agree with all of l0b0’s answer – including the suggestion of using grep to process /proc/cpuinfo. An alternate way to count ...
Anthony Geoghegan's user avatar
3 votes

Bash script to send notifications when low on ram

Kudos to you! This is a nice little script, easy to read and to understand. However, there is no reason to reach for expr. Most shells (including ...
Zeta's user avatar
  • 19.7k
3 votes

Send a tweet to ISP when internet speed drops

Let me add improvement, in regard that has already been added in other comments: Use the out-of-box Python logger package instead of writing own one Totally agree with @grajdeanu-alex about a ...
DenisOgr's user avatar
  • 159
3 votes
Accepted

Multithreaded C program to calculate CPU usage of cgroups

Global Variables I see this comment just prior to the declarations for the global variables: //TODO: localize? My answer would be yes. It is very difficult to read,...
pacmaninbw's user avatar
  • 26.1k
3 votes
Accepted

Python script which sends telegram message if Raspberry Pi's temperature crosses 60 °C

chatId -> chat_id and similar for other members and method names, by PEP8 standard ...
Reinderien's user avatar
  • 71.1k
2 votes

Automatic ping check program

Note: Bear in mind that you are relying on the OS's ability to correctly calculate packet loss. (Please see: https://networkengineering.stackexchange.com/questions/30940/difference-between-ping-timed-...
K McCabe's user avatar
2 votes

Check SMART status on MacOS and pop up alert

Some suggestions: A direct string comparison test may be flaky especially if the string contains multiple space characters. I can think of three alternatives: Use regex matching: this can be achieved ...
Gao's user avatar
  • 1,230
2 votes

A website status monitor in Python/Flask

This looks like a very good status page. Well done ! Review from settings import refresh_interval, filename, site_down I recommend that you use set of config ...
JaDogg's user avatar
  • 4,561
2 votes

Log monitoring with pythonic tail -f and process killing

... about making this class based, but it really doesn't make sense to do it ... I'd not agree with that, because: same arguments filename/f and ...
RomanPerekhrest's user avatar
2 votes
Accepted

NRPE script for monitoring memory usage

I don't understand why it should be a warning to have over 80% of the system RAM available. If anything needs a warning, it should be having under 20% of RAM available, right? Reading each line into ...
200_success's user avatar
2 votes
Accepted

Online check with retry logic and anti-flapping

If, as you say in your comments, everything is more or less a single main() function, I would start by splitting things up to make reasonning about each part (and ...
301_Moved_Permanently's user avatar
1 vote
Accepted

Program to continuously check availability of internet connection c#

You probably want to avoid using recursion on conn. Say you did not have internet connection for a long time. Then, for every failed connection you will add a new ...
Miguel Alorda's user avatar
1 vote

Log monitoring with pythonic tail -f and process killing

Here is my contribution. You should not make the while True loop, instead of that you should use inotify in order to been notify only when changes happen on the file that you are monitoring, here is ...
camp0's user avatar
  • 865
1 vote
Accepted

HTTP status monitoring

Not a full review, but several issues pop up at a quick scan: Avoid panic, it's meant for reporting a bug in the program (e.g. dividing by zero, failing a bounds ...
Dave C's user avatar
  • 560
1 vote
Accepted

Application to monitor device power levels for deviations

I'll also begin with the low hanging fruit mentioned by Mateusz Konieczny. PEP8/pylint/etc. your code. It is decently formatted, but there are some issues. Before even considering optimizing ...
Bailey Parker's user avatar
1 vote

Bash script to send notifications when low on ram

I like the script. But I have maybe some suggestions for improvement. This part: ...
David Mosler's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible