- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Need help in adding 'LowFree' value of /proc/m...
Operating System - Linux
1753604
Members
6018
Online
108797
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-31-2009 07:28 AM
тАО08-31-2009 07:28 AM
Need help in adding 'LowFree' value of /proc/meminfo in Nagios script.
Hi,
I have attached a script(check_ram)which is for memory monitoring in Nagios. I have tested and it's working fine. I would like to add the 'LowFree' value of /proc/meminfo in that so that it checks and sends the alert based on LowFree value of /proc/meminfo. As of now this scripts checks the other value of /proc/meminfo and sends the alert.
I am not good in scripting and need you help on this.
Thanks in advance.
Gaby
I have attached a script(check_ram)which is for memory monitoring in Nagios. I have tested and it's working fine. I would like to add the 'LowFree' value of /proc/meminfo in that so that it checks and sends the alert based on LowFree value of /proc/meminfo. As of now this scripts checks the other value of /proc/meminfo and sends the alert.
I am not good in scripting and need you help on this.
Thanks in advance.
Gaby
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2009 05:35 AM
тАО09-01-2009 05:35 AM
Re: Need help in adding 'LowFree' value of /proc/meminfo in Nagios script.
Hi Gaby,
your attachment is a Nagios plug-in written in Python.
Though I can read the Python code I am not into scripting in Python.
Had it been a Perl or Bash plug-in I probably could have helped.
Hey, but this is good way for you to get started learning some Python.
Although I am quite perl-biased some Python skills won't hurt (especially on RedHat Linux much of their systems programming is done in Python, e.g. Yum).
Only bear in mind that in Python indentations are mandatory.
It doesn't matter how many spaces you indent the control structure or function blocks as long as all lines within them are indented by the same spacing.
So if you're interested in LowFree why not just add an extra elif block here?
for x in range(len(output)):
y = output[x].split()
if y [0] == "MemTotal:":
memtotal = int(y[1])
elif y[0] == "MemFree:":
memfree = int(y[1])
elif y[0] == "Cached:":
memcached = int(y[1])
elif y[0] == "LowFree:":
lowfree = int(y[1])
Then of course this list also needs to be extended:
for x in memtotal,memfree,memcached,lowfree:
Some more work is required within the memory arithmetics block following the parsing
because the plug-in caters for passed in warning and critical thresholds in a variety of units (e.g. KB, MB, GB, %).
As a general hint I would suggest that you replaced the conditionals referring to total_free by something like e.g.
if lowfree < critical_threshold:
etc.
It simply requires a bit of fiddling on your behalf.
Since Python is a scripting language there are no long compile cycles involved and you can try out changes to the code immediately as you script along.
Or if you cannot reconcile with the idea of scripting at all ask some Python hacker to do the little changes for you.
your attachment is a Nagios plug-in written in Python.
Though I can read the Python code I am not into scripting in Python.
Had it been a Perl or Bash plug-in I probably could have helped.
Hey, but this is good way for you to get started learning some Python.
Although I am quite perl-biased some Python skills won't hurt (especially on RedHat Linux much of their systems programming is done in Python, e.g. Yum).
Only bear in mind that in Python indentations are mandatory.
It doesn't matter how many spaces you indent the control structure or function blocks as long as all lines within them are indented by the same spacing.
So if you're interested in LowFree why not just add an extra elif block here?
for x in range(len(output)):
y = output[x].split()
if y [0] == "MemTotal:":
memtotal = int(y[1])
elif y[0] == "MemFree:":
memfree = int(y[1])
elif y[0] == "Cached:":
memcached = int(y[1])
elif y[0] == "LowFree:":
lowfree = int(y[1])
Then of course this list also needs to be extended:
for x in memtotal,memfree,memcached,lowfree:
Some more work is required within the memory arithmetics block following the parsing
because the plug-in caters for passed in warning and critical thresholds in a variety of units (e.g. KB, MB, GB, %).
As a general hint I would suggest that you replaced the conditionals referring to total_free by something like e.g.
if lowfree < critical_threshold:
etc.
It simply requires a bit of fiddling on your behalf.
Since Python is a scripting language there are no long compile cycles involved and you can try out changes to the code immediately as you script along.
Or if you cannot reconcile with the idea of scripting at all ask some Python hacker to do the little changes for you.
Madness, thy name is system administration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2009 06:39 AM
тАО09-01-2009 06:39 AM
Re: Need help in adding 'LowFree' value of /proc/meminfo in Nagios script.
Hi Ralph,
Thanks a lot for the reply. I have a perl script as well which I am attaching here.
Could you please help me to add the LowFree (/proc/meminfo) option in that. I have tested this script and it's working fine but I need to add the 'LowFree' of /proc/meminfo in the same so that I can get alert whenever the LowFree is below 100MB.
Thanks
Gaby
Thanks a lot for the reply. I have a perl script as well which I am attaching here.
Could you please help me to add the LowFree (/proc/meminfo) option in that. I have tested this script and it's working fine but I need to add the 'LowFree' of /proc/meminfo in the same so that I can get alert whenever the LowFree is below 100MB.
Thanks
Gaby
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2009 12:53 AM
тАО09-02-2009 12:53 AM
Re: Need help in adding 'LowFree' value of /proc/meminfo in Nagios script.
Hi Gaby,
I have patched your post's attachment that included the check_mem.pl Nagios plug-in and attached my patch
although it probably would have been wiser to rewrite the plug-in from scratch.
As I wasn't so sure how your requirement with regard to the LowFree value is
I assumed that it would be ok to just relate it to LowTotal and stick to the relative free check in percentage.
Thus, I got rid of all the code parts that applied to the -f, -u, and -C options to the plug-in.
Hope, that is somewhat close to your requirement.
Ah, and since you posted this thread in the Linux Forum I of course also got rid of the code bits that cater for running this plug-in on Solaris where either the existence of the KStat module or some parsing of (Solaris) vmstat's output was required.
To apply my patch just copy your original plug-in to e.g. check_lowmem.pl and then issue
$ patch check_lowmem.pl check_mem.pl.patch
I have patched your post's attachment that included the check_mem.pl Nagios plug-in and attached my patch
although it probably would have been wiser to rewrite the plug-in from scratch.
As I wasn't so sure how your requirement with regard to the LowFree value is
I assumed that it would be ok to just relate it to LowTotal and stick to the relative free check in percentage.
Thus, I got rid of all the code parts that applied to the -f, -u, and -C options to the plug-in.
Hope, that is somewhat close to your requirement.
Ah, and since you posted this thread in the Linux Forum I of course also got rid of the code bits that cater for running this plug-in on Solaris where either the existence of the KStat module or some parsing of (Solaris) vmstat's output was required.
To apply my patch just copy your original plug-in to e.g. check_lowmem.pl and then issue
$ patch check_lowmem.pl check_mem.pl.patch
Madness, thy name is system administration
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP