Skip to content
Permalink
Browse files

Telegram, sd* resizing, Docker

  • Loading branch information...
NEMS Linux
NEMS Linux committed Sep 5, 2019
1 parent 16e4c2b commit 5afff6116336e36df89aba3b8709e61736c5553e
Showing with 35 additions and 3 deletions.
  1. +14 −3 data/1.5/nagios/plugins/notify-by-telegram.lua
  2. +21 −0 data/1.5/nagios/plugins/t
@@ -4,7 +4,7 @@
-- Kaganishu for helping with documentation and improvements for NEMS 1.5
-- NickTheGreek for contributing his findings to help improve functionality for NEMS 1.5

-- VERSION 1.5.1
-- VERSION 1.5.2

https = require('ssl.https')
local handle = io.popen("/usr/local/bin/nems-info alias")
@@ -14,6 +14,17 @@ local nemsalias = string.gsub(result, "\n", "")
local telegram_url = 'https://api.telegram.org/bot' .. arg[1] .. '/sendMessage?'
local chat_id = '-' .. arg[2]:gsub('%g', '')

-- UTF-8 Emojis Based on State
if string.find(arg[5]:lower(), "crit") then
scolor = "🚫" -- No Entry Sign
elseif string.find(arg[5]:lower(), "warn") then
scolor = "⚠️" -- Warning Sign
elseif string.find(arg[5]:lower(), "unknown") then
scolor = "" -- Question Mark
else
scolor = "" -- White Heavy Check Mark
end

Notification = "Notification Type: " .. arg[3] ..'\n' --$NOTIFICATIONTYPE$
Host = "Host: " .. arg[4] ..'\n' --$HOSTNAME$
State = "State: " .. arg[5] ..'\n' --$HOSTSTATE$/$SERVICESTATE$
@@ -23,10 +34,10 @@ local chat_id = '-' .. arg[2]:gsub('%g', '')
Alias = "Reporting NEMS Server: " .. nemsalias .. '\n' --NEMS Server Alias

if (#arg == 8) then --assumes this since 8 arguments have been passed
message = '***** NEMS Linux ***** ' ..'\n' ..'\n' .. Notification .. Host ..State .. Address .. Info .. Date_Time .. Alias
message = scolor .. '\n' .. '\n' .. Notification .. Host ..State .. Address .. Info .. Date_Time .. Alias
else
Service = "Service: " .. arg[8] .. '\n' --$SERVICEDESC$
message = '***** NEMS Linux ***** ' ..'\n' ..'\n' .. Notification .. Host .. Service ..State .. Address .. Info .. Date_Time .. Alias
message = scolor .. '\n' .. '\n' .. '***** NEMS Linux ***** ' ..'\n' ..'\n' .. Notification .. Host .. Service ..State .. Address .. Info .. Date_Time .. Alias
end

local data_str = 'chat_id=' .. chat_id .. '&text=' .. message..''
@@ -0,0 +1,21 @@
#!/bin/bash
fulldev=`/bin/mount | /bin/sed -n 's|^/dev/\(.*\) on / .*|\1|p'`
fulldev="sda1"
if [[ $fulldev == "" ]]; then
echo "Could not determine your root device."
exit 1
fi

rootdev=`echo $fulldev | cut -d "p" -f 1`
if [[ $rootdev == $fulldev ]]; then
rootdev="${fulldev//[!a-z]/}"
fi

rootpart=`echo $fulldev | cut -d "p" -f 2`
if [[ $rootpart == $fulldev ]]; then
rootpart="${fulldev//[!0-9]/}"
fi


echo $rootdev
echo $rootpart

0 comments on commit 5afff61

Please sign in to comment.
You can’t perform that action at this time.