nagios监控squid的脚本-创新互联

最近一直都在忙工作上的事情,没有时间来写点东西了,公司用的cache是squid,之前有过监控,但是nagios中看不到squid的命中率,于是就写了这么一个脚本来通过pnp4nagios查看squid的一些图。下面是脚本:

目前成都创新互联已为成百上千的企业提供了网站建设、域名、虚拟空间、成都网站托管、企业网站设计、莲花网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
  1. #!/bin/bash 
  2. "Version 1.1"
  3. "zhhmj (tgariltg@gmail.com)"
  4. "localhost"
  5. "$PROGNAME $VERSION $AUTHOR"
  6. ""
  7. ""
  8. "Description:"
  9. "Gets percentage of hits  for a squid reverse proxy"
  10. "Options:"
  11. "  -h|--help"
  12. "   Print help info."
  13. "  -H|--hostname)"
  14. "   Sets the hostname, default is localhost"
  15. "  -P|--port)"
  16. "   Sets the port, default is 8001"
  17. "  -wd)"
  18. "   Sets the number of available file descriptors to warn at, default 100"
  19. "  -cd)"
  20. "   Sets the number of available file descriptors to go critical at, default 30"
  21. "  -wh)"
  22. "   Sets the percentage of hits to warn at, default 70"
  23. "  -ch)"
  24. "   Sets the percentage of hits to go critical at, default 50"
  25. ""
  26. "Example:"
  27. "  ./check_squid -H 127.0.0.1 -P 8001 -wd 100 -cd 30 -wh 70 -ch 50"
  28. "  WARNING - Squid is serving an average of 7.2 per minute since start with 655349 file descriptors left and 0.04 percent of CPU use and Hits as 64% of all requests"
  29. case"$status_text"in
  30. "Error gettings metrics.(Access control on squid?)"
  31. "Error connecting to host"
  32. minute
  33. asofallby
  34. asofby
  35. asofby
  36. "${status_text}""Available number of file descriptors"'s/^[ \t]*//'
  37. "${status_text}""CPU Usage:"'s/^[ \t]*//'
  38. "${status_text}""Average HTTP requests per minute since start"'s/^[ \t]*//'
  39. "${status_text}""Hits as % of all requests"'{print $8}''{print $1}'
  40. "${status_text}""Memory hits as % of hit requests"'{print $9}''{print $1}'
  41. "${status_text}""Disk hits as % of hit requests"'{print $9}''{print $1}'
  42. "'avail_descriptors'=$available_descriptors 'cpu_usage'=$cpu_usage 'avg_http_requests'=$avg_http_requests 'all_requests_hits'=$all_requests_hits% 'memory_hits'=$memory_hits% 'disk_hits'=$disk_hits%"
  43. out"Squid is serving an average of $avg_http_requests per minute since start with $available_descriptors file descriptors left and $cpu_usage percent of CPU use and Hits as $all_requests_hits% of all requests"
  44. then
  45. "CRITICAL - ${out} | ${perfdata}"
  46. then
  47. "WARNING - ${out} | ${perfdata}"
  48. else
  49. "OK - ${out} | ${perfdata}"
  50. "$1"
  51. case"$1"in
  52. --help|-h)
  53. --version|-v)
  54. --hostname|-H)
  55. --port|-P)
  56. "Unknown argument: $1"
  57. then
  58. "Warn descriptors must not be lower than critical and crit hits must not be lower than warn hits!"

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:nagios监控squid的脚本-创新互联
文章位置:http://lszwz.com/article/dddhps.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款