Customize Drive Space Percentage for Notification?

Last night, I began receiving e-mails saying my drive was over 75% full. This morning, I discovered that it sent the notification repeatedly every hour, so I figured it was being done from cron. Checking revealed that, sure enough, /var/lib/asterisk/bin/storage.php was being run hourly from cron. We were in NO danger of running out of drive space as the file system in question had over 40 gig free yet.

Figuring I just had to change a configuration in the GUI, I loaded the System Admin module and went into Notifications. Only thing there was who to send them to. Poking around through the rest of System Admin, then a bunch of other modules did not reveal where to set this parameter. OK, fine - I’ll just change it in the PHP script… only it’s been obfuscated. :angry: :frowning:

So my questions are

  1. How do I go about changing the percentage of space that must be consumed before I am e-mailed about it?
  2. Is there any built-in way to say ‘only bug the admin once every xx hours about this’ for notifications?

As it stands, the only thing I can think of to work around the problem is to somehow de-obfuscate the PHP script or simply write my own & disable the built-in mechanism. (The latter would almost certainly be faster, but it’s highly annoying to buy a ready-to-go phone system and then have to start writing pieces to replace what doesn’t work or isn’t configurable for no real reason…)

The “right” way would be to submit a feature request asking to create a variable in the Settings page somewhere that adjusted that.

Another (even more ridiculous way) would be to set up the Asterisk -> Nagios connection and let Nagios handle it. That way, you can fully manage both without any changes to the underlying Asterisk system.

Change the crontab entry to

0 9-17/4 * * * . . .

Where workhours are 9to5 and you want to ‘get off your ass’ every 4 hours

1 Like

Thanks for the input guys.

Still waiting on the last actual bugs I reported to be fixed, so I’m not going to bother the devs with something so simple, even though it’s kinda crazy to not permit notifications to be configured.

Don’t know why, but copy/pasting that crontab entry to the storage.php line resulted in no notifications at all being sent from last Friday up until about 10 minutes ago - then I got the first one. :thinking: (Hey, at least it shut up & didn’t fill up my mailbox all weekend long! :wink: :smiley: )

I didn’t care for it only checking between those hours - if something goes haywire & fills the drive, I want to know NOW. So I wrote a script in perl which is how the built-in feature should’ve been written IMO. It allows for virtually any number of alerts to be defined which are triggered on the percentage of drive space remaining, you can set each alert to notify one or more admins or have all alerts go to a single admin, you can set each alert to notify the admin every n hours, and you can specify which file systems to be monitored. Wrote it in my spare time on Friday & today - just turned it on & am testing now. Once I’m confident I didn’t do anything completely idiotic, I’ll share it so that others may benefit from my work. :slight_smile: (Believe it or not, I actually added documentation with the intent of sharing… my old coding instructors would be so proud! :laughing: )

Question: Is it permitted to post a script like this on these forums?

https://crontab.guru/

As to posting code, I have had scripts deleted , but that was when other folks were in charge

probably posting with the hash/bang commented might be more acceptable 'cos then it is ‘not a script’ that can be blindly copy/pasted into a shell but still open for peer review which is always a good thing

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.