I need to remotely periodically check if a Linux file system is mounted read only on lots of servers. The only tools at my disposal in this instance are the usual CLI scripting languages (BASH/Perl/Python), SSH and SNMP.
My thoughts so far are:
- Share SSH key and execute the mount command remotely, grep/awk-ing for the RO flag on the given mountpoint.
- Check via SNMP, although I'm not certain if this information is available or how easy that is.
- Attempt to SCP a file across, or remotely touch a file.
The SNMP method is the nicest/cleanest I can think of, however I'm at a loss on how to do this as CLI SNMP seems like a nightmare, especially if I need to run through a decision process to find an index based on a given mountpoint.
Ideally I'd like to pull this off using only BASH (inc. sed/awk/grep etc) and SNMP but need some guidance on where to begin! snmpd is already instaled and configured for v2 on all the servers in question.
The final use of this script will be as a Nagios command.
Many thanks in advance for any help!
Note We already have cacti/nagios set up monitoring 100s of servers, I forget to mention this when originally posting!