Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SHELL some monitoring scripts (modules)

2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1the source code installation script of 1meme Apache

#! / bin/bash

# # auther xiaosonglin

# # date 2013-06-08

# apache install

PATH= `echo $PATH`

Rpm-qa | grep httpd

If [$?-eq 0]; then

Echo "apache alredy install" > apac.log

Rpm-e httpd

Else

Echo "apache not install" > > apac.log

Address of the wget http://192.168.18.254/abc/httpd-2.2.16.tar.bz2 LAN class

If [$?-ne 0]; then

Echo "wget ERROR" > > apac.log

Else

Tar fjvx httpd-2.2.16.tar.bz2

Cd httpd-2.2.16

. / configure

Make & & make install

Fi

Fi

#

A httpd startup script, put under / etc/init.d/, you can use service apache2 start | restart | status | stop

Apache can be customized in

#! / bin/bash

# # apache replace httpd

# # auther xsl

# # date

Start () {

/ usr/sbin/httpd

}

Stop () {

Kill-s QUIT httpd

}

Status () {

Elinks http://192.168.18.213-dump > / dev/null Native

If [$?-eq 0]; then

Echo "apache is running"

Else

Echo "apache is down"

Fi

}

Restart () {

Kill-s QUIT httpd

Sleep 3

/ usr/sbin/httpd

}

# # main

Case $1 in

Start)

Start

Stop)

Stop

Status)

Status

Restart)

Restart

*)

Echo "Usage:. / case start | stop | restart | status"

Esac

#

2. Monitor disk

# DISK

# disk () {

# show disk

IP= `ifconfig eth0 | awk 'NR==2' | awk' {print $2}'| awk-F:'{print $2}'`

DISK_LIST= `fdisk-l | grep Disk | awk-F,'{print $1}'> disk_ list`

DISK_COUNT1= `cat disk_list | wc-l`

Let DISK_COUNT2= "$DISK_COUNT1 + 1"

For ((item1witi disk_use

For i in `cat disk_ use`

Do

If [$I-gt 90]

Then

Echo "$IP disk full,please check"

Fi

Done

Done

#}

#

3. Monitor memory

#! / bin/bash

IP= `ifconfig eth0 | awk 'NR==2' | awk' {print $2}'| awk-F:'{print $2}'`

# Mem_mom

# mem () {

MEM_TOTAL= `free | awk 'NR==2' | awk' {print $2}'`

MEM_USE= `free | awk 'NR==2' | awk' {print $3}'`

MEM_FREE= `free | awk 'NR==2' | awk' {print $4}'`

Let USE= "$MEM_USE * 100 / $MEM_TOTAL"

Echo-e "\ t\ t\ t $IP"

Echo

Echo mem_total = $MEM_TOTAL

Echo mem_use = "$MEM_USE use" $USE "%"

Echo mem_free = $MEM_FREE

#}

#

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report