surveillance: scripts inutiles
This commit is contained in:
parent
76b57fbe1a
commit
6e8991239b
2 changed files with 0 additions and 78 deletions
|
@ -1,25 +0,0 @@
|
||||||
#!/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
|
|
|
@ -1,53 +0,0 @@
|
||||||
#! /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'
|
|
Loading…
Add table
Add a link
Reference in a new issue