diff --git a/nagios/php_syntax_check.sh b/nagios/php_syntax_check.sh
deleted file mode 100755
index b6dd7d29141267291186fb885f6544c7bafe9227..0000000000000000000000000000000000000000
--- a/nagios/php_syntax_check.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-#The root directory to check
-dir="/etc/simplesamlphp"
-
-cd $dir
-
-paths=$(find . -type f -name "*.php")
-globalResult=""
-
-for path in $paths
-do
-    if [[ -f $path ]] ; then
-        result=$(php -l $path 2>&1)
-        if [[ ! $result =~ ^No.syntax.errors.*$ ]] ; then
-            globalResult+="$result  |  "
-        fi
-    fi
-done
-
-if [[ -z $globalResult ]] ; then
-    echo "0 php_syntax_check - OK"
-else
-    echo "2 php_syntax_check - $globalResult"
-fi
diff --git a/perun/proxy/utils/nagios/check_php_syntax.py b/perun/proxy/utils/nagios/check_php_syntax.py
new file mode 100755
index 0000000000000000000000000000000000000000..56d0efe0c1202cde1c027995c44be490b22992ce
--- /dev/null
+++ b/perun/proxy/utils/nagios/check_php_syntax.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+import argparse
+
+
+# nagios return codes
+UNKNOWN = -1
+OK = 0
+WARNING = 1
+CRITICAL = 2
+
+
+def get_args():
+    parser = argparse.ArgumentParser(
+        description=(
+            "Checks whether PHP files have valid syntax, primarily used for checking"
+            " automatically generated files"
+        )
+    )
+    parser.add_argument(
+        "-d",
+        "--directory",
+        required=True,
+        help="path which will be scanned for PHP files, including subdirectories",
+    )
+    return parser.parse_args()
+
+
+def main():
+    dir = get_args().directory
+    os.chdir(dir)
+    paths = []
+    for (
+        dirpath,
+        dirname,
+        filenames,
+    ) in os.walk("."):
+        for f in filenames:
+            if f.endswith(".php"):
+                paths.append(
+                    os.path.join(
+                        dirpath,
+                        f,
+                    )
+                )
+    global_result = ""
+
+    for path in paths:
+        if os.path.isfile(path):
+            result = subprocess.getoutput(f"php -l {path}")
+            if not result.startswith("No syntax errors"):
+                global_result += f"{result}  |  "
+
+    if not global_result:
+        print(f"{OK} check_php_syntax - OK")
+        sys.exit(OK)
+    else:
+        print(f"{CRITICAL} check_php_syntax - {global_result}")
+        sys.exit(CRITICAL)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/setup.py b/setup.py
index 7339cde4415ecd2a8477e44f8029008a5bde6290..7bf8c55d2929928e6de870dcef805bced0842ffa 100644
--- a/setup.py
+++ b/setup.py
@@ -37,6 +37,7 @@ setuptools.setup(
             "check_rpc_status=perun.proxy.utils.nagios.check_rpc_status:main",
             "check_saml=perun.proxy.utils.nagios.check_saml:main",
             "check_user_logins=perun.proxy.utils.nagios.check_user_logins:main",
+            "check_php_syntax=perun.proxy.utils.nagios.check_php_syntax:main",
             "check_webserver_availability="
             "perun.proxy.utils.nagios.webserver_availability:main",
             "metadata_expiration=perun.proxy.utils.metadata_expiration:main",