Category: Python

p

Install and setup Haystack search for Django

So Mysql is crap at doing full text search. So in one of my projects i use Haystack so i can do full text searches. I have a running Django project up and this is how I setup haystack for my project.   Install and config sudo pip install django-haystack   in settings.py under INSTALLED_APPS add haystack ‘haystack’,   And… Read more →

Python ConfigParser using you own config files in python

Storing settings in config files and then let python read the configfiles and to good stuff .   Read the file #Reading config file config = ConfigParser.ConfigParser() config.read(‘setting.cfg’) print all items and values in an section for name, value in config.items(“monitor”): print ‘ %s = %s’ % (name, value) Print all items in configfile for section_name in parser.sections(): print ‘Section:’,… Read more →

How the HELL is oncall ? (the oncall reminder script)

When you have oncall often sometimes is easy to forget hows oncall and when you are not. So for the last time wonder how is oncall and ask some python for some help,   The script #!/usr/bin/env python # # Mattias Hemmingsson # matte@elino.se # # Script for reminder friend when to bet # Uses and csv file and send… Read more →

restrict sms in nagios / icinga

Im using nagios as primary monitoring tool. And to get alerts we use an sms gateway. The problem is that sometimes when we work we bring down and server and we get so many sms from icinga that you trow away you phone. So for bringing the sms cost down and to have not so many sms to you phone… Read more →

Django sending email

building and small webpage and in that page I want an small contact field. So my visitors (if any ) can contact me with an form input. So I made an small html template that has a very small form (No validation ) and then post the email and massages back to the view that send the email. small and simple and today work… Read more →

Testing OSSEC / Syslog auth

Im runing and PCI DSS Level 1 system. And during our PCI Audit i have to provide evidence that our monitoring system (OSSEC) can log logins that fails. So or testing this and to provide evidence for our audit I made a small python script. the Scripts tries to login to th host specified in and text field and tries… Read more →

DNS Verify new ns servers

The dns tester scripot lets you check so that you dns name are correct checking first used names today and then verify the names with you new DNS server. You will need an file of you doman names first to run in the script.   #!/usr/bin/env python import socket import dns.resolver #v=”yes” g_dns=”88.80.170.189″ o_dns=”81.201.209.55″ def test_dns(name,typ,v): print “===================================================================” try: answers… Read more →

%d bloggers like this: