Re: Question about script alert description

2016-09-19 Thread Bryan Harris
Ah I see, this is another artifact from us having an old-ish version of
Monit.  Where I work we can only use EPEL from RHEL 6 and the guy who
maintains Monit for EPEL is very busy lately and had no time to update to
the latest.  He was also worried about backwards compatibility.  If I had
any idea how to be an EPEL maintainer I could try and help but it looked
very confusing to me (compared to slackware, which is easy enough for me to
handle).  I will probably leave it alone for now, and store it away in the
back of my head that a future update might make the output I'm seeing more
pleasant for me.

Thanks for your help.

V/r,
Bryan

On Mon, Sep 19, 2016 at 4:57 AM, Martin Pala  wrote:

>
> > On 17 Sep 2016, at 18:50, Lutz Mader  wrote:
> >
> > Hi Martin,
> > is this a new mail Format used by monit 5.19. or an old Format?
> >> the prefix "'/usr/local/sbin/inactive.sh' failed with exit status (1)
> -- " is part of the event description.
> >
> >
> > With monit 5.18 I got mails like the following.
> > Monit  Manager_Lsof Status succeeded
> > Monit alert
> > Service Manager_Lsof event Status succeeded
> > at Sat, 10 Sep 2016 09:23:08 on 
> > status succeeded [status=0] -- lsof 1966
> > Yours sincerely, Monit
> >
> >
> > With the monitrc definitions like this.
> > set mail-format { from: mo...@.de
> >  subject: Monit  $SERVICE $EVENT
> >  message: Monit $ACTION
> > Service $SERVICE event $EVENT
> > at $DATE on $HOST
> > $DESCRIPTION
> > Yours sincerely, Monit }
> >
> >
> > Yes, the mail contain the usefull Status Information, but the script
> > Name is not part of the mail.
> > Bye, Lutz
>
> The status succeeded message didn't contain the program name - only the
> status failure event.
>
> We have simplified the messages in the next monit release:
> https://bitbucket.org/tildeslash/monit/commits/
> c8db8020a5e177a9552e92af015056fc162a4268?at=master
>
> Best regards,
> Martin
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Re: Question about script alert description

2016-09-19 Thread Martin Pala

> On 17 Sep 2016, at 18:50, Lutz Mader  wrote:
> 
> Hi Martin,
> is this a new mail Format used by monit 5.19. or an old Format?
>> the prefix "'/usr/local/sbin/inactive.sh' failed with exit status (1) -- " 
>> is part of the event description.
> 
> 
> With monit 5.18 I got mails like the following.
> Monit  Manager_Lsof Status succeeded
> Monit alert
> Service Manager_Lsof event Status succeeded
> at Sat, 10 Sep 2016 09:23:08 on 
> status succeeded [status=0] -- lsof 1966
> Yours sincerely, Monit
> 
> 
> With the monitrc definitions like this.
> set mail-format { from: mo...@.de
>  subject: Monit  $SERVICE $EVENT
>  message: Monit $ACTION
> Service $SERVICE event $EVENT
> at $DATE on $HOST
> $DESCRIPTION
> Yours sincerely, Monit }
> 
> 
> Yes, the mail contain the usefull Status Information, but the script
> Name is not part of the mail.
> Bye, Lutz

The status succeeded message didn't contain the program name - only the status 
failure event.

We have simplified the messages in the next monit release: 
https://bitbucket.org/tildeslash/monit/commits/c8db8020a5e177a9552e92af015056fc162a4268?at=master

Best regards,
Martin
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


RE: Re: Question about script alert description

2016-09-17 Thread Lutz Mader
Hi Martin,
is this a new mail Format used by monit 5.19. or an old Format?
> the prefix "'/usr/local/sbin/inactive.sh' failed with exit status (1) -- " is 
> part of the event description.


With monit 5.18 I got mails like the following.
Monit  Manager_Lsof Status succeeded
Monit alert
Service Manager_Lsof event Status succeeded
at Sat, 10 Sep 2016 09:23:08 on 
status succeeded [status=0] -- lsof 1966
Yours sincerely, Monit


With the monitrc definitions like this.
set mail-format { from: mo...@.de
  subject: Monit  $SERVICE $EVENT
  message: Monit $ACTION
Service $SERVICE event $EVENT
at $DATE on $HOST
$DESCRIPTION
Yours sincerely, Monit }


Yes, the mail contain the usefull Status Information, but the script
Name is not part of the mail.
Bye, Lutz
























---
Mail & Cloud Made in Germany mit 3 GB Speicher!
https://email.freenet.de/mail/Uebersicht?epid=e990450




--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


Re: Question about script alert description

2016-09-13 Thread Martin Pala
Hi,

the prefix "'/usr/local/sbin/inactive.sh' failed with exit status (1) -- " is 
part of the event description. We can simplify that message, the program path 
is not necessary as service name is reported too, but the status value should 
still be part of the event description.

Best regards,
Martin



> On 12 Sep 2016, at 13:50, Bryan Harris  wrote:
> 
> Hi folks,
> 
> I have recently created a script to figure out which users on the local 
> system have expired accounts.  So anyone returned by the script output will 
> be a user account that is expired and can't login.  And if they have a star 
> (*) by their name the account is older than 90 days.
> 
> When I get back the alert email, the description not only has my script 
> output but it also contains its own little info line.
> 
> My script output is just:
> 
> 3 inactive accounts: *user1, user2, *user3
> 
> But When I get an alert it looks like this:
> 
> Description: '/usr/local/sbin/inactive.sh' failed with exit status (1) -- 3 
> inactive accounts: *user1, user2, *user3
> 
> Monit adds this extra line: '/usr/local/sbin/inactive.sh' failed with exit 
> status (1) --
> 
> Does anyone know how to instruct Monit to exclude this line from the 
> $DESCRIPTION field?  I just want the output like this:
> 
> Description: 3 inactive accounts: *user1, user2, *user3
> 
> Here is the way I have entered configuration declaration into Monit.
> 
> check program inactive-accounts with path "/usr/local/sbin/inactive.sh"
>   every "0-3 6 * * *"
>   alert br...@mygreatserver.com  not on { 
> instance, action }
>   if status != 0 then alert
> 
> # vim: ft=config
> 
> I'm running monit from EPEL and the version is: monit-5.14-1.el6.x86_64.
> 
> I don't suppose it matters a lot, but just in case, here is the script.
> 
> #!/bin/bash
> 
> # Let's get a list of accounts likely to be people, not service accounts
> _accounts=`getent --service=files passwd | awk -F: '$3 > 500 && $1 !~ 
> /splunk|service|oracle|nobody|nails/'`
> 
> # What to call the array of inactive accounts
> declare -a inactiveAccounts
> 
> # Today's date
> _todaysDateInDaysSince1970=`echo \`date +%s\`/86400 | bc`
> 
> # Now let's see who's account is inactive, and add it to the array
> for _row in $_accounts ; do
>   _user=`echo $_row | awk -F: '{print $1}'`
>   _accountExpirationInDaysSince1970=`getent --service=files shadow $_user | 
> awk -F: '{print $8}'`
>   if (("$_todaysDateInDaysSince1970" > 
> "$_accountExpirationInDaysSince1970")); then
> if 
> (("$(($_todaysDateInDaysSince1970-$_accountExpirationInDaysSince1970))" > 
> "90")); then
>   inactiveAccounts+=("*$_user")
> else
>   inactiveAccounts+=("$_user")
> fi
>   fi
> done
> 
> # Create a printout suitable for Monit reporting
> _i=0
> printf "Found ${#inactiveAccounts[@]} inactive accounts: "
> for _user in ${inactiveAccounts[@]}; do
>   if (("$_i" > "0")); then
> printf ","
>   fi
>   printf "$_user"
>   (( _i += 1 ))
> done
> printf "\n"
> 
> # Exit code of 0 for Success (no inactive accounts)
> # Exit code of 1 for Alert (inactive accounts)
> if [ "${#inactiveAccounts[@]}" -eq "0" ]; then
>   exit 0
> elif (( "${#inactiveAccounts[@]}" >= "1" )); then
>   exit 1
> fi
> 
> 
> Thanks in advance for any hint or info in the right direction.
> 
> V/r,
> Bryan
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general

--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Re: Question about script alert description

2016-09-12 Thread Geoff Goas
Check the mail-format option in the monit documentation. I believe you can
specify this per service.

An alternative would be to keep it in monit but disable the alerting, and
have the script send the email.

On Mon, Sep 12, 2016 at 4:32 PM, Bryan Harris 
wrote:

> Sure we could do that.  It's just that we went with monit for our
> monitoring (for the most part).  It may not be that big of a concern, just
> seems like it would be nice to have our script output as the full
> description message.  Then any old script could perform any old monit check
> and there would be no difference (in output message style).  As it is, the
> script output has to fight with monit's extra message for space in the
> email (if you want it all on one line).  I guess I could throw a newline in
> there to have it on the next line.  I guess I just don't see any need for
> forcing that message.  If I want to know the return code I could print it
> with my script.
>
> Thanks for the feed back though.  I wonder if they will tell me to just go
> with cron.
>
> V/r,
> Bryan
>
> On Mon, Sep 12, 2016 at 4:23 PM, Geoff Goas  wrote:
>
>> This doesn't answer your question, but is running the script from cron
>> and having it send the email notification not an option?
>>
>> On Mon, Sep 12, 2016 at 7:50 AM, Bryan Harris 
>> wrote:
>>
>>> Hi folks,
>>>
>>> I have recently created a script to figure out which users on the local
>>> system have expired accounts.  So anyone returned by the script output will
>>> be a user account that is expired and can't login.  And if they have a star
>>> (*) by their name the account is older than 90 days.
>>>
>>> When I get back the alert email, the description not only has my script
>>> output but it also contains its own little info line.
>>>
>>> My script output is just:
>>>
>>> 3 inactive accounts: *user1, user2, *user3
>>>
>>> But When I get an alert it looks like this:
>>>
>>> Description: '/usr/local/sbin/inactive.sh' failed with exit status (1)
>>> -- 3 inactive accounts: *user1, user2, *user3
>>>
>>> Monit adds this extra line: '/usr/local/sbin/inactive.sh' failed with
>>> exit status (1) --
>>>
>>> Does anyone know how to instruct Monit to exclude this line from the
>>> $DESCRIPTION field?  I just want the output like this:
>>>
>>> Description: 3 inactive accounts: *user1, user2, *user3
>>>
>>> Here is the way I have entered configuration declaration into Monit.
>>>
>>> check program inactive-accounts with path "/usr/local/sbin/inactive.sh"
>>>   every "0-3 6 * * *"
>>>   alert br...@mygreatserver.com not on { instance, action }
>>>   if status != 0 then alert
>>>
>>> # vim: ft=config
>>>
>>> I'm running monit from EPEL and the version is: monit-5.14-1.el6.x86_64.
>>>
>>> I don't suppose it matters a lot, but just in case, here is the script.
>>>
>>> #!/bin/bash
>>>
>>> # Let's get a list of accounts likely to be people, not service accounts
>>> _accounts=`getent --service=files passwd | awk -F: '$3 > 500 && $1 !~
>>> /splunk|service|oracle|nobody|nails/'`
>>>
>>> # What to call the array of inactive accounts
>>> declare -a inactiveAccounts
>>>
>>> # Today's date
>>> _todaysDateInDaysSince1970=`echo \`date +%s\`/86400 | bc`
>>>
>>> # Now let's see who's account is inactive, and add it to the array
>>> for _row in $_accounts ; do
>>>   _user=`echo $_row | awk -F: '{print $1}'`
>>>   _accountExpirationInDaysSince1970=`getent --service=files shadow
>>> $_user | awk -F: '{print $8}'`
>>>   if (("$_todaysDateInDaysSince1970" > 
>>> "$_accountExpirationInDaysSince1970"));
>>> then
>>> if 
>>> (("$(($_todaysDateInDaysSince1970-$_accountExpirationInDaysSince1970))"
>>> > "90")); then
>>>   inactiveAccounts+=("*$_user")
>>> else
>>>   inactiveAccounts+=("$_user")
>>> fi
>>>   fi
>>> done
>>>
>>> # Create a printout suitable for Monit reporting
>>> _i=0
>>> printf "Found ${#inactiveAccounts[@]} inactive accounts: "
>>> for _user in ${inactiveAccounts[@]}; do
>>>   if (("$_i" > "0")); then
>>> printf ","
>>>   fi
>>>   printf "$_user"
>>>   (( _i += 1 ))
>>> done
>>> printf "\n"
>>>
>>> # Exit code of 0 for Success (no inactive accounts)
>>> # Exit code of 1 for Alert (inactive accounts)
>>> if [ "${#inactiveAccounts[@]}" -eq "0" ]; then
>>>   exit 0
>>> elif (( "${#inactiveAccounts[@]}" >= "1" )); then
>>>   exit 1
>>> fi
>>>
>>>
>>> Thanks in advance for any hint or info in the right direction.
>>>
>>> V/r,
>>> Bryan
>>>
>>>
>>> --
>>> To unsubscribe:
>>> https://lists.nongnu.org/mailman/listinfo/monit-general
>>>
>>
>>
>>
>> --
>>
>> *Geoff GoasSystems Engineer*
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>>
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>



