邮件发送统计信息

作者:电脑系统

#定义日志路径
path=/usr/local/nginx/htdocs/log

LANG=en_US.UTF-8

class.php

table='<html><body><table border="1" cellspacing="0" bordercolor="#000000" style="width:400px;bordera-collapse:collapse;align:center"><tr><td>Type</td><td>总计</td><td>Success</td><td>Fail</td></tr>'
table="$table<caption>实名认证统计信息</caption>"

echo  -n "$name访问量为 :" >>/tmp/tongji

 代码如下

#文件2
file1=id5_check_results.log

name=`echo $s | cut -d. -f 1`

echo('<link href="style.css教程" rel="stylesheet" type="text/css" />');
$max = 3;
$j = 0;
if(count($dirs) == 2){
echo'<table width="800" border="0" cellpadding="5" cellspacing="5"><tr>';
 print("<td width='33%'><img src='type/dir.png'/>");
 print('<a href="test.php?path='.$path."/".$dirs[0].'">');
 print($dirs[0]);
 print('</a>');
 print("</td>");
 print("<td width='33%'><img src='type/dir.png'/>");
 print('<a href="test.php?path='.$path."/".$dirs[1].'">');
 print($dirs[1]);
 print('</a>');
 print("</td>");
 print("<td width='33%'>");
 print("  ");
 print("</td>");
 echo '</tr></table>';
}else{
echo'<table width="800" border="0" cellpadding="5" cellspacing="5"><tr>';
while($j <= (count($dirs) -1)){
 print("<td ><img src='type/dir.png'/>");
 print('<a href="test.php?path='.$path."/".$dirs[$j].'">');
 print($dirs[$j]);
 print('</a>');
 print("</td>");
 if(($j 1) % $max == 0){
   echo '</tr>';
   if(($j 1) != count($dirs)){
    echo '<tr>';
     }
  }
  $j ;
 }
 echo '</tr></table>';
}
$i = 0;
if(count($files) == 2){
echo'<table width="800" border="0" cellpadding="5" cellspacing="5"><tr>';
 print("<td width='33%'><img src='type/".$newdir -> getfiletype($files[0]).".png'/> ");
 print($newdir -> change2line($files[0]));
 print("</td>");
 print("<td width='33%'><img src='type/".$newdir -> getfiletype($files[1]).".png'/> ");
 print($newdir -> change2line($files[1]));
 print("</td>");
 print("<td width='33%'>");
 print("  ");
 print("</td>");
 echo '</tr></table>';
}else{
echo'<table width="800" border="0" cellpadding="5" cellspacing="5"><tr>';
while($i <= (count($files) -1)){
 print("<td width=100><img src='type/".$newdir -> getfiletype($files[$i]).".png'/> ");
 print($newdir -> change2line($files[$i])); 
 print("</td>");
 if(($i 1) % 3 == 0){
   echo '</tr>';
   if(($i 1) != count($files)){
    echo '<tr>';
    }
 }
 
 $i ;
}
 echo '</tr></table>';
}
?>

  #免费成功数
  success=`grep -r $type $path/$date/$file |wc -l `

echo ''> /tmp/tmp.txt

<?php
  class for php4.x
 class  dirver{
  /class var/
  var $path;
  var $flies;
  var $dirs;
  /
  function dirver(){
   $this -> path = ""; 
   $this -> files = array();
   $this -> dirs = array();
  }
  
  function dirdata(){
   if(isset($this -> path)){
    $handle = dir($this -> path);
    while(false !== ($data = $handle -> read())){
     if(is_dir($this -> connectname($this -> path,$data)) && $data != "." && $data != ".."){
       $this -> dirs[] = $data;
       continue;
      }
      
     if($data != "." && $data != ".." && is_file($this -> connectname($this -> path,$data))){
       $this -> files[] = $data;
       continue;
      }
     
    }
    $handle -> close(); 
   }else{
    return false; 
   }
  }
  
 function setpath($src){
   if($src != ""){
    $this -> path = $src; 
   }else{
    return false; 
   }
  }
 /
 function connectname($path,$name){
  return $path."/".$name;
 }
 /
 function change2line($name){
  $basename = explode(".",$name);
  $basename = $basename[0];
  $tmp = $this -> path."/".$name;
  $tmp = '<a href="'.$tmp.'" target="_blank">'.$basename.'</a>';
  return $tmp; 
 }
 
 function getfiletype($file){
  if($file != ""){
   $tmp = explode(".",$file);
   $type = $tmp[count($tmp)-1];
   return $type; 
  }
 }
 
 
 function getfiles(){
  return $this -> files;
  }
 
 function getdirs(){
  return $this -> dirs; 
  }
 //
 }

