Zabbix Statistics MySQL Session table statistics user Internet behavior

Source: Internet
Author: User

/usr/local/zabbix/bin/mysql_session.sh

#!/bin/bash

#this script is used to sort MySQL malicious action

#mysql session

Metric=$1

Case $metric in

Mini

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/mini/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

Login

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/login/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

Register

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/register/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

Ajax_showcart)

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/ajax_showcart/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

Init

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[

$NF]}end{for (A in S) print A,s[a]} ' |awk '/init/{print $ ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

PUBLIC_FIND_PWD)

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/public_find_pwd/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

Public_session_life)

output=$ (mysql-uroot-pxxxxxx-e "select * from Huiyewang.snto_session;" | Awk-f "|" ' {print $} ' |awk ' {print $9} ' |awk ' {++s[$NF]}end{for (A in S) print A,s[a]} ' |awk '/public_session_life/{print '} ')

If ["$output" = = ""];then

Echo 0

Else

Echo $output

Fi

;;

*)

Echo-e "\e[033musage:sh [mini|login|register|ajax_showcart|init|public_find_pwd|public_session_life]\e[0m"

Esac


Zabbix Agent configuration section

Userparameter=mysql.session[*],/usr/local/zabbix/bin/mysql_session.sh $

This article is from the "Xiangjiang River Blowing Crazy" blog, please make sure to keep this source http://xjcf00.blog.51cto.com/10170403/1642117

Zabbix Statistics MySQL Session table statistics user Internet behavior

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.