Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Telegram, sd* resizing, Docker
  • Loading branch information
NEMS Linux committed Sep 5, 2019
1 parent 16e4c2b commit 5afff61
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
17 changes: 14 additions & 3 deletions data/1.5/nagios/plugins/notify-by-telegram.lua
Expand Up @@ -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")
Expand All @@ -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$
Expand All @@ -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..''
Expand Down
21 changes: 21 additions & 0 deletions data/1.5/nagios/plugins/t
@@ -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.