#类型1

# 清空之前的记录

?>

#定义邮件地址,多个邮件地址逗号分隔

first="[$date/$month/$year:00:00:00"

include("class.php");
$path = $_get['path'];
if($path == ""){
 $path = "dir"; 
}else{
 if(!strstr($path,"dir")){
  $path = "dir/".$path;
 }else{
  $path = $path; 
 }
}

#文件1

cat >>/etc/mail.rc<EOF

$newdir = new dirver();
$newdir -> setpath($path);
$newdir -> dirdata();
$files = $newdir -> getfiles();
$dirs = $newdir -> getdirs();
//print_r($files);
//print_r($dirs);

  #收费失败数
  failue1=`grep -v $type1 $path/$date/$file1 |wc -l `

#本脚本用来统计特定时间段内,独立访问的用户数量

  #以html格式发送数据
  echo $table | mailx -v -s "$(echo -e "$date 统计信息nContent-Type: text/html")" $Email_ok
else
  echo "$file 或 $file1 文件不存在,请查看原因" | mailx -v -s " $date 统计信息" $Email_failue
fi

year=`date %Y`

file=nciic_check_results.log

for s in `ls | grep -v error.log | grep -v test.sh | grep -v access1.log | grep -v tongji.sh`

  #收费成功数
  success1=`grep -r $type1 $path/$date/$file1 |wc -l `

#!/bin/bash

Email_ok=邮件地址1,邮件地址2

# 去重ip,获取所有的访问量

  #追加数据

cat $s | awk -v First="$first" -v Last="$last" '$4 >=First && $4 <=Last'  | awk '{print $1}' >>/tmp/tmp.txt

  if [[ $all != `expr $success $failue` || $all1 != `expr $success1 $failue1` ]]; then
    table="$table<tr><td col=4>数据不匹配<td></tr>"
  fi

mon=`date %B --date="-1 day"`

  table="$table<tr><td>收费</td><td>$all1</td><td>$success1</td><td>$failue1</td></tr>"
  table="$table<tr><td>免费</td><td>$all</td><td>$success</td><td>$failue</td></tr>"

cat /tmp/tmp.txt | sort | uniq -c |wc -l>>/tmp/tongji

  #完成table样式
  table="$table</table></body></html>"

# 发送邮件配置

#判断两个文件是否存在

cat /tmp/tongji | mailx -s "移动线路 nginx访问量 " ssg@beiyang.com 122121@139.com

type='",2:0}'

echo -n "总访问量为:">>/tmp/tongji

#生成日期
date=`date -d yesterday " %Y%m%d"`

set smtp-auth=login

if [[ -f $path/$date/$file && -f $path/$date/$file1 ]];then

do

  #收费总数
  all1=`cat $path/$date/$file1 |wc -l`

date=`date %d --date="-1 day"`

  #免费总数
  all=`cat $path/$date/$file |wc -l`

#变量的带入

  #判断两组数据是否匹配

set smtp-auth-password=*****

  #免费失败数
  failue=`grep -v $type $path/$date/$file |wc -l `

cat $s | awk -v First="$first" -v Last="$last" '$4 >=First && $4 <=Last'  | awk '{print $1}'|sort | uniq -c |wc -l >>/tmp/tongji

#!/bin/bash

set from="*****@163.com"

#定义表格样式

if  [ `rpm -qa mailx|wc -l` == 0 ]

#类型2
type1='",2:true}'

month=${mon:0:3}

echo ''>/tmp/tongji

EOF

set smtp-auth-user=****@163.com

then

set smtp=smtp.163.com

last="[$date/$month/$year:24:00:00"

yum install mailx -y

done

# 安装配置邮件

fi

#设置语言环境,换取需要的日月的格式

本文由分分快三计划发布,转载请注明来源

关键词: 分分快三计划 Linux Nginx