-- 

*Geoff GoasSystems Engineer*
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Re: Question about script alert description

2016-09-12 Thread Bryan Harris
Sure we could do that.  It's just that we went with monit for our
monitoring (for the most part).  It may not be that big of a concern, just
seems like it would be nice to have our script output as the full
description message.  Then any old script could perform any old monit check
and there would be no difference (in output message style).  As it is, the
script output has to fight with monit's extra message for space in the
email (if you want it all on one line).  I guess I could throw a newline in
there to have it on the next line.  I guess I just don't see any need for
forcing that message.  If I want to know the return code I could print it
with my script.

Thanks for the feed back though.  I wonder if they will tell me to just go
with cron.

V/r,
Bryan

On Mon, Sep 12, 2016 at 4:23 PM, Geoff Goas  wrote:

> This doesn't answer your question, but is running the script from cron and
> having it send the email notification not an option?
>
> On Mon, Sep 12, 2016 at 7:50 AM, Bryan Harris 
> wrote:
>
>> Hi folks,
>>
>> I have recently created a script to figure out which users on the local
>> system have expired accounts.  So anyone returned by the script output will
>> be a user account that is expired and can't login.  And if they have a star
>> (*) by their name the account is older than 90 days.
>>
>> When I get back the alert email, the description not only has my script
>> output but it also contains its own little info line.
>>
>> My script output is just:
>>
>> 3 inactive accounts: *user1, user2, *user3
>>
>> But When I get an alert it looks like this:
>>
>> Description: '/usr/local/sbin/inactive.sh' failed with exit status (1) --
>> 3 inactive accounts: *user1, user2, *user3
>>
>> Monit adds this extra line: '/usr/local/sbin/inactive.sh' failed with
>> exit status (1) --
>>
>> Does anyone know how to instruct Monit to exclude this line from the
>> $DESCRIPTION field?  I just want the output like this:
>>
>> Description: 3 inactive accounts: *user1, user2, *user3
>>
>> Here is the way I have entered configuration declaration into Monit.
>>
>> check program inactive-accounts with path "/usr/local/sbin/inactive.sh"
>>   every "0-3 6 * * *"
>>   alert br...@mygreatserver.com not on { instance, action }
>>   if status != 0 then alert
>>
>> # vim: ft=config
>>
>> I'm running monit from EPEL and the version is: monit-5.14-1.el6.x86_64.
>>
>> I don't suppose it matters a lot, but just in case, here is the script.
>>
>> #!/bin/bash
>>
>> # Let's get a list of accounts likely to be people, not service accounts
>> _accounts=`getent --service=files passwd | awk -F: '$3 > 500 && $1 !~
>> /splunk|service|oracle|nobody|nails/'`
>>
>> # What to call the array of inactive accounts
>> declare -a inactiveAccounts
>>
>> # Today's date
>> _todaysDateInDaysSince1970=`echo \`date +%s\`/86400 | bc`
>>
>> # Now let's see who's account is inactive, and add it to the array
>> for _row in $_accounts ; do
>>   _user=`echo $_row | awk -F: '{print $1}'`
>>   _accountExpirationInDaysSince1970=`getent --service=files shadow
>> $_user | awk -F: '{print $8}'`
>>   if (("$_todaysDateInDaysSince1970" > 
>> "$_accountExpirationInDaysSince1970"));
>> then
>> if 
>> (("$(($_todaysDateInDaysSince1970-$_accountExpirationInDaysSince1970))"
>> > "90")); then
>>   inactiveAccounts+=("*$_user")
>> else
>>   inactiveAccounts+=("$_user")
>> fi
>>   fi
>> done
>>
>> # Create a printout suitable for Monit reporting
>> _i=0
>> printf "Found ${#inactiveAccounts[@]} inactive accounts: "
>> for _user in ${inactiveAccounts[@]}; do
>>   if (("$_i" > "0")); then
>> printf ","
>>   fi
>>   printf "$_user"
>>   (( _i += 1 ))
>> done
>> printf "\n"
>>
>> # Exit code of 0 for Success (no inactive accounts)
>> # Exit code of 1 for Alert (inactive accounts)
>> if [ "${#inactiveAccounts[@]}" -eq "0" ]; then
>>   exit 0
>> elif (( "${#inactiveAccounts[@]}" >= "1" )); then
>>   exit 1
>> fi
>>
>>
>> Thanks in advance for any hint or info in the right direction.
>>
>> V/r,
>> Bryan
>>
>>
>> --
>> To unsubscribe:
>> https://lists.nongnu.org/mailman/listinfo/monit-general
>>
>
>
>
> --
>
> *Geoff GoasSystems Engineer*
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general

