Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
ecd2aa97
Commit
ecd2aa97
authored
Aug 14, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add nagios-monit.sh
parent
e794fd68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
nagios-monit.sh
nagios/nagios-monit.sh
+85
-0
No files found.
nagios/nagios-monit.sh
0 → 100755
View file @
ecd2aa97
#!/bin/bash
SERVER
=
$1
VZ
=
$2
if
[
$#
-ne
2
]
then
echo
-e
"
\n
Usage:
\n
./nagios-monit.sh HOSTNAME CTID
\n
or
\n
./nagios-monit.sh HOSTNAME all
\n
"
exit
1
fi
createblock
()
{
SERVER
=
$1
VZ
=
$2
IP
=
$(
ssh
$SERVER
" vzlist -a|tr -s ' '|cut -b2-|grep '^
$VZ
'|cut -f 4 -d' ' "
)
if
[
x
$IP
=
x
]
then
echo
"Connection error to
$SERVER
or no such CTID "
exit
2
fi
if
[
$IP
=
-
]
then
echo
" WARNING: The ip address of vz
$VZ
is unknown, correct it manually"
IP
=
''
fi
NAME
=
$(
ssh
$SERVER
" vzlist -a|tr -s ' '|cut -b2-|grep '^
$VZ
'|cut -f 5 -d' ' "
)
if
[
$NAME
=
-
]
then
echo
" WARNING: The CTID name of vz
$VZ
is not defined, used the CTID instead "
NAME
=
"vz
$VZ
"
fi
cat
<<
EOF
> /tmp/nagiosblock
define service {
use local-service-http-monitor
host_name
$SERVER
notifications_enabled 1
service_description MONIT-
$NAME
check_command check_nrpe_arg!check_monit_unisite!
$IP
}
EOF
scp
-q
/tmp/nagiosblock nagios:/tmp/nagiosblock
ssh nagios
cat
/tmp/nagiosblock
\>\>
/etc/nagios/objects/
$SERVER
-monit
.cfg
rm
-f
/tmp/nagiosblock
ssh nagios
rm
-f
/tmp/nagiosblock
echo
"vz
$VZ
- DONE"
}
NRPECHECK
=
$(
ssh
$SERVER
grep
-c
check_monit_unisite /etc/nagios/nrpe.cfg
)
if
[
0
${
NRPECHECK
}
-eq
0
]
then
echo
echo
"WARNING: there is no nrpe command 'check_monit_unisite found"
echo
'Add to /etc/nagios/nrpe.cfg:'
echo
'command[check_monit_unisite]=/usr/lib64/nagios/plugins/check_monit.py -H $ARG1$ -u monit -P <password>'
echo
else
echo
echo
"The nrpe command check_monit_unisite found - OK"
echo
fi
if
[
$VZ
=
all
]
then
VZLIST
=
$(
ssh
$SERVER
' vzlist -a|tr -s " "|cut -f2 -d" "|grep -v CTID '
)
for
i
in
$VZLIST
do
VZ
=
$i
createblock
$SERVER
$VZ
done
else
createblock
$@
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment