Get the App
SLTechnology News&Howtos  ›  Network Security  › 

SHELL some monitoring scripts (modules)

Shulou Source: shulou.com Published: 2022-06-01 08:58:50 09月27日 Update

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

#}

#

Tags: Scripts monitoring memory address local area LAN source code disk native module Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Shulou Technology MariaDB NVidia