Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help to prepare script for monitor services Post 303045419 by yash_message on Friday 20th of March 2020 08:47:10 AM
Old 03-20-2020
Help to prepare script for monitor services

I need to monitor services in rhel 8
below are the service......
crond
chronyd
rsyslogd
sshd
sssd
firewalld

Scripts..........
Code:
#!/bin/bash
for i in "${SERVICES[@]}"
do
###CHECK SERVICE####
`pgrep $i `
STATS=(echo $?)

if [  $STATS == 0  ]
then
echo   "$i is running"
else
echo   "$i is not running"
fi
done

but after run script, output does not come. please help, where is the problem in scripts.

--- Post updated at 07:17 PM ---

I prepared another script. but getting error.

Code:
#!/bin/bash
for i in `cat SERVICES`
do
###CHECK SERVICE####
status=systemctl | grep running |grep $i |awk '{print $4}'
if [ $status -eq running ]
then
     echo "$i is running"
else
     echo "$i is not running"
fi
done

Output-

[root@localhost ~]# sh service1.sh
service1.sh: line 6: [: -eq: unary operator expected
crond is not running
service1.sh: line 6: [: -eq: unary operator expected
chronyd is not running
service1.sh: line 6: [: -eq: unary operator expected
rsyslogd is not running
service1.sh: line 6: [: -eq: unary operator expected
sshd is not running
service1.sh: line 6: [: -eq: unary operator expected
sssd is not running
service1.sh: line 6: [: -eq: unary operator expected
firewalld is not running


Why it is coming error.
 

10 More Discussions You Might Find Interesting

1. SuSE

Script to disable services

Hi All, I want to disable bunch of unused services on SLES and RHEL to improve the performance. Since we have more than 100 servers to disable services, I want to do with some script. Any one can give me an idea how to write a script to disable services. Thanks (1 Reply)
Discussion started by: s_linux
1 Replies

2. AIX

Startup script and services

Guy's What the exact steps to mention for example this script /usr/start/start.sh to be as start up script , I want it to be automatically started when I reboot the server . (8 Replies)
Discussion started by: ITHelper
8 Replies

3. AIX

How to monitor websphere services down?

if websphere services is down, any unix command or scripts can send alert? (1 Reply)
Discussion started by: rainbow_bean
1 Replies

4. Shell Programming and Scripting

Need script to restart the services

Hi Guys, I need bash script to restart the service. 1. Disable the service called SASM svcadm disable sasm 2. if service went to maintenance mode then it shuld clear it with below command svcadm clear sasm 3.or else it should restart the mysql service /etc/init.d/mysql stop... (1 Reply)
Discussion started by: bapu1981
1 Replies

5. Red Hat

Restart of services if port no is changed in /etc/services in RHEL

I had a doubt if any services need to be restarted if port no in /etc/services in an RHEL setup is changed. For eg, the port no of 443 for SSL may need to be changed. I hope my query is clear whether any services need to be restarted if port no in /etc/services is changed. Please revert with... (10 Replies)
Discussion started by: RHCE
10 Replies

6. Shell Programming and Scripting

Script to Start services based on dependent services on other AIX machine

Hi, I just started working on a script. After my research, i found a command which can help me: AIM: To build a script which starts the services (Services 1) on server 1 automatically whenever its down. And it has a dependency on other service (Service 2) on Server 2. So my script has to... (4 Replies)
Discussion started by: draghun9
4 Replies

7. Shell Programming and Scripting

Monitor the services by script

I developed for monitoring the network connections among the branch servers as I given below as script.But I don't know how to monitor the services through network script whether the services is running or not. eg : I want to check the postgres service for all the branch servers through network... (0 Replies)
Discussion started by: kannansoft1985
0 Replies

8. Shell Programming and Scripting

Monitor some of network services

Hi I want to write a script for netflow service because my service doesnt send any packet to netflow walker (server). Although the service is started but it does not send any packet to server until i restart the service I want to write a script in order to restart the service... (7 Replies)
Discussion started by: mohsen1366
7 Replies

9. Infrastructure Monitoring

Searching for Saas Monitor service which monitor my servers which are sitting in different providers

Sorry if this is the wrong forum Searching for Saas Monitor service which monitor my servers which are sitting in different providers . This monitor tool will take as less CPU as possible , and will send info about the server to main Dashboard. The info I need is CPU / RAM / my servers status (... (1 Reply)
Discussion started by: umen
1 Replies

10. UNIX for Advanced & Expert Users

Script monitor website wth default tomcat script

Hi all, on our application server we have the following script that monitor the status of the website, my problem here is that i have edite the retries from 3 to 5, and the timewait to 120 second, so the script should check 5 times every 2 minutes, and if the fifth check fails it must restart... (0 Replies)
Discussion started by: charli1
0 Replies
TAPECALC(1)						      General Commands Manual						       TAPECALC(1)

NAME
tapecalc - full-screen editing calculator USAGE
tapecalc [options] [file-specifications] SYNOPSIS
Tapecalc is a fixed-point calculator that operates as a full-screen editor. DESCRIPTION
Tapecalc performs fixed-point computation. It is designed for use as a checkbook or expense-account balancing tool. Tapecalc maintains a running result for each operation. You may scroll to any position in the expression list and modify the list. Enter data by typing numbers (with optional decimal point), separated by operators. An output transcript may be saved and reloaded for further editing. Scripts are loaded from left to right (with the "output" processed first). OPTIONS
Command line options of tapecalc are: -h Prints the list of options. -i interval Sets compounding interval for interest computation. -o script Specify file in which to save output transcript. -p num Sets precision (number of digits after the decimal place). OPERATIONS
Computations: The operators are all single-character: + begins an addition - begins a subtraction ~ negates the result * begins a multiplication / begins a division % begins an interest computation (uses interval): rate=number. $ begins a sales-tax computation: rate=number. ( opening parenthesis. This may enclose a unary '-', more parentheses, or data (implicit unary '+'). ) closing parenthesis, expects another operator, not data. = flushes out the current number, forces re-computation of the running result. A space flushes out the current number-input, and (by default) sets the next operator to be the same as the current one. You may repeat the last arithmetic operation of any type: a repeats the last '+' (default 0). s repeats the last '-' (default 0). n repeats the last '~'. m repeats the last '*' (default 1). d repeats the last '/' (default 1). i repeats the last '%' (default 4). t repeats the last '$' (default 4). You may toggle the prefix operator of any number by typing a single character: A toggles the operator to '+'. S toggles the operator to '-'. N toggles the operator to '~'. M toggles the operator to '*'. D toggles the operator to '/'. I toggles the operator to '%'. T toggles the operator to '$'. Editing: As you enter data, you may edit it. A backspace deletes the last digit of the current number (if it is visible). Use the arrow keys or vi-style 'h' and 'l' to move left and right within the line. Other editing commands include u undoes the last x/X command (restricted to restoring the current data only). x deletes the current data. If the data is null, deletes the following line. X deletes the current data. If the data is null, deletes the preceding line and moves up. o opens a new line after the current line. O opens a new line before the current line. # edit the associated comment. An "open" permits you to insert a new operator and data into the expression list. You may type an operator character (e.g., '+'), and continue with the new data, or an operator-repeat (e.g., 'A'). In either case, you may edit the new data, just as you would the old data. A 'u' (or other toggle, such as 'o', 'O', or 'q') typed after an open will undo the open (and close it). Scrolling/cursor movement: H move to the top line on the screen. M move to the middle line on the screen. L move to the last line on the screen CTL/F scroll forward one screen. CTL/B scroll backward one screen. j move forward one line. k move backward one line. z<CR> move the current line to the top of the screen. z. move the current line to the middle of the screen. z- move the current line to the bottom of the screen. Like vi, tapecalc allows you to jump to a particular line with a ":" command :$ jumps to the last entry :1 jumps to the first entry. Scripts: Transcript files are formatted to permit line-oriented entries: <operator><value><tab><ignored><tab># comment The transcripts saved by tapecalc contain the running result in the "ignored" part. To exit without saving a transcript, type 'Q'. A nor- mal exit, by typing 'q', saves the list of operators, data (and running result) in the specified file. You can read and write scripts without leaving tapecalc. reads a script at the current entry :e file clears the current script and reads a script from the file. :f shows the current script name. :r file :w file writes a script to the specified file. ENVIRONMENT
Tapecalc runs in a portable UNIX(R) environment. FILES
Tapecalc is a single binary module, with a help file tapecalc.hlp installed in the same directory. FUTURE WORK
It would be nice to be able to change the precision within the program. In particular, the interest and sales tax computations would be more useful if their precision was independent of the running total. AUTHOR
Thomas Dickey SEE ALSO
wc (1), vi (1) TAPECALC(1)
All times are GMT -4. The time now is 10:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy