idrisa
February 1, 2024, 6:44am
1
Hi,
I am trying to create a bash script which can create a csv file as per below.
File system check can be OK if it is below 80% usage.
Please help me
Server Uptime - days SSH-Login Check SNMP Status File System Status
abcd 41 OK- Local login OK OK
efgh 30 OK-Local login OK OK
And what code did you try so far?
Where do you get server names from?
This structure is unclear, where are the commas supposed to be?
Given the use of SNMP, is this data you're polling from a NetCool or similar report?
If so, what is the format of the original data?
Welcome @idrisa !
Please wrap your samples in triple-backticks markdowns, to keep the original format!
(The little terminal icon at the top of the edit window provides them.)
I edited your initial post. Maybe you want to re-edit it and adjust the spacing.?
idrisa
February 1, 2024, 12:16pm
5
idrisa:
basically I am not really worried about exact spacing.
As long as you get the idea that I am trying to get the headings with Server name, uptime of the server, ssh login works, SNMP status is up, and the file systems are under the 90% mark.
I want to use a for loop so i can run from my server and cat for the client servers.
I have private and public keys already setup.
My bash scripting is very limited that is why i need help. Even perl script will do.
Server Uptime - days SSH-Login Check SNMP Status File System
abcd 41 OK- Local login OK OK
efgh 30 OK-Local login OK OK
Server Uptime - days SSH-Login Check SNMP Status File System Status
abcd 41 OK- Local login OK OK
efgh 30 OK-Local login OK OK
I'm sorry, but this still doesn't help.
Maybe instead of duplicating your original post and adding unformatted outputs again, try re-editing original post to represent the actual formatting you want to retain.
No answers about any input data, neither code snippets were provided so far.
Collect the raw data like this?
#!/bin/bash
servers=(
abcd
efgh
)
for server in "${servers[@]}"
do
echo "$server"
ssh -n "$server" '
uptime
service snmpd status
df -klP
'
echo
done
Hi @idrisa ,
Do you already have the data and just need to aggregate it into a report? Or do you also need to collect the data.
So you're at least wanting some logic to interpret the data and later output based on said interpretation.
idrisa:
Please help me
Please share what you have tried to do already.
I'm guessing that you are wanting CSV output something like the following:
Server,Uptime - days,SSH-Login Check,SNMP Status,File System Status
abcd,41,OK- Local login,OK,OK
efgh,30,OK-Local login,OK,OK
(I tried to preserve white space that I thought was important.)
The scope of your request is highly dependent on which of the following three things you're really asking for:
Help collecting the data, interpreting it, and reporting it.
Help interpreting the data and reporting it.
Help reporting the data.
We need some more information on what OS the Bash script is running on and if collecting the data, what OS the remote systems are running.