Commit 6e899123 authored by Daniel STAN's avatar Daniel STAN

surveillance: scripts inutiles

parent 76b57fbe
#!/bin/bash
#
# $Id: monit-ovh,v 1.1 2007/05/26 01:17:37 dimino Exp $
#
# Récupère la sortie du monit status sur ovh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=$(basename $0)
SERVER=vert
PORT=5000
PIDFILE=/var/run/$NAME.pid
if [ -f $PIDFILE ]; then
echo "error: $NAME already running."
exit 1
fi
echo $$ > $PIDFILE
while true; do
nc -l -p $PORT -s $SERVER.adm.crans.org ovh.adm.crans.org > /tmp/$NAME
cat /tmp/$NAME > /usr/scripts/monit/status/ovh
sleep 30
done
#! /usr/bin/env python
# -*- coding: utf-8 -*-
###########################
# Import des commmandes : #
###########################
import commands
import sys
import psycopg2
sys.path.append('/usr/scripts/gestion')
from config import upload, virus, p2p
import smtplib
from ldap_crans import crans_ldap
from time import *
sys.path.append('/usr/scripts/')
import cranslib.deprecated
cranslib.deprecated.module()
sys.path.pop()
# Connections :
###############
pgsql = psycopg2.connect(database='filtrage', user='crans')
pgsql.set_session(autocommit=True)
mail = smtplib.SMTP('localhost')
ldap = crans_ldap()
curseur=pgsql.cursor()
requete="SELECT ip_crans FROM avertis_virus"
curseur.execute(requete)
virus=curseur.fetchall()
for i in range(0,len(virus)) :
IP=virus[i][0]
print IP
requete="SELECT COUNT(ip_src) from virus where ip_src='%s' and date > timestamp 'now' - interval '1 hour'"%IP
curseur.execute(requete)
resultv=curseur.fetchall()
requete="SELECT COUNT(ip_src) from flood where ip_src='%s' and date > timestamp 'now' - interval '1 hour'"%IP
curseur.execute(requete)
resultf=curseur.fetchall()
machine = ldap.search('ipHostNumber=%s' % IP,'w' )['machine'][0]
hostname=machine.nom()
proprio=machine.proprietaire()
bl=proprio.blacklist()
for ligne in bl:
if '-,virus,' in ligne:
print hostname,resultv[0][0],resultf[0][0],ligne
break
#else :
# print hostname,resultv[0][0],resultf[0][0],'PAS DE BL'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment