Skip to content

ldmcclatchey/Python

Repository files navigation

Python

Author: Leon McClatchey
Language: Python
OS: Linux Notes: All of the scripts here does use the python library argparse to obtain the required parameters.

Nagios Plugins

*** Installation: ***

  1. Install Script in Nagios Folder and Confirm the permissions are minimally 755
  2. Update the Resources configuration to insure the designated paths, users, and passwords exist
  3. Update the Commands for each script with the correct parameters:
    1. Storage.py: command_line $USER1$/Storage.py -H $HOSTADDRESS$ -c $USER3$ -n $USER9$ $ARG1$
    2. Networks.py: command_line $USER1$/Networks.py -H $HOSTADDRESS$ -c $USER3$ -n $USER9$ $ARG1$
    3. check_updates.py: command_line $USER1$/check_updates.py -H $HOSTNAME$ -n $USER9$ $ARG1$
  4. Update the Services Configuration:
    1. Bind the service command to the command, adding any addional parameters
    2. Added the desired hostnames or hostgroup_names to the service *** Notes: *** These scripts were created on RedHat 10 with Python 3.12.9 and tested on Nagios running on the same machine.

Storage.py

Description: Utilizes SNMP calls to find the storage devices on a host
Gets the name of the device, Total Capacity, and Amount Used
Then from the SNMP Data, additional information is calculated
The results are then displayed to the command line,
which can be read by a NMS service such as Nagios
Requirements: This is a Standalone script, so no user libraries are called
However, if a log is maintained, it will be in the NMS/Nagios log folder
This script does rely on netsnmp availability on the server
The Availability of the MIB is all required
Libraries argparse and IPy must be installed
Linux Hosts, /etc/snmp/snmpd.conf must contain the line includeAllDisks

Networks.py

Description: Uses SNMP to determine what the active interfaces are,
Grabbing the pertinent statistics of the active interfaces.
This script does use similar functions as the Storage.py script
except it is focused more on Network interfaces instead of Storage Devices,
But, This script has been set up as a standalone script as well.

check_updates.py

Description: Checks the update status of Linux systems
The nagios user must be allowed ssh into the remote system with keys
This requires a nagios home directory to have all the keys
if these keys have been created, they can be copied to the Nagios Home folder
But the permissions must then be adjusted
The key needs to be copied to the remote user@host via the nagios user
Requirements: This is a Standalone script, so no user libraries are called
However, if a log is maintained, it will be in the NMS/Nagios log folder
All Hosts referenced should exist in the local /etc/hosts file
Libraries paramiko, and argparse must be installed

Other Utility Scripts

Stocks.py

*** Description: *** This script was written on a machine running OpenSUSE Leap 16 with Python version 3.13.5
it reads a mysql database to find what stock tickers to look for
it then uses the yfinance library to find the information for that ticker
the results are then saved to the same mysql database. *** Requirements: *** This script requires a current version of yfinance and pymysql which is compatible with python 3.13.5

About

Projects Written in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Contributors

Languages