je recherche un logiciel libre permettant d'envoyer une alerte mail quand un certain espace disque restant est atteint.
Le système utilisé est du windows (différents types).
Merci d'avance de vos réponses
-
Ws
- Messages : 2
Après 15 années d’existence, le forum historique de Framasoft, ferme ses portes.
Pour les nostalgiques et les curieux, il reste toujours possible de consulter les discussions mais c’est maintenant le forum
Framacolibri qui prend la relève.
Si vous avez des questions, on se retrouve là-bas…
df.exe >\\monserveurrepository(B)\statdisque\monserveuramonitorer(A).txt
wget http://monserveurrepository(B)/statdisque/test.asp
del test.asp
<% response.expires = "-1" %>
<html>
<head>
<meta http-equiv="refresh" content="86400">
</head>
<body>
Vérification de l'espace disque des différents serveurs.<br>
<%
datefichier = ""
affichedatemaj = ""
'#############################################################
'#### Procédure d'affichage de la date de maj du fichier #####
'#############################################################
Sub DateMajFichier(nomfic)
set fs = CreateObject("Scripting.FileSystemObject")
nFile = Server.MapPath(".") & "\" & nomfic
if fs.FileExists(nFile) then
set MonFichier = fs.GetFile(nFile)
affichedatemaj = "<small><small><i>Dernière mise à jour: " & MonFichier.DateLastModified &"</i></small></small><br/>"
datefichier = Mid(replace(CStr(MonFichier.DateLastModified), "/", "_"),1,10)
datefichier = Mid(datefichier,7,4)&"_"&Mid(datefichier,4,2)&"_"&Mid(datefichier,1,2)
set MonFichier = nothing
else
' le fichier n'existe pas
end if
set fs = nothing
end sub
'#############################################################
'######## Procédure d'affichage de chaque fichier ############
'#############################################################
Sub ParseFichier (nomfichier)
'-------- Ouverture du fichier
Set objFile = Server.CreateObject("Scripting.FileSystemObject")
Set objStream = objFile.OpenTextFile(Server.MapPath(dossier) & "\"&nomfichier)
response.write "<br>Vérification de "&nomfichier&" :<br>"
DateMajFichier(nomfichier)
'-------- Création de l'archive
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile Server.MapPath(dossier) &"\archives\"&datefichier&"_"&nomfichier 'Créer un fichier
Set f = fs.GetFile(Server.MapPath(dossier) &"\archives\"&datefichier&"_"&nomfichier)
Set ts = f.OpenAsTextStream(2, -2)
'-------- Traitement de chaque ligne du fichier
While not objStream.atEndOfStream
strCit = objStream.readLine
'-------- Ecriture de l'archive
ts.Write strCit& VbCrLf
ligneok = 0
if Mid(strCit,2,1)=":" and InStr(StrCit,"[\\$]")=0 then
if ((Mid(strCit,1,1)>="a") and (Mid(strCit,1,1)<="z")) then
'-------- Récupération de toutes les infos sur l'occupation disque WIN NT4
OS = "WINNT"
disque = Mid(strCit,1,3)
total = Int(CDbl(Mid(strCit,21,20))/(1024))
libre = Int(CDbl(Mid(strCit,41,20))/(1024))
utilise = total-libre
pourcentage = Int(utilise*100/total)
pourcentagetexte = CStr(pourcentage)&" %"
ligneok = 1
else
'-------- Récupération de toutes les infos sur l'occupation disque WIN NT5, 2000+, XP
OS = "WIN"
disque = Mid(strCit,1,3)
total = Int(Clng(Mid(strCit,4,11))/1024)
utilise = Int(Clng(Mid(strCit,15,13))/1024)
libre = Int(Clng(Mid(strCit,28,13))/1024)
if IsNumeric(Mid(strCit,41,6)) then
pourcentage = CInt(Mid(strCit,41,6))
else
pourcentage = 0
message = message & "Erreur de traitement du fichier du serveur :"&nomfichier& VbCrLf
end if
pourcentagetexte = Mid(strCit,41,7)
ligneok = 1
end if
end if
if Mid(strCit,1,1)="/" then
'-------- Récupération de toutes les infos sur l'occupation disque pour Unix
OS = "UNIX"
espace = InStr(1,strCit," ")
disque = Mid(strCit,1,espace-1)
chainesanspointdemontage = trim(Mid(strCit, espace))
espace = InStr(1,chainesanspointdemontage," ")
total = Mid(chainesanspointdemontage,1,espace-1)
chainesanstotal = trim(Mid(chainesanspointdemontage, espace))
espace = InStr(1,chainesanstotal," ")
libre = Mid(chainesanstotal,1,espace-1)
chainesanslibre = trim(Mid(chainesanstotal , espace))
espace = InStr(1,chainesanslibre," ")
pourcentagetexte = Mid(chainesanslibre,1,espace-1)
pourcentage = Mid(chainesanslibre, 1,espace-2)
if pourcentage = "" then
pourcentage = 0
else
pourcentage =CInt(pourcentage)
end if
chainesanspourcent = trim(Mid(chainesanslibre , espace))
espace = InStr(1,chainesanspourcent," ")
utilise = Mid(chainesanspourcent,1,espace-1)
ligneok = 1
end if
if ligneok then
'-------- Affichage des infos si le pourcentage > 90%
if pourcentage>=90 and pourcentage<100 then
envoi_ok = 1
disque_pb = disque_pb&" , "&nomfichier
response.write "<b>Disque "&disque&" : Probleme d'espace disque ; Email envoye à l'aministrateur.</b><br>"
if OS = "UNIX" then
message = message & "Problème d'espace disque sur le disque "&disque&" du serveur "& nomfichier & VbCrLf
message = message & "Il reste "&libre&" Mo sur le disque "& disque & VbCrLf
message = message & "Taille totale : "&total&" ko"& VbCrLf
message = message & "% occupée : "&pourcentage&" %"& VbCrLf
message = message & "Taille libre : "&libre&" ko"& VbCrLf& VbCrLf
else
message = message & "Problème d'espace disque sur le disque "&disque&" du serveur "& nomfichier & VbCrLf
message = message & "Il reste "&libre&" Mo sur le disque "& disque & VbCrLf
message = message & "Taille totale : "&total&" Mo"& VbCrLf
message = message & "% occupée : "&pourcentage&" %"& VbCrLf
message = message & "Taille libre : "&libre&" Mo"& VbCrLf& VbCrLf
end if
else
response.write "Disque "&disque&" : Pas de problème.<br>"
end if
end if
Wend
'-------- Fermeture du fichier
objStream.Close
Set objStream = Nothing
Set objFile = Nothing
End Sub
'#############################################################
'################### Corps de la page ########################
'#############################################################
'-------- Lecture du contenu du répertoire
Dim dossier, chemin, dossierParent
Set objFs = Server.CreateObject("Scripting.FileSystemObject")
dossier = "."
chemin = Server.MapPath(dossier&"/")
set objDossier = objFs.getFolder(chemin)
'-------- Initialisation de variables
disque_pb = ""
message = ""
envoi_ok = 0
'-------- Boucle sur les fichiers textes
for each Fichier in objDossier.Files
if objFs.GetExtensionName(Fichier.Name)="txt" then
'--------- Appel de la procédure de traitement et d'affichage du fichier
parsefichier(Fichier.Name)
end if
next
Set objFs = Nothing
Set objDossier = Nothing
if envoi_ok then
'----------------------Envoi du mail récapitulatif
sujet = "Probleme d'espace disque sur :"&disque_pb
expediteur = "Robot_surveillance_disque"
response.write "<br/><br/><b><big>Récapitulatif de l'email envoyé</big></b><br/>"
response.write "<b>Expéditeur : </b>"&expediteur&"<br/>"
response.write "<b>Sujet : </b>"&sujet&"<br/>"
response.write "<b>Message : </b>"&replace(message, VbCrlf,"<br/>")&"<br/>"
On error resume next
Dim mySmartMail
Set mySmartMail = Server.CreateObject("aspSmartMail.SmartMail")
mySmartMail.Server = "serveurdemail"
mySmartMail.SenderName = "<expediteur>"
mySmartMail.SenderAddress = "<"&expediteur&">"
mySmartMail.Recipients.Add "expediteur@domaine.com"
mySmartMail.Subject = sujet
mySmartMail.Body = VbCrLf&message& VbCrLf
mySmartMail.SendMail
if Err.Number<>0 then
Response.write "Error: " & Err.description
set mySmartMail = nothing
end if
end if
%>
</body>
</html>
Utilisateur(s) parcourant actuellement ce forum : Aucun utilisateur inscrit