code updates
This commit is contained in:
parent
4adaea40ad
commit
6b2f58837e
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
docker run --rm -e DFLT_PASSWORD=$DFLT_PASSWORD -e DFLT_USERNAME=$DFLT_USERNAME -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs --privileged -t scsdansible:april2025 ./run_backup_configs.sh 2>/tmp/run_backups.2.txt >/tmp/run_backups.1.txt
|
||||
docker run --rm -e DFLT_PASSWORD=$DFLT_PASSWORD -e DFLT_USERNAME=$DFLT_USERNAME -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs --privileged -t scsdansible:aug2025 ./run_backup_configs.sh 2>/tmp/run_backups.2.txt >/tmp/run_backups.1.txt
|
||||
docker run --rm -e DFLT_PASSWORD=$DFLT_PASSWORD -e DFLT_USERNAME=$DFLT_USERNAME -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs --privileged -t scsdansible ./run_backup_configs-cisco.sh 2>/tmp/run_cisco_backups.2.txt >/tmp/run_cisco_backups.1.txt
|
||||
docker run --rm -e WLC_PASSWORD=$WLC_PASSWORD -e DFLT_PASSWORD=$DFLT_PASSWORD -e DFLT_USERNAME=$DFLT_USERNAME -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs --privileged -t scsdansible:pyexpect ./run_backup_wlcs.sh 2>/tmp/run_wlc_backups.2.txt >/tmp/run_wlc_backups.1.txt
|
||||
sed -i -E 's/(key|ipsec|wpa-passphrase|password) ([a-f0-9]+) $/ \1 *redacted*/' /home/johnp/scsd-configs/git/configs/wlc/wlc*cfg
|
||||
|
||||
20
code/reconcilevlans.py
Normal file
20
code/reconcilevlans.py
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
import os
|
||||
|
||||
vlandict={}
|
||||
|
||||
for fn in [ '../configs/ct/ct-noc-a8325-a.cfg' ]:
|
||||
print(os.path.basename(fn))
|
||||
with open(fn) as infile:
|
||||
for line in infile:
|
||||
if line.startswith("vlan"):
|
||||
print(line)
|
||||
vlan=line.strip()
|
||||
try:
|
||||
vlandict[vlan].append(fn)
|
||||
except KeyError:
|
||||
vlandict[vlan]=[]
|
||||
vlandict[vlan].append(fn)
|
||||
|
||||
print(vlandict)
|
||||
|
||||
20
code/run_space_check.sh
Executable file
20
code/run_space_check.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# export USERNAME=jpoland.oa;export PASSWORD='XXXXXCHANGEMEXXXXX'; docker run --rm -e PASSWORD=$PASSWORD -e USERNAME=$USERNAME -v /home/johnp/scsd-configs/git:/repo -v /home/johnp/scsd-configs/git/code:/work -v /home/johnp/scsd-configs/git/configs/:/configs --privileged -t scsdansible /work/run_space_check.sh 2>/dev/null | tee space_check.txt
|
||||
#
|
||||
#
|
||||
openfortivpn vpn.scsd.us:10443 --username=$USERNAME --trusted-cert fda7d7ed64a9bd84562c6643e858c4a61cfdc6e90b0d4ee60e07fd0bb7fb7a9f --password=$PASSWORD &
|
||||
while [ ! `ip a | grep -q "inet .*ppp" && echo "1"` ];
|
||||
do
|
||||
#echo checking
|
||||
sleep 1
|
||||
done
|
||||
sleep 3
|
||||
|
||||
for sw in $(ansible-inventory --list -i inventory.yml | jq -r '._meta.hostvars | keys | .[]'| grep -E "a");do
|
||||
ip=$(ansible-inventory --list -i inventory.yml | jq -r '._meta.hostvars["'$sw'"]["ansible_host"]')
|
||||
echo -n $sw $ip" "
|
||||
|
||||
python space_check.py --user $USERNAME --password $PASSWORD --ip $ip --switchname $sw | grep -E 'tmpfs|ERROR'
|
||||
|
||||
done
|
||||
36
code/space_check.py
Normal file
36
code/space_check.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pexpect
|
||||
import argparse
|
||||
import os
|
||||
import tempfile
|
||||
import sys
|
||||
|
||||
def space_check(ip, username, password,switchname):
|
||||
#print(f"Checking {ip}")
|
||||
#print(f"Logging in with {username} and {password}")
|
||||
try:
|
||||
child = pexpect.spawn(f"ssh -oHostKeyAlgorithms=+ssh-ed25519 {username}@{ip}")
|
||||
#child.logfile = sys.stdout.buffer
|
||||
child.expect("password:")
|
||||
child.sendline(password)
|
||||
child.expect("#")
|
||||
child.sendline("start-shell")
|
||||
child.expect('\$')
|
||||
child.sendline("df -h /var/log")
|
||||
child.expect('\$')
|
||||
print(f"-------{switchname}--------")
|
||||
print(child.before.decode("utf-8"))
|
||||
child.sendline("exit")
|
||||
child.expect("#")
|
||||
except:
|
||||
print("ERROR")
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="check /var/log free space")
|
||||
parser.add_argument("--username", help="Username for login", required=True)
|
||||
parser.add_argument("--password", help="Password for login", required=True)
|
||||
parser.add_argument("--ip", help="IP address of switch", required=True)
|
||||
parser.add_argument("--switchname", help="switch name", required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
space_check(args.ip, args.username, args.password,args.switchname)
|
||||
Loading…
x
Reference in New Issue
Block a user