init
This commit is contained in:
		
							parent
							
								
									e5586da25e
								
							
						
					
					
						commit
						e5f10f0374
					
				
							
								
								
									
										21
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								README.md
									
									
									
									
									
								
							@ -1,2 +1,19 @@
 | 
				
			|||||||
# pmpw
 | 
					# Poor Man's Proxmox Watchdog
 | 
				
			||||||
Poor Man's Proxmox Watchdog
 | 
					
 | 
				
			||||||
 | 
					A bash script working as a helthcheck for a VM. 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Takes in a single argument in form of VMID.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Requirements
 | 
				
			||||||
 | 
					Copy/clone code into your directory 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Add exec permission on watchdog.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`chmod u+x /path/to/watchdog.sh`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Examples
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`./watchdog.sh <REPLACE_WITH_VMID>` 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`./watchdog.sh 100` 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										52
									
								
								watchdog.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								watchdog.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# check if $1 exists
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ -z $1 ]]
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					    echo "Pass a VMID."
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#------------------------------------------------
 | 
				
			||||||
 | 
					# CONSTS
 | 
				
			||||||
 | 
					QMLIST="$(qm list | tail -n +2)"
 | 
				
			||||||
 | 
					VMID=$1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#------------------------------------------------ 
 | 
				
			||||||
 | 
					# CODE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# check if container exists
 | 
				
			||||||
 | 
					if ! echo "$QMLIST" | grep -q " $VMID " 
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					    printf "\nNo such VM!\n"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					VMSTATE=$(echo "$QMLIST" | grep " $VMID " | awk '{print $3}')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					case $VMSTATE in
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "running")
 | 
				
			||||||
 | 
					        printf "VM %s" "$VMID" "allready running."
 | 
				
			||||||
 | 
					        echo ""
 | 
				
			||||||
 | 
					        exit 0
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "stopped")
 | 
				
			||||||
 | 
					        printf "Starting VM %s" "$VMID""."
 | 
				
			||||||
 | 
					        echo ""  # To lazy to fix output spacing 
 | 
				
			||||||
 | 
					        qm start "$VMID"
 | 
				
			||||||
 | 
					        exit 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *)
 | 
				
			||||||
 | 
					        printf "\nUnknown state\n"
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# If you have gotify or something simmilar you can paste it under "running") 
 | 
				
			||||||
 | 
					# and under "stopped") for notifications.
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user