File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 66from prometheus_client import make_wsgi_app , Gauge
77from flask import Flask
88from waitress import serve
9+ from shutil import which
910
1011app = Flask ("Speedtest-Exporter" ) # Create flask app
1112
@@ -132,7 +133,23 @@ def mainPage():
132133 "Click <a href='/metrics'>here</a> to see metrics." )
133134
134135
136+ def checkForBinary ():
137+ if which ("speedtest" ) is None :
138+ logging .error ("Speedtest CLI binary not found. Please install it by" +
139+ " going to the official website.\n " +
140+ "https://www.speedtest.net/apps/cli" )
141+ exit (1 )
142+ speedtestVersionDialog = (subprocess .run (['speedtest' , '--version' ],
143+ capture_output = True , text = True ))
144+ if "Speedtest by Ookla" not in speedtestVersionDialog .stdout :
145+ logging .error ("Speedtest CLI that is installed is not the official" +
146+ " one. Please install it by going to the official" +
147+ " website.\n https://www.speedtest.net/apps/cli" )
148+ exit (1 )
149+
150+
135151if __name__ == '__main__' :
152+ checkForBinary ()
136153 PORT = os .getenv ('SPEEDTEST_PORT' , 9798 )
137154 logging .info ("Starting Speedtest-Exporter on http://localhost:" +
138155 str (PORT ))
You can’t perform that action at this time.
0 commit comments