Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added logsize script #9

Closed
wants to merge 1 commit into from

2 participants

@andre-d

Forgot to pull req this

@spladug
Owner

Traffic's becoming AMQPized, so this will no longer be needed. Thanks :(

@spladug spladug closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 30, 2012
  1. @andre-d

    Added logsize script

    andre-d authored
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 0 deletions.
  1. +26 −0 logsize.py
View
26 logsize.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import os
+import sys
+import alerts
+
+def monitor_logdir(path, tag, threshold):
+ tag = "monitor_{%s}" % tag
+
+ num_files = len(os.listdir(path))
+
+ if num_files > threshold:
+ alerts.harold.alert(tag, "%s has too many files [%d/%d]" % (path, num_files, threshold))
+
+def main():
+ # Usage is: logsize.py 10 some_logs /var/logs/somelogs
+ # 10 - Max number of files before alert
+ # some_logs - Tag used for harold
+ # /var/logs/somelogs - Folder in which to look for files
+ threshold = int(sys.argv[1])
+ tag = sys.argv[2]
+ path = sys.argv[3]
+ monitor_logdir(path, tag, threshold)
+
+if __name__ == "__main__":
+ main()
Something went wrong with that request. Please try again.