#!/bin/bash

#ping_monitor.sh

IP_ADDRESS=$1
if [ -n "$IP_ADDRESS" ] ; then while :
do
PING_OK=`ping -c 1 -W 2 $IP_ADDRESS | grep "time=" `
if [ 0 -eq $? ]; then
echo "$PING_OK $TIME_ `date`" >> PING_${IP_ADDRESS}_OK.log
else
echo "PING $IP_ADDRESS 2seconds TMOUT... `date`" >> PING_${IP_ADDRESS}_TMOUT.log
fi sleep 1
done
else
echo "用法:$0 <IP or 域名>"
echo "监控日志请到当前目录下获取"
fi

脚本执行花费时间毫秒级别

#!/bin/bash
#计算脚本执行时间 #开始 纳秒时间戳
start=$(date +%s%N)
echo 'start nanosecond:' $start #脚本内容
sleep 0.001; #结束 纳秒时间戳
end=$(date +%s%N)
echo 'end nanosecond:' $end #计算时间差毫秒 需要除以1000000
take=$(( (end - start) /1000000 )) #输出计算结果
echo Time taken to execute commands is ${take} millisecond .

tcp端口持续监测

#!/bin/bash
# 持续监测端口监听状态
#tcping 二进制文件:https://ks3-cn-beijing.ksyun.com/zhangmingda/tcping
GUEST_IP=$1
GUEST_PORT=$2
LOGFILE=$1_TcpPort$2_monitor.log if [ -n "$GUEST_IP" ] && [ -n "$GUEST_PORT" ]; then
while :
do
RESO=`tcping -t 2 $GUEST_IP $GUEST_PORT`
# -t 超时时间S
if [ $? -eq 0 ]; then
sleep 1
fi
echo `date` $RESO >> $LOGFILE
done
else
echo "用法:$0 <IP or 域名> <端口>"
echo "监控日志请到当前目录下获取"
fi

curl 持续监控返回值

#!/bin/bash
#
#Author:zhangmingda
#date:20191021
#use:持续监控https/http连接请求状态
#########################################################
logfile='curl_monitor.log'
if [ ! -f ${logfile} ];then
touch $logfile
fi #日志文件
echo;echo "curl_log result from $1 " |tee -a ${logfile}
#########################################################
echo ' DNS_OK: TCP_OK: DATA_START: TOTAL_TIME: http_code:' | tee -a ${logfile} while true ;
do
tid="$(date '+%F %H:%M:%S')" ;
url=$1 ;
curl -m 3 -4 -o /dev/null -s -w "curl_tid:${tid} %{time_namelookup} %{time_connect} %{time_starttransfer} %{time_total} code:%{h
ttp_code} \n" \ ${url} | tee -a $logfile ;
sleep 1;
done

#!/bin/bash
#
#Author:zhangmingda
#date:2019-12-30
#use:持续监控https/http连接请求状态
#########################################################
logfile='curl_monitor.log'
if [ ! -f ${logfile} ];then
touch $logfile
fi #日志文件
echo;echo "curl_log result from $1 " |tee -a ${logfile}
#########################################################
echo ' DNS_OK: TCP_OK: DATA_START: TOTAL_TIME: http_code:' | tee -a ${logfile}

while true ;
do
tid="$(date '+%F %H:%M:%S')" ;
url=$1 ;
curl -m 3 -4 -o /dev/null -s -w "curl_tid:${tid} %{time_namelookup} %{time_connect} %{time_starttransfer} %{time_total} \
code:%{http_code} http_connect:%{http_connect} remote_tcp/ip:%{remote_ip}:%{remote_port} url_effective:%{url_effective} \
speed_download:%{speed_download} time_redirect:%{time_redirect}\n" \
${url} | tee -a $logfile ;
sleep 1;
done

最新文章

  1. Notes: DOM Range
  2. Dijkstra算法初步 - 迷宫问题
  3. SQL查询中in、exists、not in、not exists的用法与区别
  4. Jquery实现滚动到底部加载更多(最原始)
  5. Java代码实现excel数据导入到Oracle
  6. MySQL 5.5 服务器变量详解一(转)
  7. [转] Java之ACM速成
  8. oracle 查询优化改写
  9. [bzoj1565][NOI2009]植物大战僵尸_网络流_拓扑排序
  10. Linux进程-命令行参数和环境列表
  11. 巧妙解决vue2.0关于set添加属性后视图不能更新的问题
  12. SpringCloud 学习网址记录
  13. Spring xml配置
  14. 转发:tomcat的acess_log打印post请求参数,分析日志
  15. main.dart
  16. CodeForces - 710F:String Set Queries (二进制分组 处理 在线AC自动机)
  17. setjmp的跳转
  18. CoreDNS介绍
  19. windows下MySQL的安装(非安装包)
  20. 串口调试助手vc源程序及其详细编写过程

热门文章

  1. [省选联考 2021 A/B 卷] 宝石
  2. 洛谷 P5902 [IOI2009]salesman(dp)
  3. CF1437G Death DBMS
  4. R语言与医学统计图形-【26】ggplot2主题函数
  5. Docker 外部访问容器Pp、数据管理volume、网络network 介绍
  6. 20-Integer to Roman-Leetcode
  7. 使用Openmp并行化
  8. Hbase(6)【Java Api Phoenix操作Hbase】
  9. 02-爬取http://www.allitebooks.org/网站,获取图片url,书名,简介,作者
  10. 利用python爬取城市公交站点