Re: Question about script alert description

2016-09-12 Thread Geoff Goas
This doesn't answer your question, but is running the script from cron and
having it send the email notification not an option?

On Mon, Sep 12, 2016 at 7:50 AM, Bryan Harris 
wrote:

> Hi folks,
>
> I have recently created a script to figure out which users on the local
> system have expired accounts.  So anyone returned by the script output will
> be a user account that is expired and can't login.  And if they have a star
> (*) by their name the account is older than 90 days.
>
> When I get back the alert email, the description not only has my script
> output but it also contains its own little info line.
>
> My script output is just:
>
> 3 inactive accounts: *user1, user2, *user3
>
> But When I get an alert it looks like this:
>
> Description: '/usr/local/sbin/inactive.sh' failed with exit status (1) --
> 3 inactive accounts: *user1, user2, *user3
>
> Monit adds this extra line: '/usr/local/sbin/inactive.sh' failed with exit
> status (1) --
>
> Does anyone know how to instruct Monit to exclude this line from the
> $DESCRIPTION field?  I just want the output like this:
>
> Description: 3 inactive accounts: *user1, user2, *user3
>
> Here is the way I have entered configuration declaration into Monit.
>
> check program inactive-accounts with path "/usr/local/sbin/inactive.sh"
>   every "0-3 6 * * *"
>   alert br...@mygreatserver.com not on { instance, action }
>   if status != 0 then alert
>
> # vim: ft=config
>
> I'm running monit from EPEL and the version is: monit-5.14-1.el6.x86_64.
>
> I don't suppose it matters a lot, but just in case, here is the script.
>
> #!/bin/bash
>
> # Let's get a list of accounts likely to be people, not service accounts
> _accounts=`getent --service=files passwd | awk -F: '$3 > 500 && $1 !~
> /splunk|service|oracle|nobody|nails/'`
>
> # What to call the array of inactive accounts
> declare -a inactiveAccounts
>
> # Today's date
> _todaysDateInDaysSince1970=`echo \`date +%s\`/86400 | bc`
>
> # Now let's see who's account is inactive, and add it to the array
> for _row in $_accounts ; do
>   _user=`echo $_row | awk -F: '{print $1}'`
>   _accountExpirationInDaysSince1970=`getent --service=files shadow $_user
> | awk -F: '{print $8}'`
>   if (("$_todaysDateInDaysSince1970" > "$_accountExpirationInDaysSince1970"));
> then
> if (("$(($_todaysDateInDaysSince1970-$_accountExpirationInDaysSince1970))"
> > "90")); then
>   inactiveAccounts+=("*$_user")
> else
>   inactiveAccounts+=("$_user")
> fi
>   fi
> done
>
> # Create a printout suitable for Monit reporting
> _i=0
> printf "Found ${#inactiveAccounts[@]} inactive accounts: "
> for _user in ${inactiveAccounts[@]}; do
>   if (("$_i" > "0")); then
> printf ","
>   fi
>   printf "$_user"
>   (( _i += 1 ))
> done
> printf "\n"
>
> # Exit code of 0 for Success (no inactive accounts)
> # Exit code of 1 for Alert (inactive accounts)
> if [ "${#inactiveAccounts[@]}" -eq "0" ]; then
>   exit 0
> elif (( "${#inactiveAccounts[@]}" >= "1" )); then
>   exit 1
> fi
>
>
> Thanks in advance for any hint or info in the right direction.
>
> V/r,
> Bryan
>
>
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general
>



-- 

*Geoff GoasSystems Engineer*
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general