Skip to content

Instantly share code, notes, and snippets.

@Aricg
Last active December 16, 2015 06:19
Show Gist options
  • Select an option

  • Save Aricg/5390537 to your computer and use it in GitHub Desktop.

Select an option

Save Aricg/5390537 to your computer and use it in GitHub Desktop.
tails a log and if certain stings are found it prints all but the first four parts of the line.
#!/usr/bin/python
from sh import tail
import string
for line in tail("-fn0", "/tmp/alert", _iter=True):
if ("PASSIVE" and "OK") in line:
nagios_alerts = line.split(" ")
print repr(nagios_alerts[4:])
print(len(nagios_alerts[4:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment