Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
241ee2385f | ||
|
|
6beee1e2ba | ||
|
|
5d89ac6417 | ||
|
|
c4801fa8dc | ||
|
|
44e406c80f | ||
|
|
06caf72a34 | ||
| 19accb4c0e | |||
| 5718426164 | |||
| 86011bbacf | |||
| 2f2a283f7e | |||
| 2ff5c979b5 | |||
| 8fd4776f92 | |||
| ffc9ad66ed | |||
| 3de8864695 | |||
| 0fb4bdf279 | |||
| ae439aed2d | |||
| 3afefd1e28 | |||
| 29507b8851 | |||
| eef1df73ae | |||
| 034f15c009 | |||
| ec27b17ed6 | |||
| 176c779dfd | |||
| ff1c26d7fb | |||
| c69661a84f | |||
| 7c5bc10213 | |||
| e4cf042e30 | |||
| 17858bb920 | |||
| d4300b4ca5 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
client/web/index.html
|
client/web/index.html
|
||||||
|
build/*
|
||||||
|
|||||||
102
README.md
102
README.md
@ -6,7 +6,7 @@ MoniThor is a simple monitoring tools in bash.
|
|||||||
|
|
||||||
You can use it with netcat or cryptcat
|
You can use it with netcat or cryptcat
|
||||||
|
|
||||||
You can see result on the client from a web page (self hosted python web server)
|
You can see result on the client from a web page (self hosted python3 web server)
|
||||||
|
|
||||||
|
|
||||||
## Server Configuration
|
## Server Configuration
|
||||||
@ -16,7 +16,7 @@ The configuration files for the server are :
|
|||||||
|
|
||||||
### serivce.cfg
|
### serivce.cfg
|
||||||
|
|
||||||
- ./server/conf-server/service.cfg
|
- /etc/monithor-server/service.cfg
|
||||||
|
|
||||||
```
|
```
|
||||||
LocalIp is the IP adresse to used on the server (can used 127.0.0.1)
|
LocalIp is the IP adresse to used on the server (can used 127.0.0.1)
|
||||||
@ -29,7 +29,7 @@ LocalPassword is to set if you used Crypted
|
|||||||
|
|
||||||
### sonde.cfg
|
### sonde.cfg
|
||||||
|
|
||||||
- ./server/conf-server/sonde.cfg
|
- /etc/monithor-server/sonde.cfg
|
||||||
|
|
||||||
```
|
```
|
||||||
SONDE#SCRIPT
|
SONDE#SCRIPT
|
||||||
@ -37,22 +37,50 @@ SONDE#SCRIPT
|
|||||||
|
|
||||||
SONDE is get by the server and it exec SCRIPT with ARG get from the client
|
SONDE is get by the server and it exec SCRIPT with ARG get from the client
|
||||||
|
|
||||||
|
SCRIPT are in /usr/local/bin/monithor-server.d/
|
||||||
|
|
||||||
|
Actual :
|
||||||
|
|
||||||
|
**file-present.sh** : check if a file (abosult path) is persent
|
||||||
|
|
||||||
|
**part-space.sh** : check the partition % (arg are : PATH|Min%|Max% ex : /home/isen|50|80)
|
||||||
|
|
||||||
|
**process-present.sh** : check if a process is running
|
||||||
|
|
||||||
### tree
|
### tree
|
||||||
|
|
||||||
- Tree for server
|
- Tree for server
|
||||||
|
|
||||||
```
|
```
|
||||||
|
.
|
||||||
|
├── DEBIAN
|
||||||
|
│ └── control
|
||||||
|
├── etc
|
||||||
|
│ ├── init.d
|
||||||
|
│ │ └── monithor-d
|
||||||
|
│ └── monithor-server
|
||||||
|
│ ├── service.cfg
|
||||||
|
│ └── sonde.cfg
|
||||||
|
└── usr
|
||||||
|
└── local
|
||||||
|
└── bin
|
||||||
|
├── monithor-server
|
||||||
|
└── monithor-server.d
|
||||||
|
├── file-present.sh
|
||||||
|
└── FunctionOutput
|
||||||
|
|
||||||
|
8 directories, 7 files
|
||||||
|
|
||||||
└── server
|
|
||||||
├── conf-server
|
|
||||||
│ ├── scripts
|
|
||||||
│ │ ├── file-present.sh
|
|
||||||
│ │ └── FunctionOutput
|
|
||||||
│ ├── service.cfg
|
|
||||||
│ └── sonde.cfg
|
|
||||||
└── Daemon.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### init.d System V
|
||||||
|
|
||||||
|
You can use monithor-server as a service
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo /etc/init.d/monithor-d start/stop
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Client Configuration
|
## Client Configuration
|
||||||
|
|
||||||
@ -61,7 +89,7 @@ The configuration files for the client are :
|
|||||||
|
|
||||||
### serivce.cfg
|
### serivce.cfg
|
||||||
|
|
||||||
- ./client/conf-client/service.cfg
|
- /etc/monithor-client/service.cfg
|
||||||
|
|
||||||
```
|
```
|
||||||
LocalPassword can be used if you chose Crypted=yes (process is slow)
|
LocalPassword can be used if you chose Crypted=yes (process is slow)
|
||||||
@ -74,7 +102,7 @@ TimeOut is the number of second before the interrogation failed
|
|||||||
|
|
||||||
### sonde.cfg
|
### sonde.cfg
|
||||||
|
|
||||||
- ./client/conf-client/sonde.cfg
|
- /etc/monithor-client/sonde.cfg
|
||||||
|
|
||||||
```
|
```
|
||||||
IP:PORT#SONDE#Arguemnent
|
IP:PORT#SONDE#Arguemnent
|
||||||
@ -97,24 +125,46 @@ IP:PORT#SONDE#Arguemnent
|
|||||||
|
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
└── client
|
├── DEBIAN
|
||||||
├── conf-client
|
│ └── control
|
||||||
│ ├── exec.sh
|
├── etc
|
||||||
│ ├── functions
|
│ ├── init.d
|
||||||
│ ├── service.cfg
|
│ │ └── monithor-c
|
||||||
│ ├── sonde.cfg
|
│ └── monithor-client
|
||||||
│ ├── webmonithor.html
|
│ ├── conf
|
||||||
│ └── webserver.sh
|
│ │ ├── Card_10.10.10.3-1666.cfg
|
||||||
├── service.sh
|
│ │ └── Card_10.10.10.4-1666.cfg
|
||||||
└── web
|
│ ├── service.cfg
|
||||||
├── index.html
|
│ └── sonde.cfg
|
||||||
└── webmonithor.html
|
└── usr
|
||||||
|
└── local
|
||||||
|
└── bin
|
||||||
|
├── monithor-client
|
||||||
|
└── monithor-client.d
|
||||||
|
├── MoniThor
|
||||||
|
├── MoniThorFnct
|
||||||
|
└── MoniThorWebServer
|
||||||
|
|
||||||
|
9 directories, 10 files
|
||||||
|
|
||||||
```
|
```
|
||||||
|
### init.d System V
|
||||||
|
|
||||||
|
You can use monithor-client as a service
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo /etc/init.d/monithor-c start/stop
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### WEB
|
### WEB
|
||||||
|
|
||||||
The client start a python sumple http server on localhost on `WebPort`
|
The client start a python3 sumple http server on localhost on `WebPort`
|
||||||
|
|
||||||
|
```
|
||||||
|
/usr/local/bin/monithor-client.d/MoniThorWebServer
|
||||||
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
cd $(dirname $0)
|
|
||||||
|
|
||||||
SondeFile=$(pwd)/sonde.cfg
|
|
||||||
source service.cfg
|
|
||||||
source functions
|
|
||||||
ConfFile=$1
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
|
||||||
do
|
|
||||||
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
|
||||||
then
|
|
||||||
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
sleep ${Rotation}
|
|
||||||
else
|
|
||||||
while read DATA
|
|
||||||
do
|
|
||||||
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
|
||||||
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
|
|
||||||
Cmd=$(echo $DATA| cut -d"#" -f2)
|
|
||||||
Arg=$(echo $DATA| cut -d"#" -f3)
|
|
||||||
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
|
||||||
Ret=$?
|
|
||||||
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
done < ${ConfFile}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
PrintRes() {
|
|
||||||
|
|
||||||
echo "$1"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CheckAllEnd() {
|
|
||||||
|
|
||||||
if [[ ! -f /tmp/webmonithor ]]
|
|
||||||
then
|
|
||||||
Total=$1
|
|
||||||
Actual=0
|
|
||||||
for ActualFile in $(find /tmp/ -name Monithor_\*-tmp)
|
|
||||||
do
|
|
||||||
[[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Actual=$((Actual + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${Total} -eq ${Actual} ]]
|
|
||||||
then
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
|
||||||
<meta http-equiv="refresh" content="1" />
|
|
||||||
</head>
|
|
||||||
<title>MONITHOR</title>
|
|
||||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
|
||||||
<table border="1" color="#FFFFFF">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="4">MoniThor Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>' > /tmp/webmonithor
|
|
||||||
|
|
||||||
cat /tmp/Monithor_*-tmp >> /tmp/webmonithor
|
|
||||||
|
|
||||||
echo '
|
|
||||||
</tbody>
|
|
||||||
</table> ' >> /tmp/webmonithor
|
|
||||||
mv /tmp/webmonithor ../web/index.html
|
|
||||||
rm /tmp/Monithor_* -f
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateWebEnd(){
|
|
||||||
echo '<!--End of '$1' '$(pwd)'-->' >> $1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateWeb(){
|
|
||||||
|
|
||||||
Val=$(echo $1 | cut -d"|" -f1)
|
|
||||||
Txt=$(echo $1 | cut -d"|" -f2)
|
|
||||||
Sonde=$2
|
|
||||||
Arg=$3
|
|
||||||
Remote=$4
|
|
||||||
File=$5
|
|
||||||
Color=red
|
|
||||||
[[ $Val == "0" ]] && Color=green
|
|
||||||
[[ $Val == "1" ]] && Color=yellow
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<tr> <td>'$Remote'</td> <td>'$Sonde'</td> <td>'$Arg'</td> <td style="background-color:'${Color}';" > '$Val' </td> <td> '$Txt'</td> </tr>' >> ${File}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd $(dirname $0)/../web/
|
|
||||||
source ../conf-client/functions
|
|
||||||
python -m SimpleHTTPServer ${1} &
|
|
||||||
|
|
||||||
|
|
||||||
echo '<html>
|
|
||||||
<head>
|
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
|
||||||
<meta http-equiv="refresh" content="1" />
|
|
||||||
</head>
|
|
||||||
<title>MONITHOR</title>
|
|
||||||
|
|
||||||
!!!! Initialization !!!!
|
|
||||||
|
|
||||||
' > index.html
|
|
||||||
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
|
||||||
do
|
|
||||||
if [[ ! -z $(ls -1 /tmp/ | grep Monithor_.*-tmp) ]]
|
|
||||||
then
|
|
||||||
CheckAllEnd $2
|
|
||||||
echo INSIDE
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source $(dirname $0)/conf-client/service.cfg
|
|
||||||
source $(dirname $0)/conf-client/functions
|
|
||||||
|
|
||||||
if [[ "$1" == "start" ]]
|
|
||||||
then
|
|
||||||
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
|
||||||
rm /tmp/Monitor* /tmp/webmonithor &> /dev/null
|
|
||||||
|
|
||||||
TotalConfig=$(ls -1 ./conf-client | grep Card_.*\.cfg|wc -l)
|
|
||||||
for Conf in $(ls -1 ./conf-client | grep Card_.*\.cfg)
|
|
||||||
do
|
|
||||||
screen -dmS ${Conf} bash ./conf-client/exec.sh ${Conf}
|
|
||||||
done
|
|
||||||
screen -dmS webserver bash ./conf-client/webserver.sh ${WebPort} $TotalConfig
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$1" == "stop" ]]
|
|
||||||
then
|
|
||||||
killall python &> /dev/null
|
|
||||||
rm /tmp/Monithor* &> /dev/null
|
|
||||||
touch /tmp/endmonitor
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1,6 +0,0 @@
|
|||||||
Package: monithor-client
|
|
||||||
Version: 1.0
|
|
||||||
Architecture: all
|
|
||||||
Dependsd:netcat,cryptcat,screen,python,netcat,cryptcat,elinks
|
|
||||||
Maintainer: Guillaume Astier <guillaume@gastier.net>
|
|
||||||
Description: monithor client (with simple http server python)
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
RemoteIp=10.10.10.3:1666
|
|
||||||
LocalPassword='Evil@MonitoR-666'
|
|
||||||
Crypted=no
|
|
||||||
Rotation=1
|
|
||||||
TimeOut=2
|
|
||||||
WebPort=80
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
SondeFile=/etc/monithor-client/sonde.cfg
|
|
||||||
source /etc/monithor-client/service.cfg
|
|
||||||
source /usr/local/bin/monithor-client.d/MoniThorFnct
|
|
||||||
|
|
||||||
ConfFile=$1
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
|
||||||
do
|
|
||||||
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
|
||||||
then
|
|
||||||
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
sleep ${Rotation}
|
|
||||||
else
|
|
||||||
while read DATA
|
|
||||||
do
|
|
||||||
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
|
||||||
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
|
|
||||||
Cmd=$(echo $DATA| cut -d"#" -f2)
|
|
||||||
Arg=$(echo $DATA| cut -d"#" -f3)
|
|
||||||
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
|
||||||
Ret=$?
|
|
||||||
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
done < /etc/monithor-client/conf/${ConfFile}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
network#ip.sh
|
|
||||||
file#file-present.sh
|
|
||||||
|
|
||||||
BIN
doc/monithor-client.1.gz
Normal file
BIN
doc/monithor-client.1.gz
Normal file
Binary file not shown.
92
doc/monithor-client.md
Normal file
92
doc/monithor-client.md
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
---
|
||||||
|
title: monithor-client
|
||||||
|
section: 1
|
||||||
|
author: Guillaume Astier Ruiz
|
||||||
|
date: 20220320
|
||||||
|
...
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-c [start/stop]`
|
||||||
|
|
||||||
|
# DESCRIPTION
|
||||||
|
|
||||||
|
monithor-client(1) permet de surveiller votre système d'information
|
||||||
|
|
||||||
|
- l'ensemble du service est basé sur l'ourverture d'une socket TCP via netcat
|
||||||
|
|
||||||
|
- il peut aussi utiliser cryptcat (chiffré)
|
||||||
|
|
||||||
|
- un serveur web en python3 est lancé sur votre machine de monitoring
|
||||||
|
|
||||||
|
# INIT.D
|
||||||
|
|
||||||
|
le service peut être démarré et arrêté via system V
|
||||||
|
|
||||||
|
- Démarrage
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-c start`
|
||||||
|
|
||||||
|
- Arrêt
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-c stop`
|
||||||
|
|
||||||
|
# CONFIGURATION SERVICE
|
||||||
|
|
||||||
|
- Le fichier responsable de la gestion IP/PORT est : service.cfg
|
||||||
|
|
||||||
|
`$ cat etc/monithor-client/service.cfg `
|
||||||
|
|
||||||
|
`LocalPassword='Evil@MonitoR-666'`
|
||||||
|
|
||||||
|
`Crypted=no`
|
||||||
|
|
||||||
|
`Rotation=1`
|
||||||
|
|
||||||
|
`TimeOut=2`
|
||||||
|
|
||||||
|
`WebPort=80`
|
||||||
|
|
||||||
|
* LocalPassword : correspond au mot de passe utilisé pour chiffré la connexion si Crypted est à "yes"
|
||||||
|
|
||||||
|
* Crypted : si la valeur est à "yes" le binnaire crypcat est utilisé, si non netcat est utilisé
|
||||||
|
|
||||||
|
* Rotation : correspond à la valeur en seconde (float) entre chaque éxécution complète des sondes
|
||||||
|
|
||||||
|
* TimeOut : correspond à la valeur en seconde (float) du temps maximal d'éxécution de chaque sonde
|
||||||
|
|
||||||
|
* WebPort : correpond au port utilisé pour lancer le serveur web python3
|
||||||
|
|
||||||
|
# CONFIGURATION SONDE
|
||||||
|
|
||||||
|
- La configuration des sondes est stocké dans le répertoires :
|
||||||
|
|
||||||
|
/etc/monithor-client/conf/
|
||||||
|
|
||||||
|
Tous les fichiers *.cfg sont lus.
|
||||||
|
|
||||||
|
- Chaque sonde est composée de cette manière :
|
||||||
|
|
||||||
|
`IP:PORT#SONDE#arg1|arg2|arg3`
|
||||||
|
|
||||||
|
* IP:PORT : correspond à l'adresse et le prot de communication du erveur monithor-server distant.
|
||||||
|
|
||||||
|
* SONDE : correspond au nom de sonde envoyé sur le serveur monithor-server distant.
|
||||||
|
|
||||||
|
* \# : séparateur entre le nom de la sonde et les arguments
|
||||||
|
|
||||||
|
* arg1\|arg2\|arg3 : ensemble des arguments envoyé sur le serveur monithor-server distant. Le séparateur est "\|"
|
||||||
|
|
||||||
|
- Exemple :
|
||||||
|
|
||||||
|
`$ cat etc/monithor-client/conf/Card_10.10.10.3-1666.cfg `
|
||||||
|
|
||||||
|
`10.10.10.3:1666#file#/tmp/test`
|
||||||
|
|
||||||
|
`10.10.10.3:1666#part#/home/isen|50|80`
|
||||||
|
|
||||||
|
`10.10.10.3:1666#process#sshd`
|
||||||
|
|
||||||
|
- Multiple cible
|
||||||
|
|
||||||
|
Chaque fichier peut s'organiser par cible ou par type de sonde ou tout mélangé
|
||||||
BIN
doc/monithor-server.1.gz
Normal file
BIN
doc/monithor-server.1.gz
Normal file
Binary file not shown.
106
doc/monithor-server.md
Normal file
106
doc/monithor-server.md
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
---
|
||||||
|
title: monithor-server
|
||||||
|
section: 1
|
||||||
|
author: Guillaume Astier Ruiz
|
||||||
|
date: 20220320
|
||||||
|
...
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
|
||||||
|
`/usr/local/bin/monithor-d [start/stop]`
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-d [start/stop]`
|
||||||
|
|
||||||
|
|
||||||
|
# DESCRIPTION
|
||||||
|
|
||||||
|
monithor-server(1) permet d'accépter des requêtes venant d'un instance monithor-client
|
||||||
|
|
||||||
|
- l'ensemble du service est basé sur l'ourverture d'une socket TCP via netcat
|
||||||
|
|
||||||
|
- il peut aussi utiliser cryptcat (chiffré)
|
||||||
|
|
||||||
|
## INIT.D
|
||||||
|
|
||||||
|
le service peut être démarré et arrêté via system V
|
||||||
|
|
||||||
|
- Démarrage
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-d start`
|
||||||
|
|
||||||
|
- Arrêt
|
||||||
|
|
||||||
|
`/etc/init.d/monithor-d stop`
|
||||||
|
|
||||||
|
# CONFIGURATION SERVICE
|
||||||
|
|
||||||
|
- Le fichier responsable de la gestion IP/PORT est : service.cfg
|
||||||
|
|
||||||
|
`RemoteIp=10.10.10.4`
|
||||||
|
|
||||||
|
`LocalPort=1666`
|
||||||
|
|
||||||
|
`Crypted=no`
|
||||||
|
|
||||||
|
`LocalPassword='Evil@MonitoR-666'`
|
||||||
|
|
||||||
|
* RemoteIp : correspond à l'adresse IP de l'interface réseau en écoute du client de monitoring
|
||||||
|
|
||||||
|
* LocalPort : correspond au port de communication du client monithor
|
||||||
|
|
||||||
|
* LocalPassword : correspond au mot de passe utilisé pour chiffré la connexion si Crypted est à "yes"
|
||||||
|
|
||||||
|
* Crypted : si la valeur est à "yes" le binnaire crypcat est utilisé, si non netcat est utilisé
|
||||||
|
|
||||||
|
# CONFIGURATION SONDE
|
||||||
|
|
||||||
|
- La configuration des sondes est stocké dans le répertoires :
|
||||||
|
|
||||||
|
/etc/monithor-server/sonde.cfg
|
||||||
|
|
||||||
|
Chaque sonde est composé de cette manière :
|
||||||
|
|
||||||
|
`SONDE#SCRIPT`
|
||||||
|
|
||||||
|
* SONDE : Nom de la sonde envoyé par monithor server et reçu par monithor client
|
||||||
|
|
||||||
|
* SCRIPT : Script éxecuté sur l'instance avec le(s) argument(s) reçu(s) de monithor client
|
||||||
|
|
||||||
|
# SCRIPT
|
||||||
|
|
||||||
|
les scripts sont tous stocké dans le répertoire :
|
||||||
|
|
||||||
|
/usr/local/bin/monithor-server.d/
|
||||||
|
|
||||||
|
# Exemple
|
||||||
|
|
||||||
|
* Configuration server :
|
||||||
|
|
||||||
|
`cat /etc/monithor-server/sonde.cfg`
|
||||||
|
|
||||||
|
`part#part-space.sh`
|
||||||
|
|
||||||
|
* Configuration client :
|
||||||
|
|
||||||
|
`$ cat /etc/monithor-client/etc/monithor-client/conf/sample.cfg
|
||||||
|
|
||||||
|
`#10.10.10.3:1666#part#/home/isen|50|80`
|
||||||
|
|
||||||
|
* Explication
|
||||||
|
|
||||||
|
CLIENT envoi à SERVEUR : part#/home/isen|50|80
|
||||||
|
|
||||||
|
SERVEUR compare la chaine part à son fichier de configuration /etc/monithor-server/sonde.cfg
|
||||||
|
|
||||||
|
SERVEUR associe part#part-space.sh
|
||||||
|
|
||||||
|
SERVEUR exécute : /usr/local/bin/monithor-server.d/part-space.sh /home/isen 50 80
|
||||||
|
|
||||||
|
SERVEUR renvoie les valeur récupéré à CLIENT
|
||||||
|
|
||||||
|
Les lignes commençant par '#' sont à supprimer ou à décommenter
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
83
generate.sh
Executable file
83
generate.sh
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
BinNeed="dpkg-deb realpath"
|
||||||
|
Wai=$(dirname $(realpath $0))
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
|
||||||
|
echo "$0
|
||||||
|
permet de générer les versions de monithor server et client en paquet debian"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
GetOut () {
|
||||||
|
[[ $1 == "pkg" ]] && echo "Le paquet $2 est nécessaire" && usage 1
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckDep() {
|
||||||
|
for CheckBinNeed in ${BinNeed}
|
||||||
|
do
|
||||||
|
TestCheckBinNeed=$(which $CheckBinNeed)
|
||||||
|
[[ -z $TestCheckBinNeed ]] && GetOut pkg $CheckBinNeed
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
GitVersion() {
|
||||||
|
|
||||||
|
LastTag=$(git tag | sed "s/^V//g" | cut -d"-" -f1 | sort -n -k2 -t. | tail -n1)
|
||||||
|
NewTag=${LastTag}-rebuild
|
||||||
|
}
|
||||||
|
|
||||||
|
CpArchName() {
|
||||||
|
|
||||||
|
rm -Rf /tmp/monithor-*
|
||||||
|
cp -Rf ${Wai}/monithor-${1} /tmp/monithor-${1}_${2}_all
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SedControl() {
|
||||||
|
sed -i "/^Version/s/:.*/: ${2}/g" /tmp/monithor-${1}_${2}_all/DEBIAN/control
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildDeb(){
|
||||||
|
echo -n "Gen monithor-${1} [$2] : "
|
||||||
|
cd /tmp/ &> /dev/null
|
||||||
|
Dist=$(lsb_release -a 2> /dev/null | grep Distributor |awk '{print $NF}' |tr '[:upper:]' '[:lower:]')
|
||||||
|
[[ $Dist == "ubuntu" ]] && Compress=' -Z gzip -S fixed '
|
||||||
|
dpkg-deb ${Compress} --build --root-owner-group monithor-${1}_${2}_all &> /dev/null
|
||||||
|
[[ "$?" -eq "0" ]] && echo "OK" || echo "FAILED"
|
||||||
|
cp monithor-*deb ${Wai}/build
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CleanTemp() {
|
||||||
|
mkdir $Wai/build &> /dev/null
|
||||||
|
mv monithor-*deb $Wai/build
|
||||||
|
rm -Rf monithor-*
|
||||||
|
}
|
||||||
|
|
||||||
|
ManPage() {
|
||||||
|
|
||||||
|
mkdir -p /tmp/monithor-${1}_${2}_all/usr/share/man/man1/
|
||||||
|
|
||||||
|
pandoc -s -t man ${Wai}/doc/monithor-${1}.md -o /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1
|
||||||
|
gzip /tmp/monithor-${1}_${2}_all/usr/share/man/man1/monithor-${1}.1
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ ! -z $1 ]] && usage
|
||||||
|
|
||||||
|
CheckDep
|
||||||
|
GitVersion
|
||||||
|
|
||||||
|
CpArchName server $NewTag
|
||||||
|
SedControl server $NewTag
|
||||||
|
ManPage server $NewTag
|
||||||
|
BuildDeb server $NewTag
|
||||||
|
|
||||||
|
CpArchName client $NewTag
|
||||||
|
SedControl client $NewTag
|
||||||
|
ManPage client ${NewTag}
|
||||||
|
BuildDeb client $NewTag
|
||||||
BIN
img/web.png
BIN
img/web.png
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 41 KiB |
6
monithor-client/DEBIAN/control
Normal file
6
monithor-client/DEBIAN/control
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
Package: monithor-client
|
||||||
|
Version: 1.0
|
||||||
|
Architecture: all
|
||||||
|
Dependsd:netcat,cryptcat,screen,python3,netcat,cryptcat,elinks
|
||||||
|
Maintainer: Guillaume Astier <guillaume@gastier.net>
|
||||||
|
Description: monithor client (with simple http server python3)
|
||||||
8
monithor-client/DEBIAN/postinst
Executable file
8
monithor-client/DEBIAN/postinst
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Update man page"
|
||||||
|
mkdir /var/cache/man/oldlocal/fr -p
|
||||||
|
mandb 2>&1 > /dev/null
|
||||||
|
|
||||||
|
echo "Fin d'installation"
|
||||||
|
|
||||||
8
monithor-client/DEBIAN/postrm
Executable file
8
monithor-client/DEBIAN/postrm
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Update man page"
|
||||||
|
#mandb 2>&1 > /dev/null
|
||||||
|
|
||||||
|
echo "Fin d'installation"
|
||||||
|
|
||||||
|
mkdir /var/cache/man/oldlocal/fr -p
|
||||||
@ -4,7 +4,7 @@
|
|||||||
# Provides: monithor-c
|
# Provides: monithor-c
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop:
|
# Default-Stop:
|
||||||
# Short-Description: MoniThor Server
|
# Short-Description: MoniThor client
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@ -16,19 +16,25 @@ umask 022
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ ! -z $(ps axf| grep monithor-client | grep -v grep) ]
|
if [ ! -z "$(ps axf| grep monithor-client | grep -v grep)" ]
|
||||||
then
|
then
|
||||||
logger "monithor-client is running ..."
|
logger "monithor-client is running ..."
|
||||||
|
exit
|
||||||
else
|
else
|
||||||
logger "Starting MoniThor Server"
|
logger "Starting MoniThor client "
|
||||||
/usr/local/bin/monithor-client start
|
/usr/local/bin/monithor-client start
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
logger "Stoping MoniThor server" "monithor-c" || true
|
logger "Stoping MoniThor client " "monithor-c" || true
|
||||||
/usr/local/bin/monithor-client stop
|
/usr/local/bin/monithor-client stop
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
logger "status MoniThor client " "monithor-c" || true
|
||||||
|
[ $(ps axf| grep MoniThor | grep SCREEN | wc -l) -gt 1 ] && echo "monithor-c is running" || echo "montihor-c is dead"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: /etc/init.d/monithor-c {start|stop|status}" || true
|
echo "Usage: /etc/init.d/monithor-c {start|stop|status}" || true
|
||||||
exit 1
|
exit 1
|
||||||
4
monithor-client/etc/monithor-client/conf/sample.cfg
Normal file
4
monithor-client/etc/monithor-client/conf/sample.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#IP:PORT#SONDE#ARGUMENT
|
||||||
|
#Ex :
|
||||||
|
#10.10.10.3:1666#part#/home/isen|50|80
|
||||||
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
RemoteIp=10.10.10.3:1666
|
|
||||||
LocalPassword='Evil@MonitoR-666'
|
LocalPassword='Evil@MonitoR-666'
|
||||||
Crypted=no
|
Crypted=no
|
||||||
Rotation=1
|
Rotation=1
|
||||||
@ -1,20 +1,26 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /etc/monithor-client/service.cfg
|
source /etc/monithor-client/service.cfg
|
||||||
if [[ $(id -u) != "0" ]]
|
|
||||||
then
|
|
||||||
echo "Not Root"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
Exit () {
|
||||||
|
|
||||||
|
[[ "$1" == "root" ]] && echo "You have to be root ..."
|
||||||
|
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $(id -u) != "0" ]]
|
||||||
|
then
|
||||||
|
Exit root
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "start" ]]
|
if [[ "$1" == "start" ]]
|
||||||
then
|
then
|
||||||
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
||||||
rm /tmp/Monitor* /tmp/webmonithor &> /dev/null
|
rm /tmp/Monitor* /tmp/webmonithor &> /dev/null
|
||||||
|
|
||||||
TotalConfig=$(ls -1 /etc/monithor-client/conf/ | grep Card_.*\.cfg|wc -l)
|
TotalConfig=$(ls -1 /etc/monithor-client/conf/ | grep .*\.cfg| wc -l)
|
||||||
for Conf in $(ls -1 /etc/monithor-client/conf/ | grep Card_.*\.cfg)
|
for Conf in $(ls -1 /etc/monithor-client/conf/ | grep .*\.cfg)
|
||||||
do
|
do
|
||||||
screen -dmS ${Conf} bash /usr/local/bin/monithor-client.d/MoniThor ${Conf}
|
screen -dmS ${Conf} bash /usr/local/bin/monithor-client.d/MoniThor ${Conf}
|
||||||
done
|
done
|
||||||
@ -23,7 +29,7 @@ fi
|
|||||||
|
|
||||||
if [[ "$1" == "stop" ]]
|
if [[ "$1" == "stop" ]]
|
||||||
then
|
then
|
||||||
killall python &> /dev/null
|
killall python3 &> /dev/null
|
||||||
rm /tmp/Monithor* &> /dev/null
|
rm /tmp/Monithor* &> /dev/null
|
||||||
touch /tmp/endmonitor
|
touch /tmp/endmonitor
|
||||||
|
|
||||||
34
monithor-client/usr/local/bin/monithor-client.d/MoniThor
Executable file
34
monithor-client/usr/local/bin/monithor-client.d/MoniThor
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
SondeFile=/etc/monithor-client/sonde.cfg
|
||||||
|
source /etc/monithor-client/service.cfg
|
||||||
|
source /usr/local/bin/monithor-client.d/MoniThorFnct
|
||||||
|
|
||||||
|
ConfFile=$1
|
||||||
|
|
||||||
|
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
||||||
|
while [[ ! -f /tmp/endmonitor ]]
|
||||||
|
do
|
||||||
|
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
||||||
|
then
|
||||||
|
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
||||||
|
sleep ${Rotation}
|
||||||
|
else
|
||||||
|
while read DATA
|
||||||
|
do
|
||||||
|
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
||||||
|
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
|
||||||
|
Cmd=$(echo $DATA| cut -d"#" -f2)
|
||||||
|
Arg=$(echo $DATA| cut -d"#" -f3)
|
||||||
|
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
||||||
|
Ret=$?
|
||||||
|
if [[ ! -z $(echo $DATA | grep ^"[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*:[0-9]*#.*#" ) ]]
|
||||||
|
then
|
||||||
|
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
|
||||||
|
fi
|
||||||
|
done < /etc/monithor-client/conf/${ConfFile}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ CheckAllEnd() {
|
|||||||
echo '
|
echo '
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
<title>MoniThor on '$(hostname)' </title>
|
||||||
<meta http-equiv="refresh" content="1" />
|
<meta http-equiv="refresh" content="1" />
|
||||||
</head>
|
</head>
|
||||||
<title>MONITHOR</title>
|
<title>MONITHOR</title>
|
||||||
@ -31,7 +31,7 @@ CheckAllEnd() {
|
|||||||
<table border="1" color="#FFFFFF">
|
<table border="1" color="#FFFFFF">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4">MoniThor Result</th>
|
<th colspan="5">MoniThor Result</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>' > /tmp/webmonithor
|
<tbody>' > /tmp/webmonithor
|
||||||
@ -3,18 +3,20 @@
|
|||||||
|
|
||||||
pushd /var/www/html/monithor
|
pushd /var/www/html/monithor
|
||||||
source /usr/local/bin/monithor-client.d/MoniThorFnct
|
source /usr/local/bin/monithor-client.d/MoniThorFnct
|
||||||
python -m SimpleHTTPServer ${1} &
|
python3 -m http.server ${1} &
|
||||||
|
|
||||||
|
|
||||||
echo '<html>
|
echo '<html>
|
||||||
<head>
|
<head>
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
<title>MoniThor on '$(hostname)' </title>
|
||||||
<meta http-equiv="refresh" content="1" />
|
<meta http-equiv="refresh" content="1" />
|
||||||
</head>
|
</head>
|
||||||
<title>MONITHOR</title>
|
<title>MONITHOR</title>
|
||||||
|
|
||||||
!!!! Initialization !!!!
|
!!!! Initialization !!!!
|
||||||
|
|
||||||
|
Warning : check the config /etc/monithor-client/conf/*cfg
|
||||||
|
|
||||||
' > index.html
|
' > index.html
|
||||||
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
while [[ ! -f /tmp/endmonitor ]]
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Package: monithor-server
|
Package: monithor-server
|
||||||
Version: 1.0
|
Version: 1.0
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Dependsd:netcat,cryptcat
|
Dependsd:netcat,cryptcat,screen,python3,netcat,cryptcat,elinks
|
||||||
Maintainer: Guillaume Astier <guillaume@gastier.net>
|
Maintainer: Guillaume Astier <guillaume@gastier.net>
|
||||||
Description: monithor Server (nrpe like in netcat/cryptcat and bash)
|
Description: monithor server (netcat & snort)
|
||||||
8
monithor-server/DEBIAN/postinst
Executable file
8
monithor-server/DEBIAN/postinst
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Update man page"
|
||||||
|
#mkdir /var/cache/man/oldlocal/fr -p
|
||||||
|
#mandb 2>&1 > /dev/null
|
||||||
|
|
||||||
|
echo "Fin d'installation"
|
||||||
|
|
||||||
8
monithor-server/DEBIAN/postrm
Executable file
8
monithor-server/DEBIAN/postrm
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Update man page"
|
||||||
|
#mandb 2>&1 > /dev/null
|
||||||
|
|
||||||
|
echo "Fin d'installation"
|
||||||
|
|
||||||
|
mkdir -p /var/cache/man/oldlocal/fr
|
||||||
@ -16,9 +16,10 @@ umask 022
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
if [ ! -z $(ps axf| grep monithor-server | grep -v grep) ]
|
if [ ! -z "$(ps axf| grep monithor-server | grep -v grep)" ]
|
||||||
then
|
then
|
||||||
logger "monithor-server is running ..."
|
logger "monithor-server is running ..."
|
||||||
|
exit
|
||||||
else
|
else
|
||||||
logger "Starting MoniThor Server"
|
logger "Starting MoniThor Server"
|
||||||
/usr/local/bin/monithor-server start
|
/usr/local/bin/monithor-server start
|
||||||
@ -29,6 +30,13 @@ case "$1" in
|
|||||||
/usr/local/bin/monithor-server stop
|
/usr/local/bin/monithor-server stop
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
logger "status MoniThor server" "monithor-d" || true
|
||||||
|
[ "$(ps axf| grep '/usr/local/bin/monithor-server'|grep -v grep)" ] && echo "monithor-d is running" || echo "montihor-d is dead"
|
||||||
|
|
||||||
|
;;
|
||||||
|
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Usage: /etc/init.d/monithor-d {start|stop|status}" || true
|
echo "Usage: /etc/init.d/monithor-d {start|stop|status}" || true
|
||||||
exit 1
|
exit 1
|
||||||
@ -1,5 +1,5 @@
|
|||||||
LocalIp=127.0.0.1
|
RemoteIp=10.10.10.4
|
||||||
LocalPort=8080
|
LocalPort=1666
|
||||||
#########
|
########
|
||||||
Crypted=no
|
Crypted=no
|
||||||
LocalPassword='Evil@MonitoR-666'
|
LocalPassword='Evil@MonitoR-666'
|
||||||
3
monithor-server/etc/monithor-server/sonde.cfg
Normal file
3
monithor-server/etc/monithor-server/sonde.cfg
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
file#file-present.sh
|
||||||
|
part#part-space.sh
|
||||||
|
process#process-present.sh
|
||||||
@ -5,21 +5,30 @@ ScriptDir=/usr/local/bin/monithor-server.d/
|
|||||||
SondeFile=/etc/monithor-server/sonde.cfg
|
SondeFile=/etc/monithor-server/sonde.cfg
|
||||||
source /etc/monithor-server/service.cfg
|
source /etc/monithor-server/service.cfg
|
||||||
|
|
||||||
|
Exit () {
|
||||||
|
|
||||||
|
[[ "$1" == "root" ]] && echo "You have to be root ..."
|
||||||
|
#[[ "$1" == "Config" ]] && echo "Ip configuration will failed"
|
||||||
|
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $(id -u) != "0" ]]
|
if [[ $(id -u) != "0" ]]
|
||||||
then
|
then
|
||||||
echo "Not Root"
|
Exit root
|
||||||
exit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#[[ -z $(ifconfig | grep inet | awk '{print $2}' | grep $RemoteIp) ]] && Exit Config
|
||||||
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort} " || NcCmd="nc -l ${LocalIp} ${LocalPort}"
|
|
||||||
|
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${RemoteIp} -p ${LocalPort} " || NcCmd="nc -l ${RemoteIp} -p ${LocalPort}"
|
||||||
|
|
||||||
if [[ "${1}" == "start" ]]
|
if [[ "${1}" == "start" ]]
|
||||||
then
|
then
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
#coproc cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort}
|
#coproc cryptcat -k ${LocalPassword} -l ${RemoteIp} -p ${LocalPort}
|
||||||
coproc eval ${NcCmd}
|
coproc eval ${NcCmd}
|
||||||
while read -r cmd; do
|
while read -r cmd; do
|
||||||
logger "Running $cmd"
|
logger "Running $cmd"
|
||||||
18
monithor-server/usr/local/bin/monithor-server.d/part-space.sh
Executable file
18
monithor-server/usr/local/bin/monithor-server.d/part-space.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
source $(dirname $0)/FunctionOutput
|
||||||
|
|
||||||
|
Part="$(echo $1 | cut -d"|" -f1)"
|
||||||
|
Min="$(echo $1 | cut -d"|" -f2)"
|
||||||
|
Max="$(echo $1 | cut -d"|" -f3)"
|
||||||
|
|
||||||
|
[[ -z ${Part} ]] && Exit "5|no argument"
|
||||||
|
[[ ! -d ${Part} ]] && Exit "2|Part $Part don't exist"
|
||||||
|
[[ -z $(mount | grep -w ${Part}) ]] && Exit "2|$Part is not a partition"
|
||||||
|
|
||||||
|
Size=$(df -h ${Part} | grep -v Filesystem | awk '{print $5}' | sed "s#%##g")
|
||||||
|
|
||||||
|
[[ ${Size} -lt ${Min} ]] && Exit "0|Part $Part is under ${Min}% : ${Size}"
|
||||||
|
[[ ${Size} -gt ${Max} ]] && Exit "2|Part $Part is over ${Max}% : ${Size}"
|
||||||
|
[[ ${Size} -gt ${Min} ]] && Exit "1|Part $Part is between ${Min}% and ${Max}% : ${Size}"
|
||||||
11
monithor-server/usr/local/bin/monithor-server.d/process-present.sh
Executable file
11
monithor-server/usr/local/bin/monithor-server.d/process-present.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
source $(dirname $0)/FunctionOutput
|
||||||
|
|
||||||
|
Process="${1}"
|
||||||
|
|
||||||
|
[[ -z ${Process} ]] && Exit "5|no argument"
|
||||||
|
|
||||||
|
[[ ! -z $(ps axf | grep ${Process}| grep -v grep) ]] && Exit "0|Process $Process is running" || Exit "2|Process $Process is NOT running"
|
||||||
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd $(dirname $0)/conf-server/
|
|
||||||
|
|
||||||
ScriptDir=$(pwd)/scripts/
|
|
||||||
SondeFile=$(pwd)/sonde.cfg
|
|
||||||
source service.cfg
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort} " || NcCmd="nc -l ${LocalIp} ${LocalPort}"
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
#coproc cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort}
|
|
||||||
coproc eval ${NcCmd}
|
|
||||||
while read -r cmd; do
|
|
||||||
logger "Running $cmd"
|
|
||||||
cpt=0
|
|
||||||
while read DATA
|
|
||||||
do
|
|
||||||
Sonde=$(echo ${DATA}| cut -d"#" -f1)
|
|
||||||
Exec=$(echo ${DATA}| cut -d"#" -f2)
|
|
||||||
RealCmd=$(echo ${cmd} | cut -d"#" -f1)
|
|
||||||
ArgCmd=$(echo ${cmd} | cut -d"#" -f2)
|
|
||||||
if [[ "${RealCmd}" == "$Sonde" ]]
|
|
||||||
then
|
|
||||||
logger "Exec $Exec $Arg $cpt"
|
|
||||||
[ "$1" == '-d' ] && echo "############ Exec $Exec $Arg $cpt" 1>&2
|
|
||||||
bash ${ScriptDir}/${Exec} $ArgCmd
|
|
||||||
cpt=$((cpt+1))
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done < ${SondeFile}
|
|
||||||
[[ "${cpt}" -eq 0 ]] && logger "You Failed $Sonde $Exec $Arg"
|
|
||||||
|
|
||||||
done <&"${COPROC[0]}" >&"${COPROC[1]}"
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
Exit() {
|
|
||||||
|
|
||||||
|
|
||||||
Val=$(echo $1| cut -d"|" -f1)
|
|
||||||
Txt=$(echo $1| cut -d"|" -f2)
|
|
||||||
echo "$Val|$Txt"
|
|
||||||
exit $Val
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
source $(dirname $0)/FunctionOutput
|
|
||||||
|
|
||||||
File="${1}"
|
|
||||||
|
|
||||||
[[ -z ${File} ]] && Exit "5|no argument"
|
|
||||||
|
|
||||||
|
|
||||||
[[ -f ${File} ]] && Exit "0|File $File exist" || Exit "2|File $File is NOT present"
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
LocalIp=127.0.0.1
|
|
||||||
LocalPort=8080
|
|
||||||
#########
|
|
||||||
Crypted=no
|
|
||||||
LocalPassword='Evil@MonitoR-666'
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
network#ip.sh
|
|
||||||
file#file-present.sh